Simple Chatbot

A chatbot written in Python for twitch IRC (twitch chat). Keep your viewers engaged with an interactive chatbot where they can earn currency and gamble for fun! Make fun little command responses that are unique to you!
Source code can be found on the github repository.
Please post ALL bug reports in the issues page on the github!


Development Update #4 (04/08/2019)

Slots are now fully implemented!
The beauty of writing all these custom modules early in development makes adding new features super simple. I only had to write one new function to make the script work (cost_subtract) and after some minor troubleshooting, it worked flawlessly. Not a whole lot to say other than that and some other improvements were made like cleaner command parsing. Check out the update on the github linked at the top of this page!


Development Update #3 (04/04/2019)

I have just added some new and awesome changes to the github for this project! Over the past couple of weeks I toyed a lot with where I wanted to go from here and how I could make my life easier in the future when I need to move forward. Here is an overview of some of the functions I've added:

  • SqliteReadDB
    • read_username(userid) - Gets the username from the given user that comes from twitch
    • read_cooldown(userid, game) - Gets the cooldown state or duration (false if they aren't on cooldown and a number if they are) for the specified user and game
    • read_currency(userid) - Gets the currency amount for the specified user
  • SqliteUpdateDB
    • update_username(userid, username) - Updates the username. Only called if the database username and the twitch username do not match (run every time a command is received).
    • add_user(userid, username, currency, joincooldown, slotscooldown) - Adds the specified user to the databse with some cookie cutter information provided from the main script (can be altered if you want to add currency to start)
    • add_currency(userid, currency) - Adds the specified currency amount to the user. Math is done in the function using the currency in the database (pulled internally)
    • add_cooldown(userid, game, cooldown) - Adds a cooldown for the user for the specified duration and command (game).
  • commandParser
    • response_format(e, settings, cmd) - Will format the response to a command as well as checks if the command is valid. This allows for command additions from the config file (!!!)
I also added some import exceptions to fix intermittent errors I received when running the bot from command line versus in my IDE
Overall, I am very happy with the progress I made here, and will be taking a short break to recuperate and mess around with some stuff internally. I've learned so much recently and my brain just feels stuffed full of information (and I love it)!
Thanks for reading!


Development Update #2 (03/19/2019)

After almost a month of messing about and brainstorming ideas, I threw together some prototypes of a user storage system. After trying out JSON (and eventually CSV when I got frustrated and wanted something more simple), it then dawned on me that as the database grows in size, so will my memory usage as the entire file would have to be loaded into memory. This is what lead me to land on SQLite for the database of choice as it is easier to setup, easier to make changes to the database and way easier to find data from it. What started as 20+ lines of code to write a simple entry to the file, turned into 20 for the entirety of basic database management. This with the added benefit of being able to make the file automatically without issues or hard coded formatting being needed made SQLite the perfect tool for the job.
Now that I am happy with the progress I've made on the user storage, I will finally be able to move forward integrating more advanced systems to the bot. The first step will be start work on a cooldown system for the bot, and I already have some good ideas on how I want to do this. Once that's done I can start adding games to the bot and storing currency. I will post another update when I make more progress, and hopefully have a working bot by the summer. Keep your eyes out for a development stream or two in the near future and maybe you can help me test it LIVE.
For a sneak peak at the progress back-end (albeit it's a small step looking on externally but a big one for me in my learning experience) you can see some photos on imgur.


Development Update #1 (02/20/2019)

The very basic chatbot has been added to the repository. It has twitch chat integration and very basic command responses. The plan is to integrate my !slots and !join commands from my StreamLabs Scripts, but in order to do that I need to lay a lot of groundwork. Some of the items I need are as follows:

  • User storage database
  • Cooldowns
  • Currency
  • User IDs
All these things are work in progress at the moment, but we have an idea on how we want to do this using the API and a JSON file. Updates will be posted here

To see more of my projects, visit my projects page.