def maple_weapons_info(self, *search_terms): """Finds stats and drop locations for a Maple Weapon. Please note that level 77 Maple Pyrope Weapons \ are events only, and thus not available for searching.""" if any(['pyrope' in keyword.lower() for keyword in search_terms]): yield from self.b.say(msg('maple_weapons_info.pyrope')) return result = self.hiddenstreet.maple_weapon_by_name(*search_terms) if len(result) == 0: yield from self.b.say(msg('maple_weapons_info.no results').format(keyword=' '.join(search_terms), **settings.BOT)) elif len(result) > 3: yield from self.b.say(msg('maple_weapons_info.too many').format(**settings.BOT)) else: log.debug('gotten {} records from backend'.format(len(result))) library_link = 'https://mapleroyals.com/library/?page=items&id={}' img_template = 'https://mapleroyals.com/library/images/item/{:08d}.png' for maple_weapon in result: log.debug(maple_weapon) d = maple_weapon.to_dict if maple_weapon.weapon_type in ['STAFF', 'WAND']: d['magic_attack_string'] = ' **Magic Attack** ' + maple_weapon.magic_attack else: d['magic_attack_string'] = '' d['library_link'] = library_link.format(maple_weapon.id_weapon) d['image_link'] = img_template.format(maple_weapon.id_weapon) yield from self.b.say(msg('maple_weapons_info.result').format(**d))
def monster_stats(self, *words): """Finds stats for a monster put --exact (or -e for short) to \ have the exact match for the name you're looking for. Data is by kind \ concession from http://bbb.hidden-street.net/""" flag = words[0] in ['--exact', '-e'] if flag: name = ' '.join(words[1:]) else: name = ' '.join(words) result = self.hiddenstreet.monsters_by_name(name, exact_match=flag) if len(result) == 0: yield from self.b.say(msg('monster_stats.no results').format(name)) elif len(result) > 3: n = '", "'.join([m.name for m in result]) yield from self.b.say(msg('monster_stats.too many').format(n)) else: for monster in result: if monster.experience: monster.experience *= 4 mdict = monster.to_dict mdict['link'] = 'http://bbb.hidden-street.net/monster/{}'.format( monster.name.lower().replace(' ', '-').replace('\'', '')) message = msg('monster_stats.result').format(**mdict) if monster.image_url: message += '\n{}'.format(monster.image_url) yield from self.b.say(message)
def repeat(self, times: int, *content): """Repeats a message multiple times.""" if times > 5: yield from self.b.say(msg("repeat.no way")) else: for i in range(times): yield from self.b.say(" ".join(content))
def format_pierre_interval(hours: int, minutes: int, seconds: int) -> str: hours, minutes, seconds = [int(round(n)) for n in (hours, minutes, seconds)] if seconds == 60: minutes += 1 seconds = 0 if minutes == 60: hours += 1 minutes = 0 suffix = ''.join([n for n, t in (('h', hours), ('m', minutes), ('s', seconds)) if t > 0]) fmt = msg('pierre.respawn.{}'.format(suffix)) data = dict(h_time=hours, hour=msg('time.hours' if hours > 1 else 'time.hour'), m_time=minutes, minute=msg('time.minutes' if minutes > 1 else 'time.minute'), s_time=seconds, second=msg('time.seconds' if seconds > 1 else 'time.second')) return fmt.format(**data)
def maple_list_info(self, weapon_level: int=None): """Prints a simple list for all the Maple Weapons currently available in game.""" result = self.hiddenstreet.maple_list_by_level(weapon_level) log.debug('gotten {} records from backend'.format(len(result))) for w in result: yield from self.b.say(msg('maple_list_info.result').format(required_level=w.required_level, names=w.names))
def roll(self, dice: str): """Rolls a dice in NdN format.""" try: rolls, limit = map(int, dice.split("d")) except Exception: yield from self.b.say(msg("roll.wrong format")) return result = ", ".join(str(random.randint(1, limit)) for r in range(rolls)) yield from self.b.say(result)
def _bot(self): """Is the bot cool?""" yield from self.b.say(msg("cool.yes"))
def cool(self, ctx: Context): """Says if a user is cool. In reality this just checks if a subcommand is being invoked. """ if ctx.invoked_subcommand is None: yield from self.b.say(msg("cool.no").format(ctx))