Beispiel #1
0
 def _create_msg(self, message, source=None, is_admin=False):
     if not isinstance(message, irc.Message):
         if not source:
             source = "[email protected]"
         message = irc.Message(source, "#test", message)
     message.user.is_admin = is_admin
     return message
Beispiel #2
0
 def assert_reply(input, output):
     bot._send_msg = mock.MagicMock()
     bot._handle_privmsg(irc.Message('foo!bar@baz', '#chan', input))
     if output:
         bot._send_msg.assert_called_with(output, '#chan')
     else:
         bot._send_msg.assert_not_called()
     bot._send_msg.close()
Beispiel #3
0
 def assert_reply(input, output):
     bot.send_msg = mock.MagicMock()
     bot._handle_privmsg(irc.Message("foo!bar@baz", "#chan", input))
     if output:
         bot.send_msg.assert_called_with("#chan", output)
     else:
         bot.send_msg.assert_not_called()
     bot.send_msg.close()
Beispiel #4
0
 def test_commands_and_args_are_parsed(self):
     msg = irc.Message('[email protected]', '#channel', '!foo bar baz')
     cmd = botologist.bot.CommandMessage(msg)
     self.assertEqual('!foo', cmd.command)
     self.assertEqual(['bar', 'baz'], cmd.args)
Beispiel #5
0
 def test_is_private(self):
     msg = irc.Message("[email protected]", "#chan", "foo bar baz")
     self.assertFalse(msg.is_private)
     msg = irc.Message("[email protected]", "nick", "foo bar baz")
     self.assertTrue(msg.is_private)
Beispiel #6
0
 def test_init(self):
     msg = irc.Message("[email protected]", "#chan", "foo bar baz")
     self.do_assertions(msg)
Beispiel #7
0
 def test_is_private(self):
     msg = irc.Message('[email protected]', '#chan', 'foo bar baz')
     self.assertFalse(msg.is_private)
     msg = irc.Message('[email protected]', 'nick', 'foo bar baz')
     self.assertTrue(msg.is_private)
Beispiel #8
0
 def test_init(self):
     msg = irc.Message('[email protected]', '#chan', 'foo bar baz')
     self.do_assertions(msg)
Beispiel #9
0
 def test_commands_and_args_are_parsed(self):
     msg = irc.Message("[email protected]", "#channel", "!foo bar baz")
     cmd = botologist.bot.CommandMessage(msg)
     self.assertEqual("!foo", cmd.command)
     self.assertEqual(["bar", "baz"], cmd.args)