IRC Chatbot can see messages but can't PRIVMSG

Trying the most basic commands here, using the websockets, I’m doing:

    connection.send(`PASS oauth:<token>`)
    connection.send(`NICK almarcthesun`)
    connection.send("JOIN #channel")
    connection.send("PRIVMSG #channel :Hey!")

I successfully join, can see messages, but the PRIVMSG doesn’t do anything. Don’t get a 421 error either, so the command is recognized, but the message isn’t ever visible in the chat.

I have tried writing a message on those channels by hand and I can, indeed, do it, so it’s not an issue of follower-only or similar. Same issue with tmi.js.

websockets in what language? with what library?

What actuall is connection

Make sure the channel name is in all lowercase. I have seen this occur when joining #Channel instead of #channel - It was a while back and might be different now.

The language is Javascript, with the ‘ws’ library. Connection is

const connection = new WebSocket("ws://irc-ws.chat.twitch.tv:80");

Aye, I use lowercase. It works as far as receiving messages goes, but not sending them.

This suggests you are not logging all responses from the server.

And your bot doesn’t meet on of the criteria for being able to send a message.
Or your login token doesn’t have sufficent scopes applied to it.

Check your token has chat:edit - Scopes list Authentication | Twitch Developers or use validate endpoint: Authentication | Twitch Developers

Check that your code is logging/outputting any NOTICE or USERNOTICE payloads for error reports.

This could be your bot doesn’t follow the target channel, or the bot doesn’t meet the verification requirements for the target channel.

These can be “bypassed” by giving the account the moderator role in the target channel.

The token indeed has “chat:edit”.

The code is logging any messages that are thrown at it. I have tried “WHO something” and it returns a 421, as expected. On “PRIVMSG”, however, nothing at all is returned by the server.

The account has all the rights to write in the channel, I made sure of it. Also, my own channel I can surely write in, yet the messages still won’t appear.

Here’s my code, just in case:


const WebSocket = require('ws');
const connection = new WebSocket("ws://irc-ws.chat.twitch.tv:80");

connection.onopen = (event) => {
    console.log("Open")
    connection.send(`PASS oauth:<token>`)
    connection.send(`NICK gethrchat`)
    connection.send("JOIN #gethrchat")
    connection.send("PRIVMSG #gethrchat :Hey!")
}

connection.onmessage = (event) => {
    console.log(event.data)
}

Channel names are all lower case

So always gethrchat

Your nick is technically wrong,
you joined a room that technically doesn’t exist
And you sent to a room that doesn’t exist.

The browser will join gethrchat and send to the lowercase/user logim version

Whoop, sorry about that. I quickly edited the channels and forgot to change the names to lowercase.

Yes, indeed all three of them are in lowercase in my actual code. Same results. Can see messages in chat, but can’t send them.

Hey, so I tried tmi.js again and this issue persists. Tried turning on two-factor authentication and changing account.

When I send a message through tmi.js, I can see it in the log of the library, but the message isn’t actually visible in the chat. Happens in every chat, although I made sure to join ones that aren’t follower-only and are free for everyone.

I have nothing obvious left to suggest.

Since you have tested this in your own channel it should work.
And you claim you are getting no NOTICE/USERTNOTICE/errors

I don’t use TMI.js so the next step is to seek help from the library maintainers.

Or try plugging your user token + username into this chat example

Potenitally add a line at 201 of console.log(payload); to log everything that is sent to your process and see whats what.

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