mirror-nourybot/cmd/bot/privatemessage.go

30 lines
823 B
Go
Raw Normal View History

2022-08-07 01:34:31 +02:00
package main
2022-06-21 00:31:17 +02:00
import "github.com/gempir/go-twitch-irc/v3"
2022-08-07 01:34:31 +02:00
func (app *Application) handlePrivateMessage(message twitch.PrivateMessage) {
2022-06-21 00:31:17 +02:00
// roomId is the Twitch UserID of the channel the
// message originated from.
roomId := message.Tags["room-id"]
// If there is no roomId something went wrong.
if roomId == "" {
2022-08-07 01:34:31 +02:00
app.Logger.Error("Missing room-id in message tag ", roomId)
2022-06-21 00:31:17 +02:00
return
}
if len(message.Message) >= 2 {
if message.Message[:2] == "()" {
// TODO: Command Handling
2022-08-07 02:27:40 +02:00
app.Logger.Infof("[Command detected]: ", message.Message)
handleCommand(message, app.TwitchClient)
2022-06-21 00:31:17 +02:00
// app.logger.Infof("[Command detected]: ", message.Message)
return
}
}
// Message was no command so we just print it.
2022-08-07 01:34:31 +02:00
app.Logger.Infof("[#%s]:%s: %s", message.Channel, message.User.DisplayName, message.Message)
2022-06-21 00:31:17 +02:00
}