epsilon.py 文件源码

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

项目:Epsilon 作者: Capuno 项目源码 文件源码
def cmd_info(message, parameters, recursion=0):
    async for msg in client.logs_from(message.channel, limit=25):
        try:
            if msg.attachments:
                image = Image.open(BytesIO(requests.get(msg.attachments[0]['url']).content)).filter(ImageFilter.SHARPEN)
                text = pytesseract.image_to_string(image)
                if not text:
                    e = discord.Embed(colour=0xB5434E)
                    e.description = "I just forgot how to read..."
                else:
                    e = discord.Embed(colour=0x43B581)
                    e.description = text
                await client.send_message(message.channel, embed=e)
                return

        except OSError:
            e = discord.Embed(colour=0xB5434E)
            e.description = "Image way big, are you trying to kill me?"
            await client.send_message(message.channel, embed=e)
            return
        except TypeError:
            e = discord.Embed(colour=0xB5434E)
            e.description = "Latest attachment is not a static image, try again."
            await client.send_message(message.channel, embed=e)
            return
        except:
            e = discord.Embed(colour=0xB5434E)
            e.description = "Error ocurred, not related to OSError or TypeError I guess."
            await client.send_message(message.channel, embed=e)
            return
    e = discord.Embed(colour=0xB5434E)
    e.description = "I can't find an image in the last 25 posts, that or I'm retarded."
    await client.send_message(message.channel, embed=e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号