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