Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- readbuffer=""
- import sys
- import socket
- import string
- import random
- nickfile = False
- def nickgen():
- if nickfile:
- nicks = open(nickfile).read().split("\n")
- nick = nicks[random.randint(0,len(nicks)-1)]
- else:
- chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
- nick = ""
- for i in range(0,7):
- nick = nick + chars[random.randint(0,len(chars)-1)]
- return nick
- ## SETTINGS ##
- HOST="irc.esper.net"
- PORT=6667
- COMMANDER="thefinn93"
- NICK=nickgen()
- IDENT=NICK
- REALNAME="durrrpp"
- CHANNELS=[]
- ## This code is run every time a message is received. Use send(message) to send a message. Pings are handled lower down ##
- def process(incoming):
- print "<" + incoming
- try:
- line=incoming.split(":")[1].split(" ")
- if line[1] == "PRIVMSG": # Private message
- user = line[0].split('!')[0].split(':')[0]
- message = incoming.split(':',2)[2]
- if message == "\01VERSION\01": # Version
- print "<" + user + " wants to know what version we are"
- send("PRIVMSG " + user + " :__________\r\n")
- send("PRIVMSG " + user + " :< the game >\r\n")
- send("PRIVMSG " + user + " : ----------\r\n")
- send("PRIVMSG " + user + " : \\ ^__^\r\n")
- send("PRIVMSG " + user + " : \\ (oo)\\_______\r\n")
- send("PRIVMSG " + user + " : (__)\\ )\\/\\\r\n")
- send("PRIVMSG " + user + " : ||----w |\r\n")
- send("PRIVMSG " + user + " : || ||\r\n")
- else:
- if user == COMMANDER:
- print "Commander sez:" + message
- send(message + "\r\n")
- else:
- print "<" + user + ": " + message
- send("PRIVMSG " + user + " :\02" + message + "\02 to you to!\r\n")
- except:
- print "What the shit just happened??"
- ## End ##
- s=socket.socket( )
- # nickfile = "/home/finn/Dropbox/projects/irc/usernames.txt"
- def send(msg):
- print ">" + msg
- s.send(msg)
- def login():
- s.send("PRIVMSG thefinn93 :checkin\r\n")
- s.connect((HOST, PORT))
- send("NICK %s\r\n" % NICK)
- send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
- for channel in CHANNELS:
- 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)
- process(line)
- if(string.split(line)[0]=="PING"):
- send("PONG %s\r\n" % string.split(line)[1])
- elif line.split(" ")[1] == "MODE":
- send("PRIVMSG " + COMMANDER + " :Hello\r\n")
- login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement