Code Monkey home page Code Monkey logo

barebones-twitch-bot's Introduction

ko-fi

Barebones Twitch Bot in Python

This is the companion repo to a tutorial on dev.to

This is a starter-kit for Twitch chat bot, if you wanna write one in Python. It utilizes the TwitchIO library and YAML files for storing secrets and config info.

It's pretty basic right now, but I'll be expanding on this in the near future. The larger, more complex Twitch bot is being developed HERE during Live-Streams on Twitch.

Getting Started

Should be quick & easy to get up and running but, ofc, if you ever have questions about the specifics, please feel free to ask me during streams or post an issue above.

Prerequisites

  • Python 3.6
  • PIPENV -> python -m pip install pipenv
  • oauth token & client-id for a Twitch account for your bot

Installing

  1. Clone the repo, unzip it somewhere
  2. Open up a console window and navigate to the directory you unzipped it in
  3. Install requirements with pipenv install
  4. Copy & rename integrations-example.yaml to integrations.yaml
  5. Pop in all your secrets into the respective areas in integrations.yaml
  6. Back to the console, pipenv run python bot.py to start the bot
  7. Type !test in the chatroom to test the bot's working

You just installed a basic chat bot for Twitch! Have fun expanding the bot with more commands!! :D

Bot Interaction

Right now, you can only interact with the bot via the single command, !test. You can create similar commands pretty easily, just copy the function and change out the function name decorator arguement...

@bot.command(name='likethis', aliases=['this'])
async def likethis(ctx):
    await ctx.send(f'Asuh, @{ctx.author.name}!')

Test is out with !likethis in chat! :D

Events

There are 2 events that are used in the code right now.. on_ready and on_event.

on_ready

This executes when the bot comes online, and will print out to the console.

@bot.event
async def event_ready():
    print(f'Ready | {bot.nick}')

event_message

This function executes once per event (or message) sent. You can make it handle input from chat that aren't necesarily commands, and fun stuff like that.

@bot.event
async def event_message(message):
    print(message.content)
    await bot.handle_commands(message)

You can find more info in TwitchIO's official documentation.

Progress & Development Info

Contributors & Licenses

NinjaBunny9000 - Author, Project Manager - Twitch // Twitter

Special Thanks

Literally everyone that's helped even the smallest bit during streams. Thank you so much, y'all!

barebones-twitch-bot's People

Contributors

ninjabunny9000 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.