def invoke(self, msg): # distinguish between commands with and without parameters if ' ' in msg.trail: cmd, params = msg.trail.split(' ', 1) else: cmd, params = msg.trail, None # strip the ! away cmd = cmd.lstrip('!') meth = lookup_hook(self, cmd, lookup_table=None, prefix="on_cmd_") if meth: meth(params, msg)
def test_method_named(self): table = {111: "looked_up"} m = lookup_hook(self.tc, 111, table) self.assertIsNotNone(m) self.assertEquals(m, self.tc.on_looked_up)
def test_method_number(self): m = lookup_hook(self.tc, "361") self.assertIsNotNone(m) self.assertEquals(m, self.tc.on_361)
def test_method_named(self): m = lookup_hook(self.tc, "named") self.assertIsNotNone(m) self.assertEquals(m, self.tc.on_named)
def test_method_not_found(self): self.assertIsNone(lookup_hook(self.tc, "DOES_NOT_EXISTS"))