fix: ActionFailed
This commit is contained in:
parent
32547397c3
commit
147f66cd91
@ -10,7 +10,7 @@ from typing import Any, BinaryIO, Dict, List, Optional, Tuple, Union
|
|||||||
|
|
||||||
import aiocqhttp
|
import aiocqhttp
|
||||||
from aiocqhttp import CQHttp, Event
|
from aiocqhttp import CQHttp, Event
|
||||||
from aiocqhttp.exceptions import NetworkError
|
from aiocqhttp.exceptions import NetworkError, ActionFailed
|
||||||
from efb_qq_slave import BaseClient, QQMessengerChannel
|
from efb_qq_slave import BaseClient, QQMessengerChannel
|
||||||
from ehforwarderbot import Chat, Message, MsgType, Status, coordinator
|
from ehforwarderbot import Chat, Message, MsgType, Status, coordinator
|
||||||
from ehforwarderbot.chat import (
|
from ehforwarderbot.chat import (
|
||||||
@ -476,15 +476,15 @@ class GoCQHttp(BaseClient):
|
|||||||
group_info = await self.get_group_info(context["group_id"])
|
group_info = await self.get_group_info(context["group_id"])
|
||||||
context["uid_prefix"] = "group_request"
|
context["uid_prefix"] = "group_request"
|
||||||
context["group_name"] = "[Request]" + group_info["group_name"]
|
context["group_name"] = "[Request]" + group_info["group_name"]
|
||||||
context["group_id"] = str(context["group_id"]) + "_notification"
|
group_name = group_id = context["group_id"]
|
||||||
|
context["group_id"] = str(group_id) + "_notification"
|
||||||
context["message_type"] = "group"
|
context["message_type"] = "group"
|
||||||
context["event_description"] = "\u2139 New Group Join Request"
|
context["event_description"] = "\u2139 New Group Join Request"
|
||||||
original_group = await self.get_group_info(context["group_id"], False)
|
original_group = await self.get_group_info(group_id, False)
|
||||||
group_name = context["group_id"]
|
|
||||||
if original_group is not None and "group_name" in original_group:
|
if original_group is not None and "group_name" in original_group:
|
||||||
group_name = original_group["group_name"]
|
group_name = original_group["group_name"]
|
||||||
msg = Message()
|
msg = Message()
|
||||||
msg.uid = "group" + "_" + str(context["group_id"])
|
msg.uid = "group" + "_" + context["group_id"]
|
||||||
msg.author = (self.chat_manager.build_efb_chat_as_system_user(context)).other
|
msg.author = (self.chat_manager.build_efb_chat_as_system_user(context)).other
|
||||||
msg.chat = await self.chat_manager.build_efb_chat_as_group(context)
|
msg.chat = await self.chat_manager.build_efb_chat_as_group(context)
|
||||||
msg.deliver_to = coordinator.master
|
msg.deliver_to = coordinator.master
|
||||||
@ -502,7 +502,7 @@ class GoCQHttp(BaseClient):
|
|||||||
context["user_id"],
|
context["user_id"],
|
||||||
)
|
)
|
||||||
msg.text = "{} wants to join the group {}({}). \nHere is the comment: {}".format(
|
msg.text = "{} wants to join the group {}({}). \nHere is the comment: {}".format(
|
||||||
name, group_name, context["group_id"], context["comment"]
|
name, group_name, group_id, context["comment"]
|
||||||
)
|
)
|
||||||
msg.commands = MessageCommands(
|
msg.commands = MessageCommands(
|
||||||
[
|
[
|
||||||
@ -1033,6 +1033,10 @@ class GoCQHttp(BaseClient):
|
|||||||
res = result == "accept"
|
res = result == "accept"
|
||||||
try:
|
try:
|
||||||
self.coolq_bot.sync.set_friend_add_request(flag=flag, approve=res)
|
self.coolq_bot.sync.set_friend_add_request(flag=flag, approve=res)
|
||||||
|
except ActionFailed as e:
|
||||||
|
if e.retcode == 100:
|
||||||
|
return "Processed By Other Clients"
|
||||||
|
return "Failed to process request! Error Message:\n" + getattr(e, "message", repr(e))
|
||||||
except CoolQAPIFailureException as e:
|
except CoolQAPIFailureException as e:
|
||||||
return "Failed to process request! Error Message:\n" + getattr(e, "message", repr(e))
|
return "Failed to process request! Error Message:\n" + getattr(e, "message", repr(e))
|
||||||
return "Done"
|
return "Done"
|
||||||
@ -1041,6 +1045,10 @@ class GoCQHttp(BaseClient):
|
|||||||
res = result == "accept"
|
res = result == "accept"
|
||||||
try:
|
try:
|
||||||
self.coolq_bot.sync.set_group_add_request(flag=flag, approve=res, sub_type=sub_type)
|
self.coolq_bot.sync.set_group_add_request(flag=flag, approve=res, sub_type=sub_type)
|
||||||
|
except ActionFailed as e:
|
||||||
|
if e.retcode == 100:
|
||||||
|
return "Processed By Other Admins"
|
||||||
|
return "Failed to process request! Error Message:\n" + getattr(e, "message", repr(e))
|
||||||
except CoolQAPIFailureException as e:
|
except CoolQAPIFailureException as e:
|
||||||
return "Failed to process request! Error Message:\n" + getattr(e, "message", repr(e))
|
return "Failed to process request! Error Message:\n" + getattr(e, "message", repr(e))
|
||||||
return "Done"
|
return "Done"
|
||||||
|
Loading…
Reference in New Issue
Block a user