webdevRefinery Forum: Python + IRC - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

User is online Mo3 

  • Awesomeness on Rails
  • Group: Moderators
  • Posts: 1957
  • Joined: 21-July 10
  • LocationBavaria
  • Expertise:PHP,Java,Javascript,Python,Ruby on Rails,Node.js

Posted 28 April 2011 - 10:46 AM (#1)

Python + IRC


I'm working on my Python IRC bot framework. This is killing me:

:irc.webdevrefinery.com 477 Megan #webdevrefinery :You need to be identified to a registered account to join this channel

:NickServ!NickServ@services.localhost.net NOTICE Megan :Insufficient parameters for REGISTER.
:NickServ!NickServ@services.localhost.net NOTICE Megan :Syntax: REGISTER <password> <email>

:irc.webdevrefinery.com 461 Megan PRIVMSG :Not enough parameters.
:irc.webdevrefinery.com 304 Megan :SYNTAX PRIVMSG <target>{,<target>} <message>


Code:

        s=socket.socket()
        s.connect((self._server, self._port))
        if s:
            OrangeBot.log(self, 1,'Connected to '+server)
            s.send(b'NICK '+bytes(self._nick, 'UTF-8')+b'\n')
            s.send(b'USER '+bytes(self._ident, 'UTF-8')+b' '+bytes(self._server, 'UTF-8')+b' bla :'+bytes(self._realname, 'UTF-8')+b'\n')
            s.send(b'PRIVMSG NickServ REGISTER '+bytes(password, "utf8")+b' my@email.com')
            s.send(b'PRIVMSG NickServ IDENTIFY '+bytes(password, "utf8")+b'\n')

Ruby on Rails | Python | PHP
What is necessary to change a person is to change his awareness of himself.
0


User is offline Ruku 

  • I do Linux and that Internet thing.
  • Group: Members
  • Posts: 1367
  • Joined: 17-April 10
  • Location/root
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL

Posted 28 April 2011 - 11:01 AM (#2)

I honestly couldn't see anything wrong with that code (though IRC is not my forte), other than the potential for password to be blank? I'd suggest logging everything being passed to the socket's send() method and anything returned via socket.recv(), maybe at the debug level of the logger module? It's saved me a lot of headaches so far, believe me D:
Luke Carrier
I poke fun at IE and do web stuff. Find me on my blog, my code on GitHub or my angry rants on Twitter.
0


User is offline AwesomezGuy 

  • Certified Assholeâ„¢
  • Group: Members
  • Posts: 1251
  • Joined: 08-March 10
  • LocationIreland
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 28 April 2011 - 11:49 AM (#3)

There should be a : before the message you're sending when you use the PRIVMSG command:

s.send(b'PRIVMSG NickServ REGISTER '+bytes(password, "utf8")+b' my@email.com')
s.send(b'PRIVMSG NickServ IDENTIFY '+bytes(password, "utf8")+b'\n')


Should be:

s.send(b'PRIVMSG NickServ :REGISTER '+bytes(password, "utf8")+b' my@email.com')
s.send(b'PRIVMSG NickServ :IDENTIFY '+bytes(password, "utf8")+b'\n')

2


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services