add eventsub debug command

This commit is contained in:
nouryxd 2024-05-16 22:20:11 +02:00
parent e9c9118321
commit efc5793849
3 changed files with 83 additions and 1 deletions

View file

@ -179,7 +179,6 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
}
case "ping":
reply = commands.Ping(app.Environment)
// ()bttv <emote name>
// ()weather <location>
case "weather":
@ -267,6 +266,10 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
if userLevel >= 100 {
app.DebugChannelTimers(message.Channel)
}
case "eventsub":
if userLevel >= 1000 {
reply = app.listEventSubSubscriptions()
}
}
// --------------------------------
@ -388,11 +391,21 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
app.ConvertAndSave(cmdParams[1], cmdParams[2], message)
}
case "echo":
if userLevel >= 1000 {
reply = message.Message[7:len(message.Message)]
}
case "say":
if userLevel >= 1000 {
reply = message.Message[6:len(message.Message)]
}
// case "whisper":
// if userLevel >= 1000 {
// go app.sendWhisper(cmdParams[1], message.Message[10:len(message.Message)])
// }
case "join":
if userLevel >= 1000 {
go app.AddChannel(cmdParams[1], message)
@ -495,6 +508,13 @@ var helpText = map[string]command{
Level: "0",
Usage: "()commands",
},
"conv": {
Name: "conv",
Alias: nil,
Description: "Converts the linked video into an .mp4 file.",
Level: "1000",
Usage: "()conv <video link>",
},
"currency": {
Name: "currency",
Alias: []string{"currency", "money"},
@ -509,6 +529,13 @@ var helpText = map[string]command{
Level: "100",
Usage: "()debug env",
},
"debug eventsub": {
Name: "debug eventsub",
Alias: nil,
Description: "Returns information about current eventsub subscriptions.",
Level: "1000",
Usage: "()debug eventsub",
},
"debug user": {
Name: "debug user",
Alias: nil,
@ -614,6 +641,13 @@ var helpText = map[string]command{
Level: "0",
Usage: "()lastfm [username]",
},
"meme": {
Name: "meme",
Alias: nil,
Description: "Downloads the linked video and saves it with the specified name in .mp4 format.",
Level: "1000",
Usage: "()meme <name> <video link>",
},
"notify live": {
Name: "notify live",
Alias: nil,
@ -670,6 +704,13 @@ var helpText = map[string]command{
Level: "0",
Usage: "()randomxkcd",
},
"say": {
Name: "say",
Alias: []string{"say", "echo"},
Description: "Makes the bot say something.",
Level: "1000",
Usage: "()say xD",
},
"seventv": {
Name: "seventv",
Alias: []string{"seventv", "7tv"},

View file

@ -194,3 +194,25 @@ func (app *application) deleteOfflineSubscription(target, channel string) string
app.Log.Infof("%+v\n", resp2)
return fmt.Sprintf("Successfully deleted live notification for channel %s; id=%v", channel, uid)
}
// createLiveSubscription creates a stream.online twitch eventsub subscription for the specified channel
func (app *application) listEventSubSubscriptions() string {
resp, err := app.HelixClient.GetEventSubSubscriptions(&helix.EventSubSubscriptionsParams{})
if err != nil {
app.Log.Errorw("Error listing Eventsub subscriptions",
"resp", resp,
"err", err,
)
}
app.Log.Infof("%+v\n", resp)
link, err := app.uploadPaste(fmt.Sprint(resp))
if err != nil {
app.Log.Errorw("Error creating paste",
"err", err,
)
}
app.Log.Info(link)
return fmt.Sprintf("Subscriptions: asdad")
}

View file

@ -79,3 +79,22 @@ func (app *application) getChannelGameByUsername(username string) string {
reply := app.getChannelGame(channelID)
return reply
}
//func (app *application) sendWhisper(username, text string) {
// toID, err := app.getUserID(username)
// if err != nil {
// app.Log.Error(err)
// return
// }
//
// resp, err := app.HelixClient.SendUserWhisper(&helix.SendUserWhisperParams{
// FromUserID: "mycoolid",
// ToUserID: toID,
// Message: text,
// })
// if err != nil {
// app.Log.Error(err)
// }
//
// app.Log.Infof("%+v\n", resp)
//}