Skip to content

Instantly share code, notes, and snippets.

@sweemeng
Created February 26, 2014 13:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sweemeng/9229713 to your computer and use it in GitHub Desktop.
Save sweemeng/9229713 to your computer and use it in GitHub Desktop.
Beginning of a IRC bot
#!/usr/bin/python
import socket
HOST="irc.freenode.net"
PORT=6667
BOTNAME="sweemengs_bot"
CHANNEL="#myoss"
class Bot(object):
def __init__(self, host, port, name, channel):
self.host = host
self.port = port
self.name = name
self.channel = channel
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.host, self.port))
self.sock.recv(4096)
self.sock.send("USER %s %s %s :%s\r\n" % (self.name, self.name, self.name, self.name))
self.sock.send("NICK %s\r\n" % self.name)
self.sock.send("JOIN %s\r\n"% self.channel)
def run(self):
self.sock.send("PRIVMSG %s : random shit\r\n" % self.channel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment