add options for not annoucing, show title

This commit is contained in:
stryan 2021-08-23 19:44:20 -04:00
parent 4bddee9ee9
commit 82f0d7af58
2 changed files with 21 additions and 10 deletions

View File

@ -134,7 +134,12 @@ func main() {
var content YoutubeWidget
err = client.StateEvent(room, event.NewEventType("im.vector.modular.widgets"), "dimension-m.video-simp-"+v.Name, &content)
if content.ID == "" {
client.SendText(room, v.LiveMsg)
if v.AnnounceLive {
client.SendText(room, v.LiveMsg)
} else {
client.SendNotice(room, v.LiveMsg)
}
client.SendNotice(room, fmt.Sprintf("%v's Title: %v", v.Name, v.CurrentStreamTitle))
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")

View File

@ -17,18 +17,22 @@ type VtuberConfig struct {
}
type Vtuber struct {
Name string
ChannelID string
CurrentStream string
LiveMsg string
Name string
ChannelID string
CurrentStream string
CurrentStreamTitle string
LiveMsg string
AnnounceLive bool
}
func NewVtuber(name, channelID, liveMsg string) *Vtuber {
func NewVtuber(name, channelID, liveMsg string, announce bool) *Vtuber {
return &Vtuber{
Name: name,
ChannelID: channelID,
CurrentStream: "",
LiveMsg: liveMsg,
Name: name,
ChannelID: channelID,
CurrentStream: "",
CurrentStreamTitle: "",
LiveMsg: liveMsg,
AnnounceLive: announce,
}
}
@ -72,11 +76,13 @@ func (v *Vtuber) Update() error {
for _, s := range sl.Streams {
if s.Status == "live" {
v.CurrentStream = s.ID
v.CurrentStreamTitle = s.Title
found = true
}
}
if !found {
v.CurrentStream = ""
v.CurrentStreamTitle = ""
}
return nil
}