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
评论列表
文章目录