tags.py 文件源码

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

项目:PyMiki 作者: TheGrammarJew 项目源码 文件源码
def raw(self, ctx, *, name: TagName(lower=True)):
        """Gets the raw content of the tag.

        This is with markdown escaped. Useful for editing.
        """

        try:
            tag = await self.get_tag(ctx.guild.id, name, connection=ctx.db)
        except RuntimeError as e:
            return await ctx.send(e)

        transformations = {
            re.escape(c): '\\' + c
            for c in ('*', '`', '_', '~', '\\', '<')
        }

        def replace(obj):
            return transformations.get(re.escape(obj.group(0)), '')

        pattern = re.compile('|'.join(transformations.keys()))
        await ctx.send(pattern.sub(replace, tag['content']))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号