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")
|
client.SendText(evt.RoomID, "Reloading config")
|
||||||
fmt.Println("Reload requested,reloading vtubers")
|
fmt.Println("Reload requested,reloading vtubers")
|
||||||
vtubers = LoadVtubers()
|
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":
|
case "help":
|
||||||
client.SendText(evt.RoomID, "Supported commands: info,version,stats")
|
client.SendText(evt.RoomID, "Supported commands: info,version,stats,reload,subscribe")
|
||||||
default:
|
default:
|
||||||
//command not found
|
//command not found
|
||||||
client.SendText(evt.RoomID, "command not recognized")
|
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))
|
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)))
|
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 {
|
if err != nil {
|
||||||
log.Println("error embeding video")
|
log.Println("error embeding video")
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
"maunium.net/go/mautrix/id"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VtuberConfig struct {
|
type VtuberConfig struct {
|
||||||
@ -25,6 +26,7 @@ type Vtuber struct {
|
|||||||
LiveMsg string
|
LiveMsg string
|
||||||
AnnounceLive bool
|
AnnounceLive bool
|
||||||
TotalStreams int
|
TotalStreams int
|
||||||
|
Subs map[id.UserID]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVtuber(name, channelID, liveMsg string, announce bool) *Vtuber {
|
func NewVtuber(name, channelID, liveMsg string, announce bool) *Vtuber {
|
||||||
@ -36,6 +38,7 @@ func NewVtuber(name, channelID, liveMsg string, announce bool) *Vtuber {
|
|||||||
LiveMsg: liveMsg,
|
LiveMsg: liveMsg,
|
||||||
AnnounceLive: announce,
|
AnnounceLive: announce,
|
||||||
TotalStreams: 0,
|
TotalStreams: 0,
|
||||||
|
Subs: make(map[id.UserID]bool),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user