diff --git a/main.go b/main.go index 8d7a5f8..bb8d15a 100644 --- a/main.go +++ b/main.go @@ -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") diff --git a/vtuber.go b/vtuber.go index b2b0f30..8fef2a6 100644 --- a/vtuber.go +++ b/vtuber.go @@ -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 }