Advertisement
Guest User

Untitled

a guest
Sep 29th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 KB | None | 0 0
  1. import socket
  2. import time
  3.  
  4. HOST = "chat1.ustream.tv" # Server to connect to
  5. HOME_CHANNEL = "#cooldude13233" # The home channel for your bot
  6. NICK = "cooldude13233-1" # Your bots nick
  7. USER1 = "lawlfgt" # Ident 1
  8. USER2 = "xD" # Ident 2
  9. USER3 = "lawlfgt" # Ident 3
  10. PORT = 6667 # Port (it is normally 6667)
  11. UPASS = "<no peaky weaky>" # Pass for Ustream
  12. UMODE = "+wxyB"
  13. SYMBOL = "$" #symbol eg. if set to # commands will be #echo.
  14. blank = ""
  15. ###########################
  16. ##plugin loading varibles##
  17. ###########################
  18. food = True
  19. def ping(msg):
  20. s.send("PONG :"+ msg +"\r\n")
  21. def joinchan(channel):
  22. s.send("PRIVMSG "+ CHANNEL +" :Joining "+ channel +"\r\n")
  23. s.send("JOIN "+ channel +"\r\n")
  24. def partchan(channel):
  25. s.send("PRIVMSG "+ CHANNEL +" :Leaving "+ channel +"\r\n")
  26. s.send("PART "+ channel +"\r\n")
  27. def hello(user):
  28. s.send("PRIVMSG "+ CHANNEL +" :G'day "+ nick +"!\n")
  29. def quitIRC():
  30. s.send("QUIT "+ CHANNEL +"\n")
  31. def kickme(target, reason):
  32. s.send("KICK "+ CHANNEL +" "+ target +" "+ reason + "\n")
  33. def fail():
  34. s.send("PRIVMSG "+ CHANNEL +" :Either you do not have the permission to do that, or that is not a valid command.\n")
  35. def fish(user):
  36. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION slaps "+ user +" with a wet sloppy tuna fish.\x01\r\n")
  37. time.sleep(1)
  38. s.send("PRIVMSG "+ CHANNEL +" :take that bitch\n")
  39. def sandwich(sender):
  40. if food == True:
  41. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION is making "+ sender +" a sandwich\x01\r\n")
  42. time.sleep(10)
  43. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION has finished making "+ sender +"'s sandwhich\x01\r\n")
  44. time.sleep(1)
  45. s.send("PRIVMSG "+ CHANNEL +" :Here you go "+ sender +"! I hope you enjoy it!\r\n")
  46. else:
  47. s.send("PRIVMSG "+ CHANNEL +" :Command not loaded\r\n")
  48. def makeitem(nick, item):
  49. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION is making "+ nick +" a "+ item +"\x01\r\n")
  50. time.sleep(10)
  51. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION has finished making "+ nick +"'s "+ item +"\x01\r\n")
  52. time.sleep(1)
  53. s.send("PRIVMSG "+ CHANNEL +" :Here you go "+ nick +"! I hope you enjoy it!\r\n")
  54. def bomb(user):
  55. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION hurls a bomb in "+ user +"'s direction.\x01\r\n")
  56. time.sleep(0.5)
  57. s.send("PRIVMSG "+ CHANNEL +" :BOOM!\n")
  58. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION bomb explodes.\x01\r\n")
  59. s.send("KICK ##aussiepowder "+ user +" Bombed\n")
  60. time.sleep(1.75)
  61. s.send("PRIVMSG "+ CHANNEL +" :and you thought you could take a bot with such awesomeness! pfft\n")
  62. def cake(sender):
  63. if food == True:
  64. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION is making "+ sender +" a cake\x01\r\n")
  65. time.sleep(10)
  66. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION has finished making "+ sender +"'s cake\x01\r\n")
  67. time.sleep(1)
  68. s.send("PRIVMSG "+ CHANNEL +" :Here you go "+ sender +"! I hope you enjoy it!\r\n")
  69. else:
  70. s.send("PRIVMSG "+ CHANNEL +" :Command not loaded\r\n")
  71. def echo(message):
  72. s.send("PRIVMSG "+ CHANNEL +" :"+ message +"\r\n")
  73. def pepsi(user):
  74. if food == True:
  75. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION dispenses a can of Pepsi for "+ user +"\x01\r\n")
  76. else:
  77. s.send("PRIVMSG "+ CHANNEL +" :Command not loaded\r\n")
  78. def coke(user):
  79. if food == True:
  80. s.send("PRIVMSG "+ CHANNEL +" :\x01ACTION dispenses a can of Coke for "+ user +"\x01\r\n")
  81. else:
  82. s.send("PRIVMSG "+ CHANNEL +" :Command not loaded\r\n")
  83. def load(plugin):
  84. if plugin =="food":
  85. global food
  86. food = True
  87. s.send("PRIVMSG "+ CHANNEL +" :LOADED the FOOD plugin\r\n")
  88. else:
  89. s.send("PRIVMSG "+ CHANNEL +" :UNKNOWN plugin\r\n")
  90.  
  91. def unload(plugin):
  92. if plugin =="food":
  93. global food
  94. food = False
  95. s.send("PRIVMSG "+ CHANNEL +" :UNLOADED the FOOD plugin\r\n")
  96. else:
  97. s.send("PRIVMSG "+ CHANNEL +" :UNKNOWN plugin\r\n")
  98. s = socket.socket( )
  99. s.connect((HOST, PORT))
  100. s.send("PASS "+ UPASS +"\r\n")
  101. s.send("USER "+ USER1 +" "+ USER2 +" "+ USER3 +" :tehircbot\n")
  102. s.send("NICK "+ NICK +"\r\n")
  103. s.send("MODE "+ NICK +" "+ UMODE +"\r\n")
  104. s.send("JOIN "+ HOME_CHANNEL +"\r\n")
  105. while 1:
  106. line = s.recv(2048)
  107. line = line.strip("\r\n")
  108. print line
  109. stoperror = line.split(" ")
  110. if ("PING :" in line):
  111. pingcmd = line.split(":", 1)
  112. pingmsg = pingcmd[1]
  113. ping(pingmsg)
  114. elif "PRIVMSG" in line:
  115.  
  116. if len(line) < 30:
  117. print blank
  118. elif len(stoperror) < 4:
  119. print blank
  120. else:
  121. complete = line.split(":", 2)
  122. info = complete[1]
  123. msg = line.split(":", 2)[2] ##the thing that was said
  124. cmd = msg.split(" ")[0]
  125. CHANNEL = info.split(" ")[2] ##channel from which it was said
  126. user = line.split(":")[1].split("!")[0] ## the person that said the thing
  127. arg = msg.split(" ")
  128.  
  129. if "hello " + NICK ==cmd:
  130. hello(user)
  131. print "recieved hello"
  132. elif "hey " + NICK ==cmd:
  133. hello(user)
  134. "print recieved hello"
  135. elif "hi " + NICK ==cmd:
  136. hello(user)
  137. "print recieved hello"
  138. elif SYMBOL + "join"==cmd and len(arg) > 1:
  139. x = line.split(" ", 4)
  140. newchannel = x[4]
  141. joinchan(newchannel)
  142. elif SYMBOL + "leave"==cmd and len(arg) > 1:
  143. x = line.split(" ", 4)
  144. newchannel = x[4]
  145. partchan(newchannel)
  146. elif SYMBOL + "quit"==cmd:
  147. quitIRC()
  148. elif SYMBOL + "coke"==cmd and len(arg) > 1:
  149. x = line.split(" ")
  150. recvr = x[4]
  151. coke(recvr)
  152. elif SYMBOL + "pepsi"==cmd and len(arg) > 1:
  153. x = line.split(" ")
  154. recvr = x[4]
  155. pepsi(recvr)
  156. elif SYMBOL + "fish"==cmd and len(arg) > 1:
  157. x = line.split(" ")
  158. recvr = x[4]
  159. fish(recvr)
  160. elif SYMBOL + "bomb"==cmd and len(arg) > 1:
  161. x = line.split(" ")
  162. recvr = x[4]
  163. bomb(recvr)
  164. elif SYMBOL + "fish"==cmd:
  165. sandwich(user)
  166. elif SYMBOL + "cake"==cmd:
  167. cake(user)
  168. elif SYMBOL + "echo"==cmd:
  169. x = msg.split(" ", 1)[1]
  170. echo(x)
  171.  
  172. elif line.find(""+ SYMBOL +"load") != -1:
  173. plugin = msg.split(" ")[1]
  174. load(plugin)
  175.  
  176. elif line.find(""+ SYMBOL +"unload") != -1:
  177. plugin = msg.split(" ")[1]
  178. unload(plugin)
  179.  
  180. elif SYMBOL in cmd:
  181. fail()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement