gofumpt
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
stryan 2023-05-14 19:13:23 -04:00
parent ba285c4e49
commit ae50a68aea
3 changed files with 33 additions and 17 deletions

View File

@ -63,13 +63,11 @@ func main() {
wg.Add(1) wg.Add(1)
go func() { go func() {
err = simp.client.Sync() err = simp.client.Sync()
if err != nil { if err != nil {
log.Error(err) log.Error(err)
} }
wg.Done() wg.Done()
}() }()
wg.Add(1) wg.Add(1)
@ -81,7 +79,6 @@ func main() {
log.Info("simpbot running") log.Info("simpbot running")
wg.Wait() wg.Wait()
log.Info("shutting down") log.Info("shutting down")
} }
func isValidURL(toTest string) bool { func isValidURL(toTest string) bool {

24
simp.go
View File

@ -55,7 +55,12 @@ func (s *simp) Run() {
if v.IsLive() { if v.IsLive() {
// check to see if already embeded // check to see if already embeded
var content youtubeWidget var content youtubeWidget
err = s.client.StateEvent(room, event.NewEventType("im.vector.modular.widgets"), "dimension-m.video-simp-"+v.Name, &content) err = s.client.StateEvent(
room,
event.NewEventType("im.vector.modular.widgets"),
"dimension-m.video-simp-"+v.Name,
&content,
)
if err != nil { if err != nil {
log.Errorf("error getting state event in room %v: %v", room, err) log.Errorf("error getting state event in room %v: %v", room, err)
} }
@ -77,7 +82,12 @@ func (s *simp) Run() {
if len(v.Subs) > 0 { if len(v.Subs) > 0 {
s.client.SendText(room, fmt.Sprintf("Pinging %v", subs)) s.client.SendText(room, fmt.Sprintf("Pinging %v", subs))
} }
resp, err := s.client.SendStateEvent(room, event.NewEventType("im.vector.modular.widgets"), "dimension-m.video-simp-"+v.Name, s.NewYT(v.Name+"'s stream", v.CurrentStream, string(room))) resp, err := s.client.SendStateEvent(
room,
event.NewEventType("im.vector.modular.widgets"),
"dimension-m.video-simp-"+v.Name,
s.NewYT(v.Name+"'s stream", v.CurrentStream, string(room)),
)
if err != nil { if err != nil {
log.Errorf("error embeding video: %v", err) log.Errorf("error embeding video: %v", err)
} }
@ -106,7 +116,6 @@ func (s *simp) Run() {
} }
} }
} }
} }
func (s *simp) SetupMatrix(uname, pass, token, hs, domain, dserver string) error { func (s *simp) SetupMatrix(uname, pass, token, hs, domain, dserver string) error {
@ -197,7 +206,14 @@ func (s *simp) SetupMatrix(uname, pass, token, hs, domain, dserver string) error
vlist = append(vlist, fmt.Sprintf("%v Total:%v", vt.Name, vt.TotalStreams)) vlist = append(vlist, fmt.Sprintf("%v Total:%v", vt.Name, vt.TotalStreams))
t = t + vt.TotalStreams t = t + vt.TotalStreams
} }
statmsg = fmt.Sprintf("Current Stats Since %v:\n%v\n\nTotal Streams: %v\nMost Concurrent: %v/%v\n", s.startTime, strings.Join(vlist, "\n"), t, s.maxStream, len(s.vtubers)) statmsg = fmt.Sprintf(
"Current Stats Since %v:\n%v\n\nTotal Streams: %v\nMost Concurrent: %v/%v\n",
s.startTime,
strings.Join(vlist, "\n"),
t,
s.maxStream,
len(s.vtubers),
)
s.client.SendText(evt.RoomID, statmsg) s.client.SendText(evt.RoomID, statmsg)
case "version": case "version":
s.client.SendText(evt.RoomID, "not implemented") s.client.SendText(evt.RoomID, "not implemented")

View File

@ -64,7 +64,10 @@ func (v *Vtuber) IsLive() bool {
// Update takes an apiKey and updates the vtuber struct // Update takes an apiKey and updates the vtuber struct
func (v *Vtuber) Update(apiKey string) error { func (v *Vtuber) Update(apiKey string) error {
url := fmt.Sprintf("https://holodex.net/api/v2/live?channel_id=%s&lang=all&sort=available_at&order=desc&limit=25&offset=0&paginated=%%3Cempty%%3E", v.ChannelID) url := fmt.Sprintf(
"https://holodex.net/api/v2/live?channel_id=%s&lang=all&sort=available_at&order=desc&limit=25&offset=0&paginated=%%3Cempty%%3E",
v.ChannelID,
)
req, err := http.NewRequest("GET", url, nil) req, err := http.NewRequest("GET", url, nil)
req.Header.Set("X-APIKEY", apiKey) req.Header.Set("X-APIKEY", apiKey)
if err != nil { if err != nil {