Advertisement
Doogie_

Untitled

Sep 11th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #imports
  2. from irc import *
  3. import csv
  4. import re
  5.  
  6. #methods
  7. def find(string, store, type):
  8. for key in store:
  9. if (string == key or (string == key[0:len(string)])):
  10. #and type == "whois")):
  11. return store[key]
  12. # print store[string]
  13. if (type == "whois"):
  14. return "I don't recognize that name."
  15. # elif(type == "explain"):
  16. # return "I don't recognize that stunt."
  17. # print "Invalid search"
  18.  
  19. #variables
  20. whois = re.compile('>whois (.*)$')
  21. #explain = re.compile('>explain (.*)$')
  22. channel = "#ddf"
  23. server = "irc.implyingrigged.org"
  24. nickname = "Miku"
  25. connected = False
  26.  
  27. #lists
  28. characters = []
  29. #stunts = []
  30.  
  31. #files
  32. with open('characters.csv', 'rb') as charFile:
  33. char = csv.reader(charFile)
  34. characters = map(tuple,char)
  35. characters = dict(characters)
  36.  
  37. #with open('stunts.csv', 'rb') as stuntFile:
  38. # stunt = csv.reader(stuntFile)
  39. # stunts = map(tuple,stunt)
  40. # stunts = dict(stunts)
  41.  
  42. irc = IRC()
  43. irc.connect(server, channel, nickname)
  44.  
  45. while connected == False:
  46. irc.join(channel)
  47. text = irc.get_text()
  48. if "JOIN" in text and connected == False:
  49. connected = True
  50. print "Connected"
  51.  
  52. else:
  53. while 1:
  54. text = irc.get_text()
  55.  
  56. if (whois.search(text) != None):
  57. irc.send(channel,find(whois.search(text).group(1)[:-1],characters,"whois"))
  58.  
  59. # elif (explain.search(text) != None):
  60. # irc.send(channel,find(explain.search(text).group(1)[:-1],stunts,"explain"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement