add basic whisper message handler

This commit is contained in:
lyx0 2021-10-14 15:14:38 +02:00
parent 010692ade3
commit e53fd561b3
3 changed files with 20 additions and 3 deletions

View file

@ -31,6 +31,10 @@ func (b *Bot) Connect() error {
handlers.HandlePrivateMessage(message, b.twitchClient, cfg)
})
b.twitchClient.OnWhisperMessage(func(message twitch.WhisperMessage) {
handlers.HandleWhisperMessage(message, b.twitchClient)
})
err := b.twitchClient.Connect()
if err != nil {
log.Error("Error Connecting from Twitch: ", err)

View file

@ -43,8 +43,7 @@ func HandlePrivateMessage(message twitch.PrivateMessage, client *twitch.Client,
}
}
// Message was no command, just log it for now
// TODO: Add actual message logger
log.Info(message)
// Message was no command
// log.Info(message)
}

14
pkg/handlers/whisper.go Normal file
View file

@ -0,0 +1,14 @@
package handlers
import (
"github.com/gempir/go-twitch-irc/v2"
log "github.com/sirupsen/logrus"
)
func HandleWhisperMessage(whisper twitch.WhisperMessage, client *twitch.Client) {
log.Info("fn HandleWhisperMessage")
log.Info(whisper)
if whisper.Message == "xd" {
client.Whisper(whisper.User.Name, "xd")
}
}