mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add privatemessage base
This commit is contained in:
parent
82626346ce
commit
956b1a8614
2 changed files with 31 additions and 0 deletions
|
@ -44,6 +44,10 @@ func main() {
|
|||
logger: logger,
|
||||
}
|
||||
|
||||
app.twitchClient.OnPrivateMessage(func(message twitch.PrivateMessage) {
|
||||
app.handlePrivateMessage(message)
|
||||
})
|
||||
|
||||
app.twitchClient.Join("nourylul")
|
||||
app.twitchClient.Join("nourybot")
|
||||
|
||||
|
|
27
cmd/bot/privatemessage.go
Normal file
27
cmd/bot/privatemessage.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import "github.com/gempir/go-twitch-irc/v3"
|
||||
|
||||
func (app *application) handlePrivateMessage(message twitch.PrivateMessage) {
|
||||
// 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 == "" {
|
||||
app.logger.Print("Missing room-id in message tag ", roomId)
|
||||
return
|
||||
}
|
||||
|
||||
if len(message.Message) >= 2 {
|
||||
if message.Message[:2] == "()" {
|
||||
// TODO: Command Handling
|
||||
app.logger.Println("[Command detected]: ", message.Message)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Message was no command so we just print it.
|
||||
app.logger.Printf("[#%s]:%s: %s", message.Channel, message.User.DisplayName, message.Message)
|
||||
|
||||
}
|
Loading…
Reference in a new issue