ayust / kitnirc

Python IRC bot framework.
MIT License
11 stars 7 forks source link

password not working with znc #6

Closed ghost closed 10 years ago

ghost commented 10 years ago

I am having trouble connecting to znc. It seams the problem is znc does not like the \r\n in the password but this does not make sense. The following works but not in https://github.com/pdxacm/acmbot. BTW I changed the password. I don't know if this i a bug or not

derp()
{
echo -en "PASS password\r\n"
echo "NICK AcmBot"
echo "USER AcmBot AcmBot 127.0.0.1 :AcmBot"
echo "PRIVMSG #acm :Hello from a script"
echo "QUIT"
}

derp "$@" | openssl s_client -quiet -connect rita.cat.pdx.edu:1919 &> /dev/null
$ znc --version
ZNC 0.206+deb1 - http://znc.in
ayust commented 10 years ago

echo is already adding a newline; when you do echo -e "...\r\n" what you're actually sending is "...\r\n\n".

ghost commented 10 years ago

Thats script works. I thought the -n turns off that extra \n http://linux.die.net/man/1/echo

ayust commented 10 years ago

Oh, yeah, completely overlooked the -n.

As for debugging why it's not working for the bot - can you set the log level to DEBUG for your bot (which will give you a view of all network traffic back and forth) and see where it's actually bombing out and with what message, if any?

ghost commented 10 years ago
./bot.py -p 1919 rita.cat.pdx.edu --ssl --log DEBUG
INFO 2014-01-16 15:39:44,862 kitnirc.modular:0259 - Loaded the following modules: ['kitnirc.contrib.healthcheck', 'kitnirc.contrib.autojoin', 'kitnirc.contrib.admintools', 'modules.nickserv', 'modules.acmbot']
DEBUG 2014-01-16 15:39:44,863 kitnirc.modular:0133 - Controller is now listening for 'LINE' events
DEBUG 2014-01-16 15:39:44,863 kitnirc.modular:0133 - Controller is now listening for 'WELCOME' events
DEBUG 2014-01-16 15:39:44,863 kitnirc.modular:0133 - Controller is now listening for 'PRIVMSG' events
rita.cat.pdx.edu
DEBUG 2014-01-16 15:39:44,864 kitnirc.modular:0170 - Controller is dispatching 'STARTUP' event
INFO 2014-01-16 15:39:44,864 kitnirc.client:0250 - Connecting to rita.cat.pdx.edu as AcmBot ...
INFO 2014-01-16 15:39:44,866 kitnirc.contrib.healthcheck:0061 - Healthcheck running: delay=60 timeout=90
INFO 2014-01-16 15:39:44,986 kitnirc.client:0263 - Connected to rita.cat.pdx.edu.
DEBUG 2014-01-16 15:39:44,988 kitnirc.client:0212 - Dispatching event PASSWORD ()
INFO 2014-01-16 15:39:44,988 kitnirc.client:0270 - Sending server password.
DEBUG 2014-01-16 15:39:44,988 kitnirc.client:0212 - Dispatching event CONNECTED ()
INFO 2014-01-16 15:39:44,989 kitnirc.client:0323 - Requesting nick change to 'AcmBot'
DEBUG 2014-01-16 15:39:44,989 kitnirc.client:0318 - rita.cat.pdx.edu <-- NICK AcmBot
INFO 2014-01-16 15:39:44,989 kitnirc.client:0335 - Requesting user info update: username=('AcmBot',) realname=('AcmBot',)
DEBUG 2014-01-16 15:39:44,990 kitnirc.client:0318 - rita.cat.pdx.edu <-- USER ('AcmBot',) cbw-Inspiron-1520 rita.cat.pdx.edu :AcmBot
DEBUG 2014-01-16 15:39:45,105 kitnirc.client:0307 - rita.cat.pdx.edu --> :irc.znc.in 464 AcmBot :Invalid Password
ayust commented 10 years ago

Oh, one other thing to check... does the pattern you're using contain a ; character in it? If so the configuration parser might be treating that and the rest of the password after it as a comment... What happens if you provide the password via the command line flag (--password) instead?

ghost commented 10 years ago

No change. The password is [removed] if you want to test. @nightfly19 will be setting up a non ssl port 1920.

ayust commented 10 years ago

Hm. Very curious; I was able to replicate on my end.

ayust commented 10 years ago

I think the bug isn't actually with the password, but how it's sending the USER line. Investigating further...

ayust commented 10 years ago

Found the issue; there was an extra comma at the end of a line in the skeleton code. I've fixed it in the skeleton in e6bfdbc3a6de8f3061195ce90285deba9118682a but you'll need to make the same change in your own code.

ayust commented 10 years ago

To provide a little more detail - after some more staring and trying things, I noticed this line in your log:

DEBUG 2014-01-16 15:39:44,990 kitnirc.client:0318 - rita.cat.pdx.edu <-- USER ('AcmBot',) cbw-Inspiron-1520 rita.cat.pdx.edu :AcmBot

Notice how the line as sent isn't USER AcmBot ... but rather USER ('AcmBot',) ... - the extra comma was causing the username to be set as a tuple rather than a string.