Messages not appearing in chat if sent too quickly after a previous message

I’m creating an IRC bot using PHP (not that that should matter) and I’ve ran into an issue where sending messages with a short time between them will result in only the latest message being sent. (i.e. if I write “PRIVMSG #channel Hello” and then “PRIVMSG #channel world” with less than a second delay between them, only “world” will appear in the chat)

I created a temporary workaround, which is a queue system that sends each message at least 1.25 seconds after the previous one. But why can’t I send sequential messages quickly? Is this normal? I would think not, since I’m able to send messages quickly one after the other on Twitch’s website, and using a test with two browsers showed little delay between sending and receiving.

I have socket blocking turned off and use stream_select (with $tv_sec set to 0 and $tv_usec set to 200000) to detect activity in the socket. I do this because I have some commands that will send a message, wait a few seconds and then send another one. If stream blocking were turned on, the second message would only be sent once someone chatted, which isn’t what I was looking for. I doubt this would cause or influence this problem, but you never know.

EDIT: Here’s a snippet of PHP code I use when establishing a connection.

$this->context = stream_context_create(array(‘socket’ => array(‘bindto’ => ‘0:0’)));
$addr = ‘tcp://’ . $this->server . ‘:’ . (string)$this->port;
if($this->socket = stream_socket_client($addr, $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $this->context)){
stream_set_blocking($this->socket, 0);
…Login, join, pass, nick, etc.
}

Is the bot a mod? There is a spam protection for non-mods that prevents messages from being sent too quickly. You even get a NOTICE response saying “Your message was not sent because you are sending messages too quickly.”, although I think you need the twitch.tv/commands capability to receive that.

1 Like

Modding the bot did the trick. Thanks for the pointer.
Is there a way to check whether the bot is a mod or not using the IRC or Twitch protocols? That way I could trigger the delay workaround if for whatever reason the bot is not a mod.

EDIT: Never mind. I just discovered an API for checking mods.

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