Skip to content

Instantly share code, notes, and snippets.

@rvause
Created June 17, 2021 17:55
Show Gist options
  • Save rvause/c8db121debcd38bbe2cb96fdb8c1769c to your computer and use it in GitHub Desktop.
Save rvause/c8db121debcd38bbe2cb96fdb8c1769c to your computer and use it in GitHub Desktop.
"""
Simple bot to echo events in a Twitch channel.
Need to fill out the data in the commands.Bot() call below to connect.
irc_token: You can get a token to use here by connecting your account here: https://twitchapps.com/tmi/
client_id: Register a Twitch app and copy the client_id https://dev.twitch.tv/console/apps/create
nick: Your twitch username
initial_channels: the channels you wish to watch for events on
To run the bot you need Python.
$ pip install twitchio
$ python echobot.py
"""
from twitchio.ext import commands
bot = commands.Bot(
irc_token="",
client_id="",
nick="",
prefix="!",
initial_channels=[""],
)
@bot.event
async def event_ready():
print("Bot online!")
@bot.event
async def event_message(ctx):
print(f"{ctx.timestamp} {ctx.author}: {ctx.tags}")
print(ctx.raw_data)
print("")
if __name__ == "__main__":
bot.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment