Ejemplo n.º 1
0
def start(message, who):
    users = set(re.findall("<@([\w]*)>", who))
    users.add(message.body["user"])

    if len(users) <= 1:
        message.reply("bomber is not started because user not found.")
        return

    message.reply("slack-bomber is started:")
    BomberFactory.create(message.body["channel"], list(users))
Ejemplo n.º 2
0
 def test_send_new_message_after_8_chats(self, mocked_outputter):
     bomber = BomberFactory.create("channel2", [])
     bomber.prev_tick = time.time()
     self.assertEqual(bomber.should_send_as_new_message, False)
     bomber.add_chat_count()
     bomber.add_chat_count()
     bomber.add_chat_count()
     bomber.add_chat_count()
     bomber.add_chat_count()
     bomber.add_chat_count()
     bomber.add_chat_count()
     self.assertEqual(bomber.should_send_as_new_message, False)
     bomber.tick()
     bomber.add_chat_count()
     self.assertEqual(bomber.should_send_as_new_message, True)
     bomber.tick()
     self.assertEqual(bomber.should_send_as_new_message, False)
     bomber.add_chat_count()
     self.assertEqual(bomber.should_send_as_new_message, False)
Ejemplo n.º 3
0
def any(message):
    bomber = BomberFactory.instance(message.body["channel"])
    if bomber is not None:
        bomber.add_chat_count()
Ejemplo n.º 4
0
def end(message):
    BomberFactory.remove(message.body["channel"])
    message.reply("finished")
Ejemplo n.º 5
0
 def test_BomberFactory_should_create_each_bomber_instance_in_other_channel(
         self):
     bomber1 = BomberFactory.create("channel1", [])
     bomber2 = BomberFactory.create("channel2", [])
     self.assertIsNot(bomber1, bomber2)
Ejemplo n.º 6
0
 def test_BomberFactory_should_return_same_instance_in_same_channel(self):
     bomber1 = BomberFactory.create("channel", [])
     bomber2 = BomberFactory.create("channel", [])
     self.assertIs(bomber1, bomber2)
Ejemplo n.º 7
0
 def test_BomberFactory_should_create_bomber_instance(self):
     bomber = BomberFactory.create("channel", [])
     self.assertIsInstance(bomber, Bomber)