mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2024-12-22 13:13:00 -05:00
32 lines
595 B
Go
32 lines
595 B
Go
|
package chat
|
||
|
|
||
|
type ClientMap map[*Client]bool
|
||
|
|
||
|
var ClientHandler = ClientMap{}
|
||
|
|
||
|
func (c ClientMap) AddClient(client *Client) {
|
||
|
c[client] = true
|
||
|
}
|
||
|
|
||
|
func (c ClientMap) DeleteClient(ID string) {
|
||
|
for client := range c {
|
||
|
if client.ID == ID {
|
||
|
delete(c, client)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (c ClientMap) FindClientsByStreamer(streamer string) []*Client {
|
||
|
var clients []*Client
|
||
|
for client := range c {
|
||
|
// check if the client is following the given streamer
|
||
|
for s, _ := range client.FollowingStreamers {
|
||
|
if s == streamer {
|
||
|
clients = append(clients, client)
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return clients
|
||
|
}
|