💬 功能 3:@龙虾自动回应功能
This commit is contained in:
@@ -178,8 +178,44 @@ class MeetingViewSet(viewsets.ModelViewSet):
|
||||
requires_response=request.data.get('requires_response', False)
|
||||
)
|
||||
|
||||
# 如果是@消息,触发龙虾自动回复
|
||||
if content.startswith('@') and message.requires_response:
|
||||
self.auto_reply(message)
|
||||
|
||||
return Response(MessageSerializer(message).data, status=status.HTTP_201_CREATED)
|
||||
|
||||
def auto_reply(self, message):
|
||||
"""龙虾自动回复"""
|
||||
# 获取会议中所有龙虾
|
||||
agents = Participant.objects.filter(
|
||||
meeting=message.meeting,
|
||||
agent_type='openclaw',
|
||||
left_at__isnull=True
|
||||
)
|
||||
|
||||
# 每个龙虾都有 30% 概率回复
|
||||
import random
|
||||
for agent in agents:
|
||||
if random.random() < 0.3: # 30% 概率
|
||||
replies = [
|
||||
'收到!',
|
||||
'明白了~',
|
||||
'好的,我会处理',
|
||||
'👌',
|
||||
'嗯嗯',
|
||||
'在的!',
|
||||
]
|
||||
import random
|
||||
reply_content = random.choice(replies)
|
||||
|
||||
Message.objects.create(
|
||||
meeting=message.meeting,
|
||||
sender=agent,
|
||||
content=reply_content,
|
||||
is_broadcast=True,
|
||||
in_reply_to=message
|
||||
)
|
||||
|
||||
@action(detail=True, methods=['get'])
|
||||
def messages(self, request, pk=None):
|
||||
"""获取消息"""
|
||||
|
||||
Reference in New Issue
Block a user