Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #imports
- from irc import *
- import csv
- import re
- #methods
- def find(string, store, type):
- for key in store:
- if (string == key or (string == key[0:len(string)])):
- #and type == "whois")):
- return store[key]
- # print store[string]
- if (type == "whois"):
- return "I don't recognize that name."
- # elif(type == "explain"):
- # return "I don't recognize that stunt."
- # print "Invalid search"
- #variables
- whois = re.compile('>whois (.*)$')
- #explain = re.compile('>explain (.*)$')
- channel = "#ddf"
- server = "irc.implyingrigged.org"
- nickname = "Miku"
- connected = False
- #lists
- characters = []
- #stunts = []
- #files
- with open('characters.csv', 'rb') as charFile:
- char = csv.reader(charFile)
- characters = map(tuple,char)
- characters = dict(characters)
- #with open('stunts.csv', 'rb') as stuntFile:
- # stunt = csv.reader(stuntFile)
- # stunts = map(tuple,stunt)
- # stunts = dict(stunts)
- irc = IRC()
- irc.connect(server, channel, nickname)
- while connected == False:
- irc.join(channel)
- text = irc.get_text()
- if "JOIN" in text and connected == False:
- connected = True
- print "Connected"
- else:
- while 1:
- text = irc.get_text()
- if (whois.search(text) != None):
- irc.send(channel,find(whois.search(text).group(1)[:-1],characters,"whois"))
- # elif (explain.search(text) != None):
- # irc.send(channel,find(explain.search(text).group(1)[:-1],stunts,"explain"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement