Created
October 14, 2014 14:08
-
-
Save arthurbarros/57dbad81aa238700b9bf to your computer and use it in GitHub Desktop.
Robot Pong
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import socket | |
import string | |
HOST="irc.freenode.net" | |
PORT=6667 | |
NICK="SuperAwesomeNickForARobot" | |
IDENT="thatawesomenick" | |
REALNAME="AwesomeRobot" | |
CHANNEL = "#MyAwesomeRobotChannel" | |
readbuffer="" | |
s=socket.socket( ) | |
s.connect((HOST, PORT)) | |
s.send("NICK %s\r\n" % NICK) | |
s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME)) | |
s.send("JOIN %s\r\n"% CHANNEL) | |
while 1: | |
readbuffer=readbuffer+s.recv(1024) | |
temp=string.split(readbuffer, "\n") | |
readbuffer=temp.pop( ) | |
for line in temp: | |
line=string.rstrip(line) | |
line=string.split(line) | |
l = " ".join(line) | |
if "PING" in l: | |
s.send("PONG \r\n") | |
s.send("PRIVMSG #whatthebot :") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment