add options for not annoucing, show title
This commit is contained in:
parent
4bddee9ee9
commit
82f0d7af58
5
main.go
5
main.go
@ -134,7 +134,12 @@ func main() {
|
|||||||
var content YoutubeWidget
|
var content YoutubeWidget
|
||||||
err = client.StateEvent(room, event.NewEventType("im.vector.modular.widgets"), "dimension-m.video-simp-"+v.Name, &content)
|
err = client.StateEvent(room, event.NewEventType("im.vector.modular.widgets"), "dimension-m.video-simp-"+v.Name, &content)
|
||||||
if content.ID == "" {
|
if content.ID == "" {
|
||||||
|
if v.AnnounceLive {
|
||||||
client.SendText(room, v.LiveMsg)
|
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)))
|
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")
|
||||||
|
@ -20,15 +20,19 @@ type Vtuber struct {
|
|||||||
Name string
|
Name string
|
||||||
ChannelID string
|
ChannelID string
|
||||||
CurrentStream string
|
CurrentStream string
|
||||||
|
CurrentStreamTitle string
|
||||||
LiveMsg string
|
LiveMsg string
|
||||||
|
AnnounceLive bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVtuber(name, channelID, liveMsg string) *Vtuber {
|
func NewVtuber(name, channelID, liveMsg string, announce bool) *Vtuber {
|
||||||
return &Vtuber{
|
return &Vtuber{
|
||||||
Name: name,
|
Name: name,
|
||||||
ChannelID: channelID,
|
ChannelID: channelID,
|
||||||
CurrentStream: "",
|
CurrentStream: "",
|
||||||
|
CurrentStreamTitle: "",
|
||||||
LiveMsg: liveMsg,
|
LiveMsg: liveMsg,
|
||||||
|
AnnounceLive: announce,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,11 +76,13 @@ func (v *Vtuber) Update() error {
|
|||||||
for _, s := range sl.Streams {
|
for _, s := range sl.Streams {
|
||||||
if s.Status == "live" {
|
if s.Status == "live" {
|
||||||
v.CurrentStream = s.ID
|
v.CurrentStream = s.ID
|
||||||
|
v.CurrentStreamTitle = s.Title
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
v.CurrentStream = ""
|
v.CurrentStream = ""
|
||||||
|
v.CurrentStreamTitle = ""
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user