Guest User

Untitled

a guest
Jan 5th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. from ircutils import bot
  2. import time
  3. import string
  4. import sys
  5.  
  6. class EchoBot(bot.SimpleBot):
  7.  
  8. def on_channel_message(self, event):
  9. print event.message # Output all the messages to the console.
  10. name = event.source # The source is who caused this event.
  11.  
  12. fullmessage = event.message
  13.  
  14. if fullmessage[0] == '(': # The user is on MineCraft
  15. endName = fullmessage.find(')')
  16. if endName > 0:
  17. currentmessage = fullmessage[endName+1:]
  18. commandarray = currentmessage.split()
  19. command = commandarray[0]
  20. arguments = commandarray[1:]
  21. self.send_message(event.target, "Command Detection: " + command)
  22. self.send_message(event.target, "Argument Detection: " + string.join(arguments, ' '))
  23. response = handle_command(command, arguments, fullmessage[1:endName])
  24. if response:
  25. self.send_message(event.target, response)
  26. else: # The user is NOT on MineCraft. The user is on IRC.
  27. if event.source == "Done-Fear":
  28. commandarray = fullmessage.split()
  29. command = commandarray[0]
  30. arguments = commandarray[1:]
  31. self.send_message(event.target, "Command Detection: " + command)
  32. self.send_message(event.target, "Argument Detection: " + string.join(arguments, ' '))
  33. response = handle_command(command, arguments, fullmessage[1:endName])
  34. if response:
  35. self.send_message(event.target, response)
  36.  
  37.  
  38. def handle_command(command, arguments, name):
  39. if command == '+bug':
  40. file = open("Bugs.txt", "a")
  41. file.write(string.join(arguments, ' '))
  42. file.write("\r\n")
  43. file.close()
  44. return "Thank you for the bug report my system will process it"
  45. elif command == '+suicide':
  46. if name == ''
  47. sys.exit(0)
  48. return
  49. elif command == '+hi':
  50. return "Hello, " + name
  51. elif command == '+rules':
  52. return "No flaming ; no racism ; have fun"
  53. elif command == '+help':
  54. return "What can I help you with, " + name + "? Start by trying the following commands: " + "+hi,+rules,+help,+cookie"
  55. elif command == '+cookie':
  56. return "Omg you seriues you want a cookie again -.- TAKE COVER hes gone explode'"
  57. elif command == '+cake':
  58. return "Omg you seriues the cake is a LIE !!!!"
  59. else:
  60. pass
  61.  
  62.  
  63. if __name__ == "__main__":
  64. echo = EchoBot("JS_Gladis")
  65. echo.connect("irc.esper.net", channel=["#pandabot"])
  66. echo.start()
  67.  
  68.  
  69.  
  70.  
  71. # cmds = '+hi,+rules,+help,+cookie'
  72. # if command == '+hi':
  73. # self.send_message(event.target, 'Hello, ' + name)
  74. # elif command == '+rules':
  75. # self.send_message(event.target, 'No flaming ; no racism ; have fun')
  76. # elif command == '+help':
  77. # self.send_message(event.target, 'srr ' + name[1:-1] + ' but with what can i help you? try ' + cmds)
  78. # elif command == '+cookie' :
  79. # self.send_message(event.target, 'Omg you seriues you want a cookie again -.- TAKE COVER hes gone explode')
  80. # elif command == '+cake' :
  81. # self.send_message(event.target, 'Omg you seriues the cake is a LIE !!!!')
  82. # elif command == '+bug':
  83. # self.send_message(event.target, 'Thank you for the bug report my system will process it ')
  84. # myFile = open('bug.txt', 'a')
  85. # myFile.write(message[1:])
  86. # myFile.close()
  87. # elif command == '+suicide':
  88. # self.send_message(event.target, "NOOOOO don't kill me !!!")
  89. # time.sleep(1.0)
  90. # self.send_message(event.target, "Please don't kill ...")
  91. # time.sleep(1.0)
  92. # self.disconnect("Goodbye cruel world!")
  93.  
  94. # if __name__ == "__main__":
  95. # echo = EchoBot("Gladis")
  96. # echo.connect("irc.esper.net", channel=["#pandabot"])
  97. # echo.start()
Add Comment
Please, Sign In to add comment