Sunday, 3 March 2019

Am I on the right track? Twitch chat -> nodejs -> attached display

I'm new to nodejs and javascript but I have programmed a lot in the past - it's been a good 7 years+ since I did anything remotely difficult. Most of my professional life, while having a Comp Sci degree, has been spent in scripting and testing, and I've been out of work since 2014. So I'm rusty AF.​Working with a couple of others to make a gift for a streamer. This is going to be a physical device running on a Pi Zero W with a tiny tiny display and speaker attached. Someone else has already gotten those working. I'm trying to do the code. I'm currently using the tmi.js API [1] and that appears to be working - I can connect and read chat commands and output to chat or console various responses using a switch statement.​However, the goal is for certain chat commands will cause one of the following on the Pi, NOT in chat:Play a gif - most common use we believePlay a soundDo both of the above simultaneously - if we can get it working, this is most likely use.Play a short video - this is really iffy, but we'll tryScroll text​So I've read and played with some tutorials around taking requested URLs and fetching pages, etc. I've played a tiny bit with eventemitters. But I'm struggling with picturing how I want to go about putting it all together. I think what I could do is create an eventemitter and listen for each type of message ('gif', 'audio', etc) along with a filename and maybe send that to the browser? But then how does the browser know to go to the next item... And how should I add timeouts to prevent a single command from being wrecked, or a single user from abusing commands - I'm thinking a Map for each with possibly a timestamp of either last known success, or next valid timestamp, and just comparing when it's called again? I haven't played with Maps/Sets yet but if I'm reading things right I think that may be what I want.​IDK, kind of grasping at straws here and tinkering with all sorts of things (os, fs, url, uuid, winston and just about anything I can - kind of fascinated by nodejs right now). Open to ideas on how you would do this. Thanks for any ideas or assistance.​[1] - tmi.js

Submitted March 03, 2019 at 02:21PM by werelock

No comments:

Post a Comment