IRC bot

Someone Something fordhaivat at gmail.com
Sun Sep 13 15:58:44 EDT 2009


I"m trying to write an IRC bot just for fun (in python of course). Here's my
current code:

  1 #!/usr/local/bin/python
  2 import time
  3 import socket
  4
  5 def message (x, channel,s):
  6     y="PRIVMSG"+" "+ channel+" :"+x
  7     s.send(y);
  8 host="irc.freenode.net";
  9 port=6667;
 10 size=1024;
 11 channel="#dhaivatrocks";
 12 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
 13 s.connect((host,port));
 14 s.send("NICK PoincareBot");
 15 s.send("USER  PoincareBot 8 *  : Paul Mutton");
 16 time.sleep(5);
 17 s.send("JOIN #dhaivatrocks");
 18 s.send(PRIVMSG #dhaivatrocks :Hello everybody!
 19 while True:
 20     pass;
 21
What I don't understand is that it doesn't display any messages or show a
new message login on my IRC client. What's wrong with my code?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090913/6623d1d5/attachment.html>


More information about the Python-list mailing list