From 3dd007178c6e654b0609e1ec3387398a157ee7a8 Mon Sep 17 00:00:00 2001 From: Daniel Aberger Date: Sun, 24 Apr 2016 14:54:09 +0200 Subject: [PATCH] more params! --- modules/modules.go | 2 +- modules/ts3.go | 22 ++++++++++++---------- modules/twitch.go | 12 ++++++++---- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/modules/modules.go b/modules/modules.go index 32397ea..f27c77b 100644 --- a/modules/modules.go +++ b/modules/modules.go @@ -37,7 +37,7 @@ var ( func Init(ch chan Payload, params string) { SayCh = ch for _, param := range strings.Split(params, "!") { - kv := strings.Split(param, ":") + kv := strings.Split(param, ";") ModParams[kv[0]] = kv[1] log.Println(kv[0], kv[1]) } diff --git a/modules/ts3.go b/modules/ts3.go index a6b148b..38f443a 100644 --- a/modules/ts3.go +++ b/modules/ts3.go @@ -11,13 +11,14 @@ import ( ) var ( - users = map[string]bool{} - host string - port string - user string - pass string - botname string - channel string + users = map[string]bool{} + host string + port string + user string + pass string + botname string + channel string + tsboticon string ) func init() { @@ -33,6 +34,7 @@ func setConfig() { pass = ModParams["tspass"] botname = ModParams["tsbotname"] channel = ModParams["tschan"] + tsboticon = ModParams["tsboticon"] go loop() } func loop() { @@ -59,12 +61,12 @@ func loop() { } else { for i, _ := range neu { if users[i] != neu[i] { - SayCh <- GeneratePayload(channel, ":poop:", i+" joined TS3.", botname) + SayCh <- GeneratePayload(channel, tsboticon, i+" joined TS3.", botname) } } for i, _ := range users { if users[i] != neu[i] { - SayCh <- GeneratePayload(channel, ":poop:", i+" left TS3.", botname) + SayCh <- GeneratePayload(channel, tsboticon, i+" left TS3.", botname) } } users = neu @@ -87,7 +89,7 @@ func ts3HandleMessage(payload *WebhookPayload) { s += "\n" } } - SayCh <- GeneratePayload("@"+payload.UserName, ":poop:", s, botname) + SayCh <- GeneratePayload("@"+payload.UserName, tsboticon, s, botname) } } diff --git a/modules/twitch.go b/modules/twitch.go index d35e953..05e7b2c 100644 --- a/modules/twitch.go +++ b/modules/twitch.go @@ -114,6 +114,8 @@ type TwitchStreamObject struct { var ( announceChannel string + twitchBotIcon string + twitchBotName string twitch = map[string]bool{ "rocketbeanstv": false, "blizzard": false, @@ -136,6 +138,8 @@ func init() { func configAndPoll() { time.Sleep(5 * time.Second) announceChannel = ModParams["twitchchan"] + twitchBotIcon = ModParams["twitchicon"] + twitchBotName = ModParams["twitchbotname"] go pollStreamData() } @@ -182,7 +186,7 @@ func handleCommand(tok []string, target string, isSlashCommand bool) { } } if onlinestreams == 0 { - SayCh <- GeneratePayload(target, "", "All streams offline", "Twitch_Bot") + SayCh <- GeneratePayload(target, twitchBotIcon, "All streams offline", twitchBotName) } case 2 - tokMod: streamname := tok[1-tokMod] @@ -193,7 +197,7 @@ func handleCommand(tok []string, target string, isSlashCommand bool) { co = getTwitchChannelObject(streamname) twitchSendMsg(co, so, target) } else { - SayCh <- GeneratePayload(target, "", streamname+" not found or offline", "Twitch_Bot") + SayCh <- GeneratePayload(target, twitchBotIcon, streamname+" not found or offline", twitchBotName) } default: } @@ -263,11 +267,11 @@ func twitchSendMsg(tcobj TwitchChannelObject, tso TwitchStreamObject, target str target = announceChannel } SayCh <- GeneratePayload(target, - "", + twitchBotIcon, "*"+tso.Stream.Channel.DisplayName+ "*\n*Title:* "+tcobj.Status+ "\n*Viewers:* "+util.NumberToString(tso.Stream.Viewers, '.')+ "\n*Playing:* "+tso.Stream.Game+ "\n"+tcobj.URL+"\n", - "Twitch_Bot") + twitchBotName) }