helper.py 文件源码

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

项目:dogbot 作者: moondropx 项目源码 文件源码
def unalias_command(bot, message):
    """#unalias [-h] ??

    -h  : ?????
    ?? : ??????
    """

    try:
        cmd, *args = shlex.split(message.text)
    except ValueError:
        return False
    if not cmd[0] in config['trigger']:
        return False
    if not cmd[1:] == 'unalias':
        return False
    try:
        options, args = getopt.gnu_getopt(args, 'hd:')
    except getopt.GetoptError:
        # ????
        reply(bot, message, unalias_command.__doc__)
        return True

    origin = None

    for o, a in options:
        if o == '-h':
            # ??
            reply(bot, message, unalias_command.__doc__)
            return True

    # ??????
    if not args:
        reply(bot, message, unalias_command.__doc__)
        return True

    command = args[0]
    alias = Alias.objects(alias=command)

    if not alias:
        reply(bot, message, '?????{}'.format(command))

    reply(bot, message, '????? {} => {}'.format(alias.alias, alias.origin))
    alias.delete()
    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号