welcome_message="Welcome! THe channel is pretty quiet right now, so I thought I'd say hello, and ping some people that you're here. If no one responds for a whle, try emailing us at hello@openhatch.org or just try coming back later. FYI, you're now on my list of known nicknames, so I won't bother you again."
self.assertEqual(self.ircsock.sent_message(),"PRIVMSG {0} :Welcome Hermione! The channel is pretty quiet right now, so I thought I'd say hello, and ping some people (like {1}) that you're here. If no one responds for a while, try emailing us at hello@openhatch.org or just try coming back later. FYI, you're now on my list of known nicknames, so I won't bother you again.\n".format(botcode.channel,botcode.greeter_string(botcode.channel_greeters)))
self.assertEqual(self.ircsock.sent_message(),"PRIVMSG {0} :Welcome Hermione! The channel is pretty quiet right now, so I thought I'd say hello, and ping some people (like {1}) that you're here. If no one responds for a while, try emailing us at hello@openhatch.org or just try coming back later. FYI, you're now on my list of known nicknames, so I won't bother you again.\n".format(settings.channel,botcode.greeter_string(settings.channel_greeters)))
deftearDown(self):
withopen('test_nicks.csv','w')ascsv_file:
csv_file.write('Alice\nBob\n')
@ -139,7 +142,7 @@ class TestParseMessages(unittest.TestCase):
deftest_good_string(self):
ircmsg,actor=botcode.parse_messages(":vader!darth@darkside.org PRIVMSG #deathstar : I find your lack of faith disturbing")
self.assertEqual([ircmsg,actor],[':vader!darth@darkside.org PRIVMSG #deathstar : I find your lack of faith disturbing','vader'])
deftest_bad_string(self):
ircmsg,actor=botcode.parse_messages("we should probably replace this with a bad string more likely to occur")
self.assertEqual([ircmsg,actor],[None,None])
@ -152,69 +155,69 @@ class TestMessageResponse(unittest.TestCase):
self.ircsock=fake_irc_start()
deftest_newcomer_speaking(self):
botcode.message_response(self.bot,"~q@r.m.us PRIVMSG {} :hah".format(botcode.channel),"Chappe",ircsock=self.ircsock)# Standard message by newcomer
botcode.message_response(self.bot,"~q@r.m.us PRIVMSG {} :hah".format(settings.channel),"Chappe",ircsock=self.ircsock,channel=settings.channel,greeters=settings.channel_greeters)# Standard message by newcomer
nicklist=[i.nickforiinself.bot.newcomers]# Makes a list of newcomers nicks for easy asserting
self.assertEqual(nicklist,['Chappe'])
deftest_oldtimer_speaking(self):
botcode.message_response(self.bot,"~q@r.m.us PRIVMSG {} :hah".format(botcode.channel),"Alice",ircsock=self.ircsock)# Standard message by oldtimer
botcode.message_response(self.bot,"~q@r.m.us PRIVMSG {} :hah".format(settings.channel),"Alice",ircsock=self.ircsock,channel=settings.channel,greeters=settings.channel_greeters)# Standard message by oldtimer
nicklist=[i.nickforiinself.bot.newcomers]# Makes a list of newcomers nicks for easy asserting
self.assertEqual(nicklist,[])
deftest_join(self):
botcode.message_response(self.bot,"JOIN {} right now!".format(botcode.channel),"Shauna",ircsock=self.ircsock) # Replace with actual ping message
botcode.message_response(self.bot,"JOIN {} right now!".format(settings.channel),"Shauna",ircsock=self.ircsock, channel=settings.channel,greeters=settings.channel_greeters) # Replace with actual ping message
botcode.message_response(self.bot,"JOIN {} right now!".format(botcode.channel),"Shauna",ircsock=self.ircsock)# Replace with actual ping message
botcode.message_response(self.bot,"JOIN {} right now!".format(settings.channel),"Shauna",ircsock=self.ircsock,channel=settings.channel,greeters=settings.channel_greeters)# Replace with actual ping message
self.assertEqual(len(self.bot.newcomers),2)
botcode.message_response(self.bot,"PART {}".format(botcode.channel),"Shauna",ircsock=self.ircsock)# Replace with actual ping message
self.assertEqual(len(self.bot.newcomers),1)
botcode.message_response(self.bot,"PART {}".format(settings.channel),"Shauna",ircsock=self.ircsock,channel=settings.channel,greeters=settings.channel_greeters)# Replace with actual ping message
botcode.message_response(self.bot,"PRIVMSG info {}".format(botcode.botnick),"Shauna",ircsock=self.ircsock)
botcode.message_response(self.bot,"PRIVMSG info {}".format(self.bot.botnick),"Shauna",ircsock=self.ircsock,channel=settings.channel,greeters=settings.channel_greeters)
self.assertTrue(self.ircsock.has_sent_message())
self.assertEqual(self.ircsock.sent_message(),"PRIVMSG {} :I'm a bot! I'm from here <https://github.com/shaunagm/oh-irc-bot>. You can change my behavior by submitting a pull request or by talking to shauna.\n".format(botcode.channel))
self.assertEqual(self.ircsock.sent_message(),"PRIVMSG {} :I'm a bot! I'm from here <https://github.com/shaunagm/oh-irc-bot>. You can change my behavior by submitting a pull request or by talking to shauna.\n".format(settings.channel))
deftest_wait_time_from_admin(self):
botcode.message_response(self.bot,"{} --wait-time 40".format(botcode.botnick),"shauna",ircsock=self.ircsock)# Channel-greeters may also be changed. :(
self.assertEqual(self.ircsock.sent_message(),"PRIVMSG {} :shauna the wait time is changing to 40 seconds.\n".format(botcode.channel))
deftest_wait_time_from_non_admin(self):
botcode.message_response(self.bot,"{} --wait-time 40".format(botcode.botnick),"Impostor",ircsock=self.ircsock) # Channel-greeters may also be changed. :(
self.assertEqual(self.ircsock.sent_message(),"PRIVMSG {0} :Impostor you are not authorized to make that change. Please contact one of the channel greeters, like {1}, for assistance.\n".format(botcode.channel,botcode.greeter_string(botcode.channel_greeters)))
botcode.message_response(self.bot,"{} --wait-time 40".format(self.bot.botnick),"shauna",ircsock=self.ircsock,channel=settings.channel,greeters=settings.channel_greeters)# Channel-greeters may also be changed. :(
self.assertEqual(self.ircsock.sent_message(),"PRIVMSG {} :shauna the wait time is changing to 40 seconds.\n".format(settings.channel))
deftest_wait_time_from_non_admin(self):
botcode.message_response(self.bot,"{} --wait-time 40".format(self.bot.botnick),"Impostor",ircsock=self.ircsock, channel=settings.channel,greeters=settings.channel_greeters) # Channel-greeters may also be changed. :(
self.assertEqual(self.ircsock.sent_message(),"PRIVMSG {0} :Impostor you are not authorized to make that change. Please contact one of the channel greeters, like {1}, for assistance.\n".format(settings.channel,botcode.greeter_string(settings.channel_greeters)))
deftest_pong(self):
botcode.message_response(self.bot,"PING :","Shauna",ircsock=self.ircsock) # Replace this with actual ping message
botcode.message_response(self.bot,"PING :","Shauna",ircsock=self.ircsock, channel=settings.channel,greeters=settings.channel_greeters) # Replace this with actual ping message
botcode.message_response(self.bot,"PING!!! :","Shauna",ircsock=self.ircsock) # Replace this with actual ping message
self.assertFalse(self.ircsock.has_sent_message())
botcode.message_response(self.bot,"PING!!! :","Shauna",ircsock=self.ircsock, channel=settings.channel,greeters=settings.channel_greeters) # Replace this with actual ping message