Example #1
0
class ModuleTroll(ModuleBase):
    NUMBER_REPORT_MESSAGES = 5
    def __init__(self, bot):
        ModuleBase.__init__(self, bot)
        self.name = "ModuleTroll"
        self.reportedPeople = UserCount(self.NUMBER_REPORT_MESSAGES)

    def notify_text(self, message_id, from_attr, date, chat, text):
        name = from_attr["first_name"]
        if self.reportedPeople.has(name):
            text = name + ", t'es un vieux zgeg. HUEHUEHUEHUEHUE"
            self.bot.sendMessage(text, chat["id"])
                
    def notify_new_chat_participant(self, message_id, from_attr, date, chat, new_chat_participant):
        text = "Tiens, un nouveau zgeg, bienvenue "+ new_chat_participant["first_name"] + "!"
        self.bot.sendMessage(text, chat["id"])
        
    def notify_left_chat_participant(self, message_id, from_attr, date, chat, left_chat_participant):
        text = left_chat_participant["first_name"] + " qui s'en va, bon débarras!"
        self.bot.sendMessage(text, chat["id"])
        
    def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr):
        if commandName == "report":
            text = commandStr + " me report u\nHUEHUEHUEHUEHUE\nHUEHUEHUEHUEHUE\nHUEHUEHUEHUEHUE"        
            self.bot.sendMessage(text, chat["id"])
            self.reportedPeople.add(commandStr)

    def get_commands(self):
        return [
            ("report", "Report someone. HUEHUEHUEHUE"),
        ]
 def test_main(self):
     nb = 3
     cnt = UserCount(nb)
     user = "******"
     self.assertFalse(cnt.has(user))
     cnt.add(user)
     for i in range(nb):
         self.assertTrue(cnt.has(user))
     self.assertFalse(cnt.has(user))
     cnt.add(user)
     cnt.add(user)
     for i in range(nb * 2):
         self.assertTrue(cnt.has(user))
     self.assertFalse(cnt.has(user))
Example #3
0
 def test_main(self):
     nb = 3
     cnt = UserCount(nb)
     user = "******"
     self.assertFalse(cnt.has(user))
     cnt.add(user)
     for i in range(nb):
         self.assertTrue(cnt.has(user))
     self.assertFalse(cnt.has(user))
     cnt.add(user)
     cnt.add(user)
     for i in range(nb * 2):
         self.assertTrue(cnt.has(user))
     self.assertFalse(cnt.has(user))
Example #4
0
 def test_double_delete(self):
     nb = 3
     cnt = UserCount(nb)
     user = "******"
     cnt.remove(user)
     cnt.remove(user)
Example #5
0
 def __init__(self, bot):
     ModuleBase.__init__(self, bot)
     self.name = "ModuleTroll"
     self.reportedPeople = UserCount(self.NUMBER_REPORT_MESSAGES)
 def test_double_delete(self):
     nb = 3
     cnt = UserCount(nb)
     user = "******"
     cnt.remove(user)
     cnt.remove(user)