選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

dingtalk_message.py 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from bridge.context import ContextType
  2. from channel.chat_message import ChatMessage
  3. import json
  4. import requests
  5. from common.log import logger
  6. from common.tmp_dir import TmpDir
  7. from common import utils
  8. from dingtalk_stream import ChatbotMessage
  9. class DingTalkMessage(ChatMessage):
  10. def __init__(self, event: ChatbotMessage):
  11. super().__init__(event)
  12. self.msg_id = event.message_id
  13. msg_type = event.message_type
  14. self.incoming_message =event
  15. self.sender_staff_id = event.sender_staff_id
  16. self.other_user_id = event.conversation_id
  17. self.create_time = event.create_at
  18. if event.conversation_type=="1":
  19. self.is_group = False
  20. else:
  21. self.is_group = True
  22. if msg_type == "text":
  23. self.ctype = ContextType.TEXT
  24. self.content = event.text.content.strip()
  25. elif msg_type == "audio":
  26. # 钉钉支持直接识别语音,所以此处将直接提取文字,当文字处理
  27. self.content = event.extensions['content']['recognition'].strip()
  28. self.ctype = ContextType.TEXT
  29. self.from_user_id = event.sender_id
  30. self.to_user_id = event.chatbot_user_id
  31. self.other_user_nickname = event.conversation_title
  32. user_id = event.sender_id
  33. nickname =event.sender_nick