简体   繁体   中英

Trying to auth IRC bot to irc.twitch.tv (C++)

So I'm trying to make an IRC bot that can connect to the Twitch.tv IRC servers using C++. So far, I've managed to get this bot to connect to IRC servers that don't require any sort of password, but I'm getting tripped up at the part where I need the bot to provide a password. So what I've currently got is:

(Connecting to the server)

send(cSock, "USER custom 0 0 <bot_name>\r\n", strlen("USER custom 0 0 <bot_name>\r\n"), NULL);
send(cSock, "PASS <twitch_oauth_token>\r\n", strlen("PASS <twitch_oauth_token>\r\n"), NULL);
send(cSock, "NICK <bot_name>\r\n", strlen("NICK <name>\r\n"), NULL);

(Joining a channel)

send(cSock, "JOIN #<channel_name>\r\n", strlen("JOIN #<channel_name>\r\n"), NULL);
send(cSock, "PRIVMSG #<channel_name> :Message\r\n", strlen("PRIVMSG #<channel_name> :Message\r\n"), NULL);

The bot will say a message upon joining a channel. I've tested this bot without the line containing PASS to connect to irc.quakenet.org without needing to provide authentication information, but I want to be able to have the bot provide authentication information to irc.twitch.tv so that I can use it on a registered account there.

What am I doing wrong?

Update: Never mind...I figured out what I did wrong. Apparently I had to send the PASS before I sent the USER or NICK. Everything seems to be working alright at this point.

Thanks for all your help anyway.

What are you doing wrong?

Presumably, the server is telling you. Did you look at the conversation it's having with your bot? I'm assuming no, since you didn't paste it here.

Get a log of the conversation. Either have the bot print it out, or use a network packet sniffer such as tcpdump or Wireshark .

You must send the oauth password before you send the user. [edit] saw where you updated[/edit]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM