Support discord and slack group msg
This commit is contained in:
@@ -136,7 +136,7 @@ class AgentMsg:
|
|||||||
resp_msg.create_time = time.time()
|
resp_msg.create_time = time.time()
|
||||||
|
|
||||||
resp_msg.rely_msg_id = self.msg_id
|
resp_msg.rely_msg_id = self.msg_id
|
||||||
resp_msg.target = self.target
|
resp_msg.target = self.sender
|
||||||
resp_msg.sender = sender_id
|
resp_msg.sender = sender_id
|
||||||
resp_msg.body = resp_body
|
resp_msg.body = resp_body
|
||||||
resp_msg.topic = self.topic
|
resp_msg.topic = self.topic
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from typing import Optional
|
|||||||
|
|
||||||
from aios import KnowledgeStore, ObjectType
|
from aios import KnowledgeStore, ObjectType
|
||||||
from aios.frame.tunnel import AgentTunnel
|
from aios.frame.tunnel import AgentTunnel
|
||||||
from aios.proto.agent_msg import AgentMsg
|
from aios.proto.agent_msg import AgentMsg, AgentMsgType
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
from aios.storage.storage import AIStorage
|
from aios.storage.storage import AIStorage
|
||||||
@@ -96,10 +96,6 @@ class DiscordTunnel(AgentTunnel):
|
|||||||
if message.author == self.client.user:
|
if message.author == self.client.user:
|
||||||
return
|
return
|
||||||
|
|
||||||
if len(message.channel.members) > 2:
|
|
||||||
if self.client.user not in message.mentions:
|
|
||||||
return
|
|
||||||
|
|
||||||
content = re.sub("<@.+>", "", message.content).strip()
|
content = re.sub("<@.+>", "", message.content).strip()
|
||||||
|
|
||||||
attach_type = None
|
attach_type = None
|
||||||
@@ -142,6 +138,10 @@ class DiscordTunnel(AgentTunnel):
|
|||||||
agent_msg.sender = message.author.name
|
agent_msg.sender = message.author.name
|
||||||
self.ai_bus.register_message_handler(agent_msg.sender, self._process_message)
|
self.ai_bus.register_message_handler(agent_msg.sender, self._process_message)
|
||||||
|
|
||||||
|
if len(message.channel.members) > 2:
|
||||||
|
if self.client.user not in message.mentions:
|
||||||
|
agent_msg.msg_type = AgentMsgType.TYPE_GROUP_MSG
|
||||||
|
|
||||||
if attach_type is None:
|
if attach_type is None:
|
||||||
agent_msg.body = content
|
agent_msg.body = content
|
||||||
elif attach_type == "image":
|
elif attach_type == "image":
|
||||||
@@ -163,7 +163,6 @@ class DiscordTunnel(AgentTunnel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if len(resp_msg.body) < 1:
|
if len(resp_msg.body) < 1:
|
||||||
await message.channel.send("")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
knownledge_object = KnowledgeStore().parse_object_in_message(resp_msg.body)
|
knownledge_object = KnowledgeStore().parse_object_in_message(resp_msg.body)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from slack_bolt.app.async_app import AsyncApp
|
|||||||
|
|
||||||
from aios import KnowledgeStore, ObjectType
|
from aios import KnowledgeStore, ObjectType
|
||||||
from aios.frame.tunnel import AgentTunnel
|
from aios.frame.tunnel import AgentTunnel
|
||||||
from aios.proto.agent_msg import AgentMsg
|
from aios.proto.agent_msg import AgentMsg, AgentMsgType
|
||||||
from aios.storage.storage import AIStorage
|
from aios.storage.storage import AIStorage
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -162,7 +162,7 @@ class SlackTunnel(AgentTunnel):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if not is_metion:
|
if not is_metion:
|
||||||
return
|
agent_msg.msg_type = AgentMsgType.TYPE_GROUPMSG
|
||||||
|
|
||||||
if file_type is None:
|
if file_type is None:
|
||||||
agent_msg.body = content
|
agent_msg.body = content
|
||||||
@@ -186,7 +186,6 @@ class SlackTunnel(AgentTunnel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if len(resp_msg.body) < 1:
|
if len(resp_msg.body) < 1:
|
||||||
await app.client.chat_postMessage(channel=event["channel"], text=f"")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
knownledge_object = KnowledgeStore().parse_object_in_message(resp_msg.body)
|
knownledge_object = KnowledgeStore().parse_object_in_message(resp_msg.body)
|
||||||
|
|||||||
Reference in New Issue
Block a user