Exemple #1
0
	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)
Exemple #2
0
	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)
Exemple #3
0
	def test_method_number(self):
		m = lookup_hook(self.tc, "361")

		self.assertIsNotNone(m)
		self.assertEquals(m, self.tc.on_361)
Exemple #4
0
	def test_method_named(self):
		m = lookup_hook(self.tc, "named")

		self.assertIsNotNone(m)
		self.assertEquals(m, self.tc.on_named)
Exemple #5
0
	def test_method_not_found(self):
		self.assertIsNone(lookup_hook(self.tc, "DOES_NOT_EXISTS"))