def cron_topic(self): """Change the topic each minute on demand""" try: data = yield from spaceapi(self.bot) current_topic = yield from self.bot.async_cmds.topic( self.bot.config.autojoins[0] ) topic = self.config['topic'] if data['state']['open']: topic += u' | Space is open' status = 'open' else: topic += u' | Space is closed' status = 'closed' try: old_status = re.search('Space is (open|closed)', current_topic['topic']) old_status = old_status.group(1) except Exception as e: old_status = 'closed' if old_status != status: self.bot.topic(self.bot.config.autojoins[0], topic) except Exception as e: self.bot.log.error(e)
def cron_topic(self): """Change the topic each minute on demand""" try: data = yield from spaceapi(self.bot) current_topic = yield from self.bot.async_cmds.topic( self.bot.config.autojoins[0]) topic = self.config['topic'] if data['state']['open']: topic += u' | Space is open' status = 'open' else: topic += u' | Space is closed' status = 'closed' try: old_status = re.search('Space is (open|closed)', current_topic['topic']) old_status = old_status.group(1) except Exception as e: old_status = 'closed' if old_status != status: self.bot.topic(self.bot.config.autojoins[0], topic) except Exception as e: self.bot.log.error(e)
def status(bot, mask, target, args): """Returns the door status of the hackerspace rooms %%status """ try: data = yield from spaceapi(bot, target) bot.privmsg(target, 'Space status:') if data['state']['open']: bot.privmsg(target, '\tThe space is open!') else: bot.privmsg(target, '\tThe space is closed!') except Exception as e: bot.log.error(e) bot.privmsg(target, '\tError while retrieving space status')
def users(bot, mask, target, args): """Returns the current users inside the hackerspace rooms %%users """ try: data = yield from spaceapi(bot, target) data = data['sensors']['people_now_present'][0] if data['value'] > 0: bot.privmsg(target, 'Space users: ' + str(', '.join(data['names']))) elif data['value'] == 0: bot.privmsg(target, 'Nobody is logged into teh space :(') else: bot.privmsg(target, "I'm not sure if anyone's in the space") except Exception as e: bot.log.error(e) bot.privmsg(target, '\tError while retrieving user data')