image.py 文件源码

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

项目:KeekoBot 作者: DavidNeon 项目源码 文件源码
def gif(self, *text):
        """Retrieves first search result from giphy

        gif [keyword]"""
        if len(text) > 0:
            if len(text[0]) > 1 and len(text[0]) < 20:
                try:
                    msg = "+".join(text)
                    search = "http://api.giphy.com/v1/gifs/search?q=" + msg + "&api_key=dc6zaTOxFJmzC"
                    async with aiohttp.get(search) as r:
                        result = await r.json()
                    if result["data"] != []:
                        url = result["data"][0]["url"]
                        await self.bot.say(url)
                    else:
                        await self.bot.say("Your search terms gave no results.")
                except:
                    await self.bot.say("Error.")
            else:
                await self.bot.say("Invalid search.")
        else:
            await self.bot.say("gif [text]")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号