meta.py 文件源码

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

项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码
def github_source(self, ctx, *, command: BotCommand = None):
        """Displays the github link for the source code of a particular command.

        Keep in mind that although this is less spammy. It may be inaccurate or
        even in a completely different place if last-minute changes were applied
        to the code and weren't pushed to GitHub.

        If you truly want the most accurate code, use `{prefix}source`.
        """
        source_url = f'https://github.com/Ikusaba-san/Chiaki-Nanami/tree/dev'
        if command is None: 
            return await ctx.send(source_url)

        src = command.callback.__code__
        lines, firstlineno = inspect.getsourcelines(src)
        lastline = firstlineno + len(lines) - 1
        # We don't use the built-in commands so we can eliminate this branch
        location = os.path.relpath(src.co_filename).replace('\\', '/')

        url = f'<{source_url}/{location}#L{firstlineno}-L{lastline}>'
        await ctx.send(url)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号