class BotTest(unittest.TestCase): def setUp(self): self.bot = Bot() self.logic = BotLogic(self.bot) def test_parse_priv_msg(self): line = ":[email protected] " \ + "PRIVMSG #psywerx :I will try to improve my tunapasta " \ + "from this data :P" nick, msg, _ = self.logic.parse_msg(line) self.assertEqual("HairyFotr", nick, "Nick does not match") self.assertEqual( "I will try to improve my tunapasta " + "from this data :P", msg, "Msg does not match") def test_parse_event(self): line = ":[email protected] QUIT " \ + ":Quit: smotko" nick, msg, _ = self.logic.parse_msg(line) self.assertEqual("smotko", nick) self.assertEqual("Quit: smotko", msg) def test_parse_weird(self): line = ":smotko!~smotko@2001:1470:fffe:fe01:4c8b:3839:ad5f:3bbb " \ + "JOIN #smotko-testing" nick, msg, channel = self.logic.parse_msg(line) self.assertEqual("smotko", nick) self.assertEqual("#smotko-testing", channel)
class BotTest(unittest.TestCase): def setUp(self): self.bot = Bot() self.logic = BotLogic(self.bot) def test_parse_priv_msg(self): line = ":[email protected] " \ + "PRIVMSG #psywerx :I will try to improve my tunapasta " \ + "from this data :P" nick, msg, _ = self.logic.parse_msg(line) self.assertEqual("HairyFotr", nick, "Nick does not match") self.assertEqual("I will try to improve my tunapasta " + "from this data :P", msg, "Msg does not match") def test_parse_event(self): line = ":[email protected] QUIT " \ + ":Quit: smotko" nick, msg, _ = self.logic.parse_msg(line) self.assertEqual("smotko", nick) self.assertEqual("Quit: smotko", msg) def test_parse_weird(self): line = ":smotko!~smotko@2001:1470:fffe:fe01:4c8b:3839:ad5f:3bbb " \ + "JOIN #smotko-testing" nick, _, channel = self.logic.parse_msg(line) self.assertEqual("smotko", nick) self.assertEqual("#smotko-testing", channel)
class BotTest(unittest.TestCase): def setUp(self): self.bot = Bot() self.logic = BotLogic(self.bot) def testParsePrivMsg(self): line = ":[email protected] PRIVMSG #psywerx :I will try to improve my tunapasta from this data :P" nick, msg = self.logic.parse_msg(line) self.assertEqual("HairyFotr", nick, "Nick does not match") self.assertEqual("I will try to improve my tunapasta from this data :P", msg, "Msg does not match") def testParseEvent(self): line = ":[email protected] QUIT :Quit: smotko" nick, msg = self.logic.parse_msg(line) self.assertEqual("smotko", nick) self.assertEqual("Quit: smotko", msg)
def setUp(self): self.bot = Bot() self.logic = BotLogic(self.bot)
import telebot from nltk.corpus import wordnet as wn from logic import BotLogic with open(".secret", 'r') as f: secret = f.read()[:-1] bot = telebot.TeleBot(secret) logic = BotLogic(bot) @bot.message_handler(content_types=['text']) def handle(message): logic.process_message(message) if __name__ == "__main__": wn.ensure_loaded() bot.polling(none_stop=True, interval=0)