Create a gist now

Instantly share code, notes, and snippets.

@j-arvin95 /irc_basic.py Secret
Last active Apr 18, 2017

What would you like to do?
import socket
nickname = "hammer_bot"
username = "hammer_bot"
realname = "hammer_bot"
server = "chat.freenode.net"
port = 6667
connect_to = (server, port)
freenode = socket.socket()
freenode.connect(connect_to)
# didn't put a space between NICK and nickname...
freenode.send(("NICK " + nickname + "\r\n").encode())
freenode.send(("USER " + username + " 0 * :" + realname + "\r\n").encode())
buffer = ""
while True:
buffer += freenode.recv(8192).decode()
temp = buffer.split("\r\n", 1)
if len(temp) >= 2:
line = temp[0]
buffer = temp[1]
print(line)
line = line.split(" ")
#print("line after line.split()" + str(line))
if line[0] == "PING":
freenode.send(("PONG " + line[1] + "\r\n").encode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment