0

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.

2 Answers2

0

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.

aib
  • 45,516
  • 10
  • 73
  • 79
  • I have no idea what I'm looking for in the [log](http://www.mediafire.com/download/xbleuft99p0e1uj/log.pcapng) but here it is anyway. – user2994384 Nov 15 '13 at 01:52
  • @user2994384: Err, that looks to be a lot more than just the IRC conversation. Are you sure you want to make that public? – aib Nov 15 '13 at 02:00
  • I don't really know what that log means. It took it down just to be safe. Is there any other way to use Wireshark just to log the IRC bot? – user2994384 Nov 15 '13 at 02:06
  • It's your whole network traffic. Very unsafe to share. This is no place for a Wireshark tutorial, but try using "tcp.port eq 6667" as a filter. The quickest way to see a conversation is to right click a packet and do "Follow TCP conversation". But make sure Wireshark captures the correct part, bot login in this case. (Start capturing before running the bot.) – aib Nov 15 '13 at 02:15
  • Yeah, I realize now that posting my whole network traffic is a bad idea...anyway, I seem to have sorted it out. Thanks for the help anyway! – user2994384 Nov 15 '13 at 02:17
  • Well, good. There doesn't seem to be any sensitive data in the log, by the way, but I didn't go through it thoroughly so don't take my word for it. You should be fine as long as you didn't log in to any new web sites (or made credit card purcases :) over an insecure connection. I would logout and re-login to any service running during the capture to refresh the authentication tokens, but probably not bother changing my passwords. Go over that log sometime - it's a great insight into how things work. Good luck! – aib Nov 15 '13 at 02:49
0

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

Ph33rless
  • 1
  • 1