Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ircutils import bot
- import time
- import string
- import sys
- class EchoBot(bot.SimpleBot):
- def on_channel_message(self, event):
- print event.message # Output all the messages to the console.
- name = event.source # The source is who caused this event.
- fullmessage = event.message
- if fullmessage[0] == '(': # The user is on MineCraft
- endName = fullmessage.find(')')
- if endName > 0:
- currentmessage = fullmessage[endName+1:]
- commandarray = currentmessage.split()
- command = commandarray[0]
- arguments = commandarray[1:]
- self.send_message(event.target, "Command Detection: " + command)
- self.send_message(event.target, "Argument Detection: " + string.join(arguments, ' '))
- response = handle_command(command, arguments, fullmessage[1:endName])
- if response:
- self.send_message(event.target, response)
- else: # The user is NOT on MineCraft. The user is on IRC.
- if event.source == "Done-Fear":
- commandarray = fullmessage.split()
- command = commandarray[0]
- arguments = commandarray[1:]
- self.send_message(event.target, "Command Detection: " + command)
- self.send_message(event.target, "Argument Detection: " + string.join(arguments, ' '))
- response = handle_command(command, arguments, fullmessage[1:endName])
- if response:
- self.send_message(event.target, response)
- def handle_command(command, arguments, name):
- if command == '+bug':
- file = open("Bugs.txt", "a")
- file.write(string.join(arguments, ' '))
- file.write("\r\n")
- file.close()
- return "Thank you for the bug report my system will process it"
- elif command == '+suicide':
- if name == ''
- sys.exit(0)
- return
- elif command == '+hi':
- return "Hello, " + name
- elif command == '+rules':
- return "No flaming ; no racism ; have fun"
- elif command == '+help':
- return "What can I help you with, " + name + "? Start by trying the following commands: " + "+hi,+rules,+help,+cookie"
- elif command == '+cookie':
- return "Omg you seriues you want a cookie again -.- TAKE COVER hes gone explode'"
- elif command == '+cake':
- return "Omg you seriues the cake is a LIE !!!!"
- else:
- pass
- if __name__ == "__main__":
- echo = EchoBot("JS_Gladis")
- echo.connect("irc.esper.net", channel=["#pandabot"])
- echo.start()
- # cmds = '+hi,+rules,+help,+cookie'
- # if command == '+hi':
- # self.send_message(event.target, 'Hello, ' + name)
- # elif command == '+rules':
- # self.send_message(event.target, 'No flaming ; no racism ; have fun')
- # elif command == '+help':
- # self.send_message(event.target, 'srr ' + name[1:-1] + ' but with what can i help you? try ' + cmds)
- # elif command == '+cookie' :
- # self.send_message(event.target, 'Omg you seriues you want a cookie again -.- TAKE COVER hes gone explode')
- # elif command == '+cake' :
- # self.send_message(event.target, 'Omg you seriues the cake is a LIE !!!!')
- # elif command == '+bug':
- # self.send_message(event.target, 'Thank you for the bug report my system will process it ')
- # myFile = open('bug.txt', 'a')
- # myFile.write(message[1:])
- # myFile.close()
- # elif command == '+suicide':
- # self.send_message(event.target, "NOOOOO don't kill me !!!")
- # time.sleep(1.0)
- # self.send_message(event.target, "Please don't kill ...")
- # time.sleep(1.0)
- # self.disconnect("Goodbye cruel world!")
- # if __name__ == "__main__":
- # echo = EchoBot("Gladis")
- # echo.connect("irc.esper.net", channel=["#pandabot"])
- # echo.start()
Add Comment
Please, Sign In to add comment