Unity/Twitch Bot Whispering Help

I’ve trawled the forums, the Discord and what feels like the whole of Google trying to find an answer to this conundrum and I’m stumped. I’m aware there are similar issues in the forum but they are either not solving the issue or seemingly outdated. I’ll try to summarise the problem briefly.

  • I’m working on a “Twitch-Plays” social deduction game in Unity. I’ve previously made Twitch-Interactive games in Unity without a problem. The difference here is that certain players will need “secret” information (i.e. information hidden from other players) so I’m having to implement a system whereby the bot can whisper to certain individuals, giving them information that is hidden from other players. The maximum number of whispers per game will be 9 (and a game can last anything from 15 to 30 minutes).

  • I was originally generating an oauth token from twitchapps/tmi, but I had it pointed out to me that that doesn’t support whispering other users. I found an alternative website (https://twitchtokengenerator.com) which looks like it does. However, it’s having difficulties.

  • I have two Twitch accounts; the first is my real account which I use to stream the games and chat with people. The second is a “bot” account, which is used to receive whispers and type public information into the chat. This is also the account I would like to be able to whisper.

  • I’ve tried two different strategies to make whispers work:

  1. Creating an oauth token for my actual account (royal_flush).
  2. Creating an oauth token for my “bot” account (persephones_twitch_bot)
  • In the former, whispers work “sometimes”. It’s a bit inconsistent and I’m getting a variety of reactions in the console, ranging from not delivering whispers to myself (“unable to whisper to yourself”), nothing at all appearing in the console (and no whisper being delivered) and occasionally, whispers being delivered successfully. It’s slightly academic since I don’t want this account to be the account that is whispered to; the idea is that the “host player” should also be able to partake in the game. With this system, that’s impossible.

  • In the latter, whispers are returned with a console message saying “your settings don’t allow for this whisper to be delivered”. This despite the fact I flagged the “whisper:edit” box as yes on the oauth generator.

  • I feel all the pieces are sort of there but something is amiss. Why would my actual account allow whispers but not the bot account? My only theory is that something is amiss in my connection method (shown below).

  • I have tried to have the bot account verified as a “known-bot”, but the application was rejected. Moreover, I don’t feel that for at most 9 whispers per half hour every once in a while when I stream is really sufficient grounds for becoming a “known-bot”. This is a really frustrating issue and if anybody can help out at all, I’d be really grateful. Happy to do a screenshare/voice chat showing my code if anybody is willing. Many thanks.

private void Connect()
twitchClient = new TcpClient(“irc.chat.twitch.tv”, 6667);
reader = new StreamReader(twitchClient.GetStream());
writer = new StreamWriter(twitchClient.GetStream());

    writer.WriteLine("PASS " + persAccessToken);
    writer.WriteLine("NICK " + username);
    writer.WriteLine("USER " + username + " 8 * :" + username);
    writer.WriteLine("JOIN #" + channelName);
    writer.WriteLine("CAP REQ :twitch.tv/commands");
    writer.WriteLine(":persephones_twitch_bot!persephones_twitch_bot@persephones_twitch_bot.tmi.twitch.tv PRIVMSG #royal_flush :/w royal_flush Online. Let's Play.");

Make your own oAuth loop, don’t rely on others, as when your token dies, you have to manually go around the loop, as you can’t refresh tokens automatically when generated on someone elses oAuth loop

Avoid whispers all together, you need a Twitch Extension of off site website instead.

As you can tell you are having problems sending “unsolicited” whispers, theres a few tricks to “fixing” this, but whispers are not a reliable way for bots to send messages to users. You get screwed, by looking like spam (sending a message which looks 80% or so similar to the last messages, and sending whispers to people where the bot initiated the conversation).

Disclaimer: these are things I think help you get a bad spam score but I don’t know it’s a black box.

This might be fixed by the user whispering the bot first to “opt in”, or becoming friends with the bot, but there is no APIs for friend management, and these don’t help all the time

That error is the “you got spam blocked” error essentially

It has a good history of non unique messages? (see disclaimer above)

Long story short: it’s NOT a code problem, it’s a “bad usage of whispers” problem, caused by the spammers/hackers etc “ruining” the whisper platform for us.

TLDR use an extension instead. That’ll let you use pretty graphics and stuff too, FAQ about the game, interactive scores, more than use your “secret whisper” data, user profile/history etc.

Thanks for the feedback Barry. I had tried to get around the initiating the whisper by making it so you can only enter the game by whispering the bot in the first place, but maybe the damage is done and my spam score is not practically recoverable. I’m not a particularly brilliant coder, so making an extension seems like a daunting challenge (though it might be fun). In the interim, I’ll probably have to settle for “the host” cannot play; but I’ll probably go down the “use a build” route and just hide the stream when the information is displayed. At least that way multiple players could run the build and we just alternate who can play.

Thanks again for the feedback :slight_smile:

Essentially an Extension is just a website.

So you just need to make a display and some buttons.

And update said display with Javascript
And make the buttons do stuff (again with JS)

The hard bit here is you need a relay server that your Extension and your Unity game talk’s to.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.