mitchellharrison / python-twitch-chatbot Goto Github PK
View Code? Open in Web Editor NEWA custom, 100% Python Twitch Chatbot that stores chat/viewership data in a PostgreSQL database.
Home Page: https://twitch.tv/MitchsWorkshop
A custom, 100% Python Twitch Chatbot that stores chat/viewership data in a PostgreSQL database.
Home Page: https://twitch.tv/MitchsWorkshop
The !uptime
command is currently not functioning. The likely cause is incorrect SQL syntax. The command is not designed to give the stream's, but the bot's uptime. The logic looks sound, but there may be some syntax issues that could be quick to fix.
The following steps point me in the direction of the database as the culprit responsible for the bot being slow to respond to some commands as listed in issue #22. Printing every message to console confirmed that every message is being received without fail, and the !joke and !poem commands that rely on external API's work as intended. That tells me that the database itself is the issue. Messages are being logged fine, but the commands that pull from the database cause issues.
I'm hoping that switching from SQLite to Postgres will help with database performance enough to make the bot as responsive with database commands as the !poem and !joke commands are.
similar to the !rank command, but gives the top X users regardless of who used the !leaderboard command
Both the Streamelements bot that I used before and this bot are slow to respond if multiple commands are used in quick succession. I thought this was an issue with Twitch or IRC since the larger commercial products have the same issue. But some chatters have demonstrated their bots working much faster. Some kind of concurrency might be the issue. I'm looking into the following concurrency options:
A primer on the subject is found here. If anyone has different ideas to improve performance, comments are welcome as ever!
As a User, it might be awesome if typing something like.... !featurerequest add a featurerequest command that allows a user to define a new github issue with the feature request label on the chat bot project
This should be build in commands.py with logic to tag the user in the reply message.
If we store based on ID, we can correct for changing usernames and we can just relate another table with the user ID columns that will contain up to date names as they change. That table can also contain subscriber status and other user-specific stats.
The bot should be able to see permission levels, and whisper mods with the commands available to them
Baked in follow and subscription notifications, rather than relying on a 3rd party solution, like streamlabs or streamelements
Currently, if the bot has been up for under a minute, the bot prints an incomplete sentence. It should check if it has been running for under a minute, and if so, send something like "I just woke up, give me a minute!" or the like.
The script should, while the stream is live, get the following information from Twitch:
As well as the current time. The script should stop when the stream goes offline
!alias !so !shoutout
would map the output of !so
to !shoutout
. Mods should be able to perform.
Once !rank
is implemented, it would be great to give users the ability to get their rank for a specific command (i.e. !rank !discord
). This should be agnostic to the use of the second exclamation mark. So !rank discord
and !rank !discord
should function identically.
I broke it. I need to fix it. Issue is currently on WSL only.
As a developer,
I want the ability to locally stand-up the chat-bot component easily,
So that I can quickly have a working development environment .
At the first startup, the followers table should be backfilled with existing followers. This will take some time, so there should be a check to see if the length matches total follower count. If not, delete the table and recreate. This should be helpful for getting total follower count.
"WaNnA bEcOmE fAmOuS?!!?"
Regex hurts.
Some commands should be useable by admins. We will have to pull mod status from each message. They could be stored alongside each message in booleans like is_mod in the chat_messages table. Then we could pass that mod status to each execute() method and run certain commands or not based on that status.
It should check the total number of followers, and if that's not the same as the follower count in the DB, get the missing ones here.
Several scripts are going to need access to several tokens that need to change in real-time in case they are revoked. So we are going to store them in our database for now. There should be a module to interface with this token store with methods to refresh tokens from anywhere in the environment.
As a user, I should be able to type !rank
and get my overall chat rank from the bot. It might also be fun to include sub ranks such as... !rank discord
to see where I as a user rank in executing the !discord
command.
A sample environment fiel would be useful, with all the requires key's with dummy values for ease of use
Twitch IRC sends emote tags with every message by emote ID. If we store these in a table, we can reference the id for emote analysis later. The internet says the legacy endpoint for getting all emotes should still work. It's reference is here. It also includes links to images as well, which is a lot of data but we can get those later if we need them.
an important feature for a lot of streamers is a ShoutOut command, it should be limited use, a user can't !so themselves but the streamer should define what level of user can use it - all - vip - mod
app.py
successfully creates EventSub subscriptions. The app prints them to the terminal and all of the desired ones are shown. But after the webhooks are established, no notifications appear. No clue on this one so I'm tagging it as "help wanted," but I'll do some digging and see what I find.
Current subscriptions:
All show as established and authenticated, but ngrok doesn't even get a PUT request from Twitch after the initial creation of the webhook (even though it does during creation and authentication).
Admin
User/text
The chat bot should be fine without a refresh token, so if app.py is never run, there should be some error handling to correct for lack of refresh token. This will probably have to happen in the environment.py file.
After a discussion with the discord server, I'm going to attempt to stick with SQLite for ease of end use. But writing queries as strings is for the birds, so I am going to implement SQLalchemy using a separate models.py
file and maybe a database.py
file as well.
I'd like to implement emote tracking into the bot. For both streamer-specific and twitch-wide emotes. This should be stored in a database table, but I'm unsure how to do it. Options are:
chat_messages
table to list which emotes were used per message.The former seems like I would be losing some granularity as far as who is using the emotes and which streams see the most emote use. But I'm unclear on the implementation of the latter. I would have to pass something like a list into a single column and that would make future analysis much more difficult and slower.
If anyone has insights, feel free to drop them!
Right now, the default postgres username is being used with a password of "password". A user should be able to put their postgres username and password into the credentials file to be read automatically at runtime.
Currently, if a user wants to see the follow age of another user, they have to use the "!followage <username>" command. If they try to include a tag for that user (i.e. "@<username>"), the bot doesn't find them.
Thanks bug hunters WorthieGG and GanaXE
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.