Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Extending the bot with external modules

Ash Keel edited this page Nov 19, 2021 · 1 revision

There is no "official" API for adding more interaction to the bot as-is, but there's a way to do it using the Kilovolt server.

Listening to incoming messages

You can listen to incoming messages from users/other bots by subscribing to this key:

twitch/ev/chat-message

Messages will be in JSON format, using this schema: https://github.com/gempir/go-twitch-irc/blob/cb9ca8d0bed6a5b7f81b52d14f7ce508ceeb8fce/client.go#L111

An example message can be found below:

{
   "User":{
      "ID":"603448316",
      "Name":"ashkeelvt",
      "DisplayName":"AshKeelVT",
      "Color":"#EC2B87",
      "Badges":{
         "broadcaster":1,
         "subscriber":0,
         "premium":1
      }
   },
   "Raw":"@badge-info=subscriber/1;badges=broadcaster/1,subscriber/0,premium/1;client-nonce=75e39addea0ca08743c0daf6d86ed59a;color=#EC2B87;display-name=AshKeelVT;emotes=emotesv2_a146a0be7f554de4a6d56a72cd325007:16-26;flags=;id=7709945a-cf3c-4df0-92ca-6c306b1a6d4b;mod=0;room-id=603448316;subscriber=1;tmi-sent-ts=1631801058635;turbo=0;user-id=603448316;user-type= :ashkeelvt!ashkeelvt@ashkeelvt.tmi.twitch.tv PRIVMSG #ashkeelvt :Hello everyone! ashkee1Love",
   "Type":1,
   "RawType":"PRIVMSG",
   "Tags":{
      "badges":"broadcaster/1,subscriber/0,premium/1",
      "flags":"",
      "id":"7709945a-cf3c-4df0-92ca-6c306b1a6d4b",
      "color":"#EC2B87",
      "display-name":"AshKeelVT",
      "emotes":"emotesv2_a146a0be7f554de4a6d56a72cd325007:16-26",
      "turbo":"0",
      "user-type":"",
      "badge-info":"subscriber/1",
      "mod":"0",
      "subscriber":"1",
      "client-nonce":"75e39addea0ca08743c0daf6d86ed59a",
      "room-id":"603448316",
      "tmi-sent-ts":"1631801058635",
      "user-id":"603448316"
   },
   "Message":"Hello everyone! ashkee1Love",
   "Channel":"ashkeelvt",
   "RoomID":"603448316",
   "ID":"7709945a-cf3c-4df0-92ca-6c306b1a6d4b",
   "Time":"2021-09-16T16:04:18.635+02:00",
   "Emotes":[
      {
         "Name":"ashkee1Love",
         "ID":"emotesv2_a146a0be7f554de4a6d56a72cd325007",
         "Count":1
      }
   ],
   "Bits":0,
   "Action":false
}

If you wanted to add a new command like "!lurk", you could just set up a subscription handler and check if a message contains your trigger word of choice, then move to the next step.

Writing back to chat

You can write arbitrary messages to chat as the strimertul bot by writing to this key:

twitch/@send-chat-message

No format needed, just write the string you want to see in chat!