I’m building a twitch bot mostly for fun but also in the hopes that I can use it at least for a decent period of time in my streams.
I’m using node.js and the awesome tmijs.org TMI module for the bot connection.
I’m trying to build a currency system and I have most of it in place, but what I really want to try to work through is someway of figuring out if someone is actively chatting or not. I don’t want people to just sit in my chat and say nothing and just rack up points. I want people to be actively chatting.
Since I know this isn’t a forum for one language I won’t post any code but if you want to see my current code you can find it here
The basic theory of what I’m trying to do is basically every say 5 minutes I check the current list of viewers in chat and compare that to the list of viewers from 5 minutes ago, and for each list I basically make a new list that only includes people that are in both lists. At this point I would loop over each and update my database for that person with the new number of minutes they’ve been watching and their new currency level.
It’s somewhere here I think I would need to somehow figure out if that person is an active chatter or not. I’m just not sure what the best way of doing that is.
My first thought is to for each chat message save that username and the timestamp of the chat message into an object and each time that person chats again update the timestamp to the new time, and then when the loop goes to add currency to that user it can look in the object for the users username and see if the timestamp from the last chat message is within say 10 minutes and if it’s not it will skip adding currency to that person.
My forethought is I worry about having to manage a large object for potentially hundreds of users one day and I’m not sure if my bot can handle that.
If anyone has any tips on even just a theory of how I might do this I would love to hear your thoughts.