简体   繁体   中英

Connecting to Twitch using my C++ irc bot

I have some problems connecting my bot to irc.twitch.tv. Connecting to irc.ubuntu.com is no problem tho..

When connecting to ubuntu I just send nick and then usr. With twitch I am sending pass, nick and then usr.
I am really confused why this isn't working at all. Usually I think twitch should tell me anything but after my bot tells me that no special errors occur there is just no message at all. So I think the problem is within the connection not with me being unable to send a valid pass before usr and nick.
Because my code is a little longer I am posting it on pastebin I hope you can understand and analyse it:

http://pastebin.com/Win3CXbP

PS:  - My oauth PW should be correct it is not the string in the sample code.
     - I have the pw/usr/nick in the right order, nick/usr is wrong in code.
     - I want to say again, that I don't get any message from twitch or any errors.

PPS:  - I just tried using wireshark and when filtering for "irc" I got some data 
        with irc.ubuntu.com, but none with irc.twitch.tv. 
        Is the twitch adress wrong?
PPPS: - I am not completely into wireshark yet, but the only messages I am getting 
        on tcp port 6667 are 
                            "connection establish request"       
        and                 "connection establish acknowledge"

According to the protocol document the client connection protocol order is:

PASS

NICK

USER

Whereas your bot seems to be sending pass , user , nick .

3.1 Connection Registration

The commands described here are used to register a connection with an IRC server as a user as well as to correctly disconnect.

A "PASS" command is not required for a client connection to be
registered, but it MUST precede the latter of the NICK/USER
combination (for a user connection) or the SERVICE command (for a
service connection). The RECOMMENDED order for a client to register
is as follows:

  1. Pass message 2. Nick message 2. Service message 3. User message 

Upon success, the client will receive an RPL_WELCOME (for users) or RPL_YOURESERVICE (for services) message indicating that the
connection is now registered and known the to the entire IRC network. The reply message MUST contain the full client identifier upon which
it was registered.

EDIT:

Also, even though the protocol suggests the PASS is optional, some servers expect a password even if one is not required to connect to the network. Sending a blank PASS is not enough. For those servers I send PASS none . (anything will do as long as the password is not empty).

Twitch requires an OAuth token be used as the password. See here http://help.twitch.tv/customer/portal/articles/1302780-twitch-irc

The answer to this is pretty simple. I just found it out by just playing around with it. It seems to be a problem in my little code, that I am not instantly sending my data to the server. So when I changed the "switch 3:" to "switch: 1" everything was working suddenly.

Still ty for all your help guys!

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