Skip to content

Instantly share code, notes, and snippets.

@jrabbit
Forked from anonymous/pythonirc
Created December 24, 2011 10:59
Show Gist options
  • Save jrabbit/1517124 to your computer and use it in GitHub Desktop.
Save jrabbit/1517124 to your computer and use it in GitHub Desktop.
Python irc
#nibbler.py
import sys
import socket
import string
class connection (object):
__init__(self):
self.network = "irc.freenode.net"
self.port = 6667
self.irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.irc.connect((self.network, self.port))
def send(self, msg):
self.irc.send(b"%s\r\n" % msg)
my_connection = connection()
my_connection.send("NICK")
my_connection.send("USER nibbl3r nibbl3r nibbl3r")
my_connection.send("JOIN #tofaffy")
my_connection.send("PRIVMSG #tofaffy :Hello.")
while True:
data = my_connection.irc.recv(4096)
if data.find(b"PING"):
send("PONG " + data.split()[1])
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment