techygrrrl
techygrrrl's blog

techygrrrl's blog

Building a chatbot for Twitch in Kotlin with Ktor

Building a chatbot for Twitch in Kotlin with Ktor

techygrrrl's photo
techygrrrl
·Jun 24, 2022·

3 min read

Table of contents

  • Features
  • Watch me build it
  • Libraries, tools and API's I used

Features

techydrrroid is my bot that I use to support some interactivity in my streams.

techydrrroid supports commands, e.g. !ping, and reacts to Twitch events. It's aware of subs, followers, bits, and channel point redemptions.

It also has timers and auto-shoutout functionality.

Techydrrroid was written in the Kotlin programming language, which, if you're not familiar with it, is syntactically similar to TypeScript but runs on the Java virtual machine (JVM) and is interoperable with Java. More info and links to resources below.

Twitch events

  • Channel points redemptions (see Channel points redemptions below for more info)
  • saying thanks to subscribers, including gift subs and re-subs
  • saying thanks to followers
  • saying thanks when people give bits
  • saying thanks to raids and sharing information about their latest stream

Moderation

  • Auto-ban suspected bot/smurf accounts

Channel points redemptions

  • Check the weather for any city or airport code
  • Did something out of the ordinary happen? Do you want to blame the planets? You can check if Mercury is in retrograde to see if you can blame Mercury!
  • Get a random joke/pun. Quality not guaranteed.
  • Get a useless random fact, or a furrier random fact about dogs!
  • Get a random programming excuse
  • Get your horoscope read to you. 2 different types of redeems for this one: a more traditional one with a few sentences, and another that tells you your lucky colours, numbers, times, etc. for today
  • Have you been bad? Do you want to make a statement and go sit in a corner? You can time yourself out!
  • Tired of my face? You can play an ad!

Timers

This feature was added to support techydrrroid sending a message to chat on a timed interval, e.g. every 45 minutes.

Auto-shoutouts

When a known streamer registered in the app pops into chat for the first time (in a while), techydrrroid will auto shout them out with a custom message depending on the streamer.

Commands

  • !ping -> check if the bot is up
  • !so -> shoutout users. For broadcasters and mods only.
  • !song -> check what song I'm currently listening to on Spotify
  • !time and !times -> check my time and times around the world
  • !uptime -> how long have I been streaming?
  • !nerd -> randomly generated tech jargon
  • !followage -> find out how long you've been following me for

Watch me build it

I built techydrrroid Ktor app in 5 streams. Streams ranged from 5 to 7 hours long. It was fun tinkering around with Ktor, web sockets, and the Twitch events.

You can watch the playlist of me building techydrrroid here.

You can also see individual videos:

You can also see my other collections here.

Libraries, tools and API's I used

 
Share this