Bot can't send messages to other channel

Can anyone help / explain me what I did wrong or what I didn’t yet to make my bot working? It is my first bot.

I generated OAuth token using this site for account “A”:
https://twitchapps.com/tmi/

I ran the example bot.js on my server:
https://dev.twitch.tv/docs/irc

The bot joined to the channel “A” and also to other channel “B”. So when I type !dice in channel “A” the bot can response and message is visible. But then I type !dice in channel “B” a message the bot sent is not visible.

Bot can listen for messages, but can send only to the channel which is the account that I used to generate OAuth token.

Is channel B set to followers/sub only mode, without your bot being a mod? That would prevent it from being able to send messages to that channel.

I didn’t set anything more. So what you suggest? I want to add possibility to send messages to any channel on which a streamer enables the bot in an extension configuration panel (I imagine this in that way: when streamer enables the bot, this makes a http request to my server and then the bot joins to the streamer’s channel).

“Followers-only mode” option is set to off in account B. also account A wasn’t be added as moderator in channel B.

I checked. After adding account A as moderator in channel B the bot can send messages. Is this the only way to do this when the bot goes live? Does every streamer have to add an A account as a moderator for the bot to work on his channel?

Turn on “raw logging” and/or check for NOTICE messages that will provide any error messages.

No read the error messages and see what the problem is.

Since this is an extension you might be interested in

Instead

I enabled logs. When the bot sends message “in response” following log occurs:
Your message was not sent because you are sending messages too quickly.
It only one message since few minutes, so how it can be sent too quickly? Should I wait for some fixed time (e.g. 3 seconds ) with the response?

Off hand I don’t know what the “rule” is for sending too quickly, and it’s not documented, 3/5 seconds sounds about right.

You’ll also not be able to send the exact same message for 30 seconds. Being a mod bypasses the “spam prevention” rules such as these two.

Error Messages/NOTICE’s will advise you of any other errors/problems you run into

It works, I just wait 1 second with the response and message is visible on the channel even without moderator status. @BarryCarlyon you helped me with this logging :slight_smile:

Also I can’t use the “Extension Chat Message” because I need to send messages from another account than the extension. Also I need to listen users’ messages, because I want to send messages only after there are at least 5 or more other lines of text, I don’t want to spam.

I would be grateful if you can answer more questions:

  1. So since it works, why should I register the bot as an application and also send to verification? May I use it in form as it is now? May I keep the generated OAuth token forever?
  2. I don’t understand exactly what are limits. I read the limits here: https://dev.twitch.tv/docs/irc/guide#command--message-limits
    a) “20 authenticate attempts per 10 seconds per user” - when I execute client.connect(); with tmi.js is it just only one authentication attempt?
    b) “20 join attempts per 10 seconds per user” - Is my bot treated as a user? I mean when I execute client.join(channel) the rest of the limit is 19? So in case when I need to join to 1000 channels, should I spread these joins in time to not exceed 20 per 10 second per my bot?
    c) “20 per 30 seconds Users sending commands or messages to channels in which they do not have Moderator or Operator status” - so after my bot joined to mentioned 1000 channels, and want to send message to each one for every 5 minutes, does it exhaust the limit because it is set per bot or does it not exhaust because it is set per channel?

An Extension is also an application you don’t need a seperate set of keys

oAuth tokens expire, but you’ll be able to use the refresh token to generate a new token.

A bot’s token is only checked at login, so it only needs to be valid at “bot start/connect”

If you have a bad password, bots will generally auto reconnect.

I cannot speak to the specifics of tmi.js as I don’t use tmi.js

Yes

Correct

I believe it’s per channel yeah.

Generally speaking it’s difficult to hit the limits unless you are actually trying to spam

Can use a justinfan/anon login to monitor/count messages if needed, but I’d just send a message every 5 minutes (or whatever time period) regardles of chat lines, to account for new people joining the stream.

Then how do they know the messaging you are sending is related to the extension? If you are using a different name! Using the Extension chat also gives you access to the target channel subscriber emotes without having to “sub the bot” to the channel

Do you mean I should use the bot (even as an anonymous account) for listening messages and the “Extension Chat Message” for sending?

Yes that is a possible solution if you intend to space out messaging based on “message count in chat”

Hmm but in case I decide to send messages using original account “A” where the extension is registered but with the bot - not extension chat messages, I should register new bot app, right?

No, as an Extension is an application, you don’t need a seperate application.

A bot will login to chat using an oAuth key generated via a key set. That key set can be an “Extension key set”.

When a “user” logs into chat using an oAuth token, it’ll use the username that belongs to the oAuth token, not the “name” of the extension.

You don’t need two clientID’s

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