Is there any way to access all of a channel’s chat from an external app? I’m thinking of making an app using the twitch api that would include having users cast votes via twitch chat.
There is two ways. Either embed the actual chat itself into your app or connect to the servers directly through IRC and print out the messages in your own custom chat window.
Just curious though on how you imagine your voting system would work. Polls are currently done through chat commands to a bot or a link to http://strawpoll.me/. But if it is done between app users then only those using your app would be able to participate.
So how does the bot get the commands from twitch chat? What if I wanted viewers to use a command similar to how they use bot commands…
The bot reads all messages sent in the channel, and if a message is in the form of a known command (matched by regular expression or string comparison) then it will act according to what it was programmed to do.
You could let you app do the same thing, listen to all messages through the IRC connection. But then another thing to consider is where the magic is going to happen. If you read these votes in every instance of a user’s app, then you face the problem of viewers joining in mid-voting, and not getting the right information.
This could be solved by having an actual bot running on an account 24/7, or whenever you need it to be available. This bot would gather votes in one place and correctly get the total, then send it to each client using your app through the internets.
This beckons the question if you need an app at all. What is your app providing that is much easier/better than sending a chat command like “!vote 6” and reading a total sent from a bot alone? I’m not trying to rain on your parade - these are just questions that I would ask myself in your position to see my vision more clearly.
Thanks for the info! Where can I learn how to listen to the chat via an irc connection (like you mention above)?
That depends on what programming language you are familiar/comfortable with. My goto suggestion for beginners is PircBotX for Java. After sucessfully setting up this in an enviroment (e.g. Eclipse) you can just replace some of the lines on the page with this:
Configuration configuration = new Configuration.Builder()
.setName("username") //the twitch username of your bot
.setServerHostname("irc.twitch.tv")
.setServerPort(6667)
.setServerPassword("oauth:xxx") //the ouath token for the same account
.addAutoJoinChannel("#somechannel") //the channel to connect to
.addListener(new MyListener())
.buildConfiguration();
Get the account’s oauth token here.
Edit: forgot for a second you were building an app, so PircBotX (or a library free solution) is what you need for an Android app. I am not familiar with iOS though.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.