gyms.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:TrainerDex-RedCog 作者: TrainerDex 项目源码 文件源码
def gym(self, ctx, *, gym: str):
        """
        Lookup a gym, responds with an image, title, description and a google maps link.
        Gyms that have active raids are prioritized over gyms that do not.
        """
        hit, monacle_gym = await self.find_gym(gym)
        if not hit:
            return
        description = "{}\n[Get Directions](https://www.google.com/maps/?daddr={},{})".format(hit.description, hit.latitude, hit.longitude)
        embed=discord.Embed(title=hit.title, url='https://www.pokemongomap.info'+hit.url, description=description)
        embed.set_thumbnail(url=hit.image)
        if monacle_gym:
            embed.set_image(url='https://maps.googleapis.com/maps/api/staticmap?center={0},{1}&zoom=15&size=250x125&maptype=roadmap&markers=color:{3}%7C{0},{1}&key={2}'.format(hit.latitude, hit.longitude, 'AIzaSyCEadifeA8X02v2OKv-orZWm8nQf1Q2EZ4', "0x{:02X}".format(TEAM_COLORS[monacle_gym.team])))
            embed.color = TEAM_COLORS[monacle_gym.team]
            if monacle_gym.slots_available > 0:
                embed.add_field(name='Slots available', value=monacle_gym.slots_available)
            embed.add_field(name='Owned by', value=monacle_gym.team_name)
            if monacle_gym.raid_start and monacle_gym.raid_start <= datetime.datetime.now() and monacle_gym.raid_end >= datetime.datetime.now():
                embed.add_field(name='Raid level', value=monacle_gym.raid_level)
                embed.add_field(name='Raid Pokemon', value=monacle_gym.raid_pokemon.name)
                embed.add_field(name='CP', value=monacle_gym.raid_pokemon.cp)
                embed.add_field(name='Moveset', value=MOVES[monacle_gym.raid_pokemon.move_1]+' / '+MOVES[monacle_gym.raid_pokemon.move_2])
                embed.add_field(name='Started at', value=monacle_gym.raid_start.strftime("%H:%M:%S"))
                embed.add_field(name='Ends at', value="{} ({})".format(monacle_gym.raid_end.strftime("%H:%M:%S"), humanize.naturaltime(datetime.datetime.now()-monacle_gym.raid_end)))
        else:
            embed.set_image(url='https://maps.googleapis.com/maps/api/staticmap?center={0},{1}&zoom=15&size=250x125&maptype=roadmap&markers=color:{3}%7C{0},{1}&key={2}'.format(hit.latitude, hit.longitude, 'AIzaSyCEadifeA8X02v2OKv-orZWm8nQf1Q2EZ4', 'white'))

        await self.bot.say(embed=embed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号