From 9ea74bde41c6a12bd0281be67ea9ec40106788fb Mon Sep 17 00:00:00 2001 From: Kesuaheli Date: Mon, 25 Dec 2023 01:18:08 +0100 Subject: [PATCH] update twitch library --- go.mod | 2 +- go.sum | 4 ++-- main.go | 2 +- twitch/messageHandler.go | 7 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index a30a977..dceacf0 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/bwmarrin/discordgo v0.27.1 github.com/go-sql-driver/mysql v1.7.1 github.com/gorilla/mux v1.8.0 - github.com/kesuaheli/twitchgo v0.1.0 + github.com/kesuaheli/twitchgo v0.2.1 github.com/spf13/viper v1.15.0 ) diff --git a/go.sum b/go.sum index 200eeb3..f9b4623 100644 --- a/go.sum +++ b/go.sum @@ -135,8 +135,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kesuaheli/twitchgo v0.1.0 h1:vteAnegcvvY6aog8Z5X35BLmu6bUV3Hw/7hnw4D5bLg= -github.com/kesuaheli/twitchgo v0.1.0/go.mod h1:swIW1jJcFa4bWi/9JfUYH4Sf1kAvj+QUcaTPkce+6Ds= +github.com/kesuaheli/twitchgo v0.2.1 h1:483mwaaC2bV3qvhF/zoPjTWmPEtEYx6ASrpy1LmzTh0= +github.com/kesuaheli/twitchgo v0.2.1/go.mod h1:swIW1jJcFa4bWi/9JfUYH4Sf1kAvj+QUcaTPkce+6Ds= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= diff --git a/main.go b/main.go index 5023d52..1d8fa02 100644 --- a/main.go +++ b/main.go @@ -94,7 +94,7 @@ func main() { webserver.Run(addr, webChan) client := twitchgo.New(viper.GetString("twitch.name"), viper.GetString("twitch.token")) - client.SetEventChannelMessage(twitch.MessageHandler) + client.OnChannelMessage(twitch.MessageHandler) err = client.Connect() if err != nil { log.Fatalf("could not open the twitch connection: %v", err) diff --git a/twitch/messageHandler.go b/twitch/messageHandler.go index e535146..505f207 100644 --- a/twitch/messageHandler.go +++ b/twitch/messageHandler.go @@ -20,7 +20,8 @@ import ( "github.com/kesuaheli/twitchgo" ) -func MessageHandler(t *twitchgo.Twitch, message *twitchgo.Message) { - log.Printf("Twitch: [%s] <%s> %s", message.Command.Arguments[0], message.Source, message.Command.Data) - +// MessageHandler handles new messages from the twitch chat(s). It will be called on every new +// message. +func MessageHandler(t *twitchgo.Twitch, channel string, user *twitchgo.User, message string) { + log.Printf("Twitch: [%s] <%s> %s", channel, user.Nickname, message) }