From d380bf6b9d0ef9a491238427454033a71a80f4a7 Mon Sep 17 00:00:00 2001 From: Schnaubelt Date: Wed, 5 Dec 2012 06:37:07 -0800 Subject: [PATCH] Edited to work on python3.3. If you don't like it, blame psi --- nameless-bot.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/nameless-bot.py b/nameless-bot.py index aa56231..bc397b0 100644 --- a/nameless-bot.py +++ b/nameless-bot.py @@ -14,22 +14,22 @@ network = 'localhost' port = 6664 irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) irc.connect ( ( network, port ) ) -irc.send ( 'USER %s %s %s :Python IRC\r\n'%(botuser, botuser, botuser) ) -irc.send ( 'NICK %s\r\n'%(botnick) ) -irc.send ( 'JOIN %s\r\n'%(botchannel) ) -irc.send ( 'PRIVMSG %s :Hello World.\r\n'%(botchannel) ) +irc.send ( bytes('USER %s %s %s :Python IRC\r\n'%(botuser, botuser, botuser), "UTF-8") ) +irc.send ( bytes('NICK %s\r\n'%(botnick), "UTF-8") ) +irc.send ( bytes('JOIN %s\r\n'%(botchannel), "UTF-8") ) +irc.send ( bytes('PRIVMSG %s :Hello World.\r\n'%(botchannel), "UTF-8") ) def say(msg): - irc.send('PRIVMSG %s :%s%s'% (botchannel, msg, '\r\n')) + irc.send(bytes('PRIVMSG %s :%s%s'% (botchannel, msg, '\r\n'), "UTF-8")) while True: - data = irc.recv ( 4096 ).replace("\r\n", "") - print data + data = irc.recv ( 4096 ).decode("UTF-8").replace("\r\n", "") + print (data) #THIS IF BLOCK DEALS WITH PINGS if data.split()[0] == "PING": - irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' ) - print "PING SENT" + irc.send ( bytes('PONG ' + data.split() [ 1 ] + '\r\n', "UTF-8") ) + print ("PING SENT") #PUT EVERYTHING THE BOT IS TO RESPOND TO (IN PUBLIC OR PRIVATE) WITHIN THIS BLOCK if data.split()[1] == "PRIVMSG": @@ -49,7 +49,7 @@ while True: #PUT PRIVATE COMMANDS YOU WANT THE BOT TO RESPOND TO IN THIS BLOCK if msg_dest == botnick: if msg == "hi": - irc.send ( 'PRIVMSG %s :hi there %s!\r\n'%(src_nick, src_nick) ) + irc.send ( bytes('PRIVMSG %s :hi there %s!\r\n'%(src_nick, src_nick), "UTF-8") ) #PUT PUBLIC COMMANDS YOU WANT THE BOT TO RESPOND TO IN THIS BLOCK -- 2.11.4.GIT