def __init__(self, bot):
     self.bot = bot
     # One time events that we only need to register temporarily
     self.before_connect_events = [
         event.event(event.NOTICE, callback=self.check_login),
         event.event(event.RPL_ENDOFMOTD, callback=self.remove_events),
         event.event(event.GLOBALUSERSTATE, callback=self.set_user_state)
     ]
Esempio n. 2
0
 def test___init__(self):
     func = lambda x: x
     instance = event.event('ABC', callback=func)
     assert instance.callback == func
Esempio n. 3
0
 def test_compile_no_config(self):
     func = lambda x: x
     decorated = event.event(r'\S+')(func)
     matcher = decorated.compile()
     assert matcher('ABC') is not None
     assert matcher('ABC ') is None
Esempio n. 4
0
 def test_raw_event(self):
     func = lambda x: x
     decorated = event.event(event.PRIVMSG)(func)
     assert decorated.key == event.PRIVMSG.re
Esempio n. 5
0
 def test_regexp(self):
     func = lambda x: x
     decorated = event.event('ABC')(func)
     assert decorated.regexp == 'ABC'
Esempio n. 6
0
 def test_decorator(self):
     func = lambda x: x
     instance = event.event('ABC')
     assert instance.callback is None
     decorated = instance(func)
     assert decorated.callback == func