hello.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. ##Created by hlmtre, just pybot giving a friendly hello##
  2. import sys
  3. from event import Event
  4. from random import choice
  5. try:
  6. if sys.version_info > (3, 0, 0):
  7. from .basemodule import BaseModule
  8. else:
  9. from basemodule import BaseModule
  10. except (ImportError, SystemError):
  11. from modules.basemodule import BaseModule
  12. class Hello(BaseModule):
  13. def post_init(self):
  14. hello = Event("__hello__")
  15. hello.subscribe(self)
  16. self.help = None
  17. self.bot.register_event(hello, self) #Register to your event
  18. nick = self.bot.conf.getNick(self.bot.network) #Grabs the nick of the person greeting pybot
  19. hello.define(msg_definition="^([H|h]ello|[H|h]i|[H|h]owdy|[H|h]ey) " + nick) #How pybot determines whether he is being greeted
  20. self.retorts = ['hello', 'sup', 'hi', 'good to see you', 'loldicks'] #List of different ways he will be able to respond
  21. def handle(self, event):
  22. try:
  23. self.say(event.channel, choice(self.retorts) + " " + event.user) #If the parameters above in "hello.define" are met he will spit out the greeting in the channel
  24. except Exception as e:
  25. print(e)