diff --git a/cmds.py b/cmds.py index 23e4a40..a2d184b 100644 --- a/cmds.py +++ b/cmds.py @@ -70,30 +70,31 @@ def cmds(app, data): action="store_true") args = parser.parse_args(sqt.args) + reply = ReplyMessage(id=sqt.message_id) e: AsyncEnforcer = sqt.app.ctx.e msg = '' if args.addgroup: if args.group and args.command: if await e.add_policy(args.group, args.command): - msg = Message(content=f'添加成功:p, {args.group}, {args.command}', room_id=sqt.room_id) + msg = Message(content=f'添加成功:p, {args.group}, {args.command}', room_id=sqt.room_id, reply_to=reply) else: - msg = Message(content='添加失败,用户组已存在或其它错误', room_id=sqt.room_id) + msg = Message(content='添加失败,用户组已存在或其它错误', room_id=sqt.room_id, reply_to=reply) else: - msg = Message(content='缺失参数,请使用-h查看帮助', room_id=sqt.room_id) + msg = Message(content='缺失参数,请使用-h查看帮助', room_id=sqt.room_id, reply_to=reply) if args.adduser: if args.group: if await e.add_role_for_user(str(args.user or sqt.room_id), args.group): - msg = Message(content=f'添加成功:g, {args.user or sqt.room_id}, {args.group}', room_id=sqt.room_id) + msg = Message(content=f'添加成功:g, {args.user or sqt.room_id}, {args.group}', room_id=sqt.room_id, reply_to=reply) else: - msg = Message(content='添加失败,用户已在组内或其它错误', room_id=sqt.room_id) + msg = Message(content='添加失败,用户已在组内或其它错误', room_id=sqt.room_id, reply_to=reply) else: - msg = Message(content='缺失参数,请使用-h查看帮助', room_id=sqt.room_id) + msg = Message(content='缺失参数,请使用-h查看帮助', room_id=sqt.room_id, reply_to=reply) if len(sqt.args) == 0: parser.parse_args(["-h"]) else: if msg == '': - msg = Message(content='参数错误,请使用-h查看帮助', room_id=sqt.room_id) + msg = Message(content='参数错误,请使用-h查看帮助', room_id=sqt.room_id, reply_to=reply) await sqt.app.ctx.sio.emit('sendMessage', msg.to_json()) await e.save_policy() @@ -113,25 +114,25 @@ def cmds(app, data): if args.rmgroup: if args.group and args.command: if await e.remove_policy(args.group, args.command): - msg = Message(content=f'移除成功:p, {args.group}, {args.command}', room_id=sqt.room_id) + msg = Message(content=f'移除成功:p, {args.group}, {args.command}', room_id=sqt.room_id, reply_to=reply) else: - msg = Message(content='移除失败,用户组已存在或其它错误', room_id=sqt.room_id) + msg = Message(content='移除失败,用户组已存在或其它错误', room_id=sqt.room_id, reply_to=reply) else: - msg = Message(content='缺失参数,请使用-h查看帮助', room_id=sqt.room_id) + msg = Message(content='缺失参数,请使用-h查看帮助', room_id=sqt.room_id, reply_to=reply) if args.rmuser: if args.group: if await e.delete_role_for_user(str(args.user or sqt.room_id), args.group): - msg = Message(content=f'移除成功:g, {args.user or sqt.room_id}, {args.group}', room_id=sqt.room_id) + msg = Message(content=f'移除成功:g, {args.user or sqt.room_id}, {args.group}', room_id=sqt.room_id, reply_to=reply) else: - msg = Message(content='移除失败,用户已在组内或其它错误', room_id=sqt.room_id) + msg = Message(content='移除失败,用户已在组内或其它错误', room_id=sqt.room_id, reply_to=reply) else: - msg = Message(content='缺失参数,请使用-h查看帮助', room_id=sqt.room_id) + msg = Message(content='缺失参数,请使用-h查看帮助', room_id=sqt.room_id, reply_to=reply) if len(sqt.args) == 0: parser.parse_args(["-h"]) else: if msg == '': - msg = Message(content='参数错误,请使用-h查看帮助', room_id=sqt.room_id) + msg = Message(content='参数错误,请使用-h查看帮助', room_id=sqt.room_id, reply_to=reply) await sqt.app.ctx.sio.emit('sendMessage', msg.to_json()) await e.save_policy()