Commits

Dafydd Francis committed 8b294ad

Thanks Afal... Thafal

Comments (0)

Files changed (2)

    tbot.msg(channel,"<3 "+user)
 love.rule='<3 TwistedBot'
 
+def thanks_ants(tbot, user, channel, msg):
+    name = msg.replace("!thanks ", '').strip()
+    thname = re.sub(r'^[bcdfghjklmnpqrstvwxyz]*', '', name.lower()) or name.lower()
+    tbot.msg(channel, "Thanks %s... Th%s" % (name, thname))
+thanks_ants.rule = '!thanks '
+
 def xory(question):
    return random.choice(re.split(",|or", question)).strip()
 

test/test_ping.py

+import sys
+sys.path.append("../modules/")
+import ping
+from fake_tbot import TestedBot
+
+import unittest
+
+
+class TestPingModule(unittest.TestCase):
+
+    def setUp(self):
+        self.tbot = TestedBot()
+        self.tbot.register(ping.thanks_ants)
+
+    def test_thanks_ants(self):
+        self.tbot.bot_messages = []
+        self.tbot.listen("Afal", "#42", "!thanks ants")
+        self.assertEqual(self.tbot.last_message()[1], "Thanks ants... Thants")
+
+    def test_thanks_trtl(self):
+        self.tbot.bot_messages = []
+        self.tbot.listen("Afal", "#42", "!thanks trtl")
+        self.assertEqual(self.tbot.last_message()[1], "Thanks trtl... Thtrtl")
+
+    def test_thanks_sylnai(self):
+        self.tbot.bot_messages = []
+        self.tbot.listen("Afal", "#42", "!thanks Sylnai")
+        self.assertEqual(self.tbot.last_message()[1], "Thanks Sylnai... Thai")
+
+    def test_thanks_phoebe(self):
+        self.tbot.bot_messages = []
+        self.tbot.listen("Afal", "#42", "!thanks phoebe")
+        self.assertEqual(self.tbot.last_message()[1], "Thanks phoebe... Thoebe")
+
+if __name__ == '__main__':
+    unittest.main()