add subs
This commit is contained in:
parent
599540b342
commit
a8c0c96505
18
main.go
18
main.go
@ -153,8 +153,19 @@ func main() {
|
||||
client.SendText(evt.RoomID, "Reloading config")
|
||||
fmt.Println("Reload requested,reloading vtubers")
|
||||
vtubers = LoadVtubers()
|
||||
case "subscribe":
|
||||
if len(body_s) < 3 {
|
||||
client.SendText(evt.RoomID, "Need a member to subscribe to")
|
||||
}
|
||||
vt := body_s[2]
|
||||
for _, v := range vtubers {
|
||||
if strings.ToUpper(v.Name) == strings.ToUpper(vt) {
|
||||
v.Subs[evt.Sender] = true
|
||||
}
|
||||
}
|
||||
|
||||
case "help":
|
||||
client.SendText(evt.RoomID, "Supported commands: info,version,stats")
|
||||
client.SendText(evt.RoomID, "Supported commands: info,version,stats,reload,subscribe")
|
||||
default:
|
||||
//command not found
|
||||
client.SendText(evt.RoomID, "command not recognized")
|
||||
@ -211,6 +222,11 @@ func main() {
|
||||
}
|
||||
}
|
||||
client.SendNotice(room, fmt.Sprintf("%v's Title: %v", v.Name, v.CurrentStreamTitle))
|
||||
var subs string
|
||||
for k := range v.Subs {
|
||||
subs += k.String() + " "
|
||||
}
|
||||
client.SendText(room, fmt.Sprintf("Pinging %v", subs))
|
||||
resp, err := client.SendStateEvent(room, event.NewEventType("im.vector.modular.widgets"), "dimension-m.video-simp-"+v.Name, NewYT(v.Name+"'s stream", v.CurrentStream, string(room)))
|
||||
if err != nil {
|
||||
log.Println("error embeding video")
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
type VtuberConfig struct {
|
||||
@ -25,6 +26,7 @@ type Vtuber struct {
|
||||
LiveMsg string
|
||||
AnnounceLive bool
|
||||
TotalStreams int
|
||||
Subs map[id.UserID]bool
|
||||
}
|
||||
|
||||
func NewVtuber(name, channelID, liveMsg string, announce bool) *Vtuber {
|
||||
@ -36,6 +38,7 @@ func NewVtuber(name, channelID, liveMsg string, announce bool) *Vtuber {
|
||||
LiveMsg: liveMsg,
|
||||
AnnounceLive: announce,
|
||||
TotalStreams: 0,
|
||||
Subs: make(map[id.UserID]bool),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user