def test_format_release(self): release = { "tag_name": "v1.0.0", "published_at": "2019-04-06T13:04:26Z" } expected = "New release available: v1.0.0 (Apr 06 2019): https://git.io/fjIDk" formatted = format_release(release) self.assertEqual(formatted, expected)
async def watch_for_releases(self): """Starts a loop for `check_for_releases` and updates `self.new_release`.""" while True: self.new_release = await check_for_releases() if self.new_release: log.info("#" * 60) log.info(format_release(self.new_release)) log.info("#" * 60) await asyncio.sleep(86400) # 24 hrs
def on_user_login(self, user_type, verbose=True): log.info("'{username}' logged in as {user_type}", username=self.name, user_type=user_type) if user_type == 'admin': self.admin = True self.speedhack_detect = False # notify of new release to admin on /login new_release = self.protocol.new_release if user_type == 'admin' and new_release: self.send_chat("!" * 30) self.send_chat(format_release(new_release)) self.send_chat("!" * 30) self.user_types.add(user_type) rights = set(commands.get_rights(user_type)) self.rights.update(rights) if verbose: message = ' logged in as %s' % (user_type) self.send_chat('You' + message) self.protocol.irc_say("* " + self.name + message)