Skip to content

Commit e8ba03f

Browse files
author
linya.jj
committed
feat: release v0.7.5 回复任意单聊和群聊
1 parent 78729e7 commit e8ba03f

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

dingtalk_stream/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
from .frames import CallbackMessage
88
from .frames import SystemMessage
99
from .frames import AckMessage
10-
from .chatbot import ChatbotMessage, RichTextContent, ImageContent
10+
from .chatbot import ChatbotMessage, RichTextContent, ImageContent, reply_specified_single_chat, \
11+
reply_specified_group_chat
1112
from .chatbot import TextContent
1213
from .chatbot import AtUser
1314
from .chatbot import ChatbotHandler, AsyncChatbotHandler
1415
from .card_replier import AICardStatus, AICardReplier, CardReplier
15-
from .card_instance import MarkdownCardInstance, AIMarkdownCardInstance, CarouselCardInstance, MarkdownButtonCardInstance
16+
from .card_instance import MarkdownCardInstance, AIMarkdownCardInstance, CarouselCardInstance, \
17+
MarkdownButtonCardInstance
1618
from .card_callback import CardCallbackMessage, Card_Callback_Router_Topic

dingtalk_stream/card_replier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def create_and_send_card(self, card_template_id: str, card_data: dict, callback_
9292
"userIdType": 1
9393
}
9494

95-
# 2:群聊,2:单聊
95+
# 2:群聊,1:单聊
9696
if self.incoming_message.conversation_type == '2':
9797
body["openSpaceId"] = "dtv1.card//{spaceType}.{spaceId}".format(spaceType="IM_GROUP",
9898
spaceId=self.incoming_message.conversation_id)

dingtalk_stream/chatbot.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,26 @@ def __str__(self):
269269
)
270270

271271

272+
def reply_specified_single_chat(user_id: str, user_nickname: str = "") -> ChatbotMessage:
273+
d = {
274+
"senderId": user_id,
275+
"senderStaffId": user_id,
276+
"sender": user_nickname,
277+
"conversationType": '1',
278+
"messageId": str(uuid.uuid1()),
279+
}
280+
return ChatbotMessage.from_dict(d)
281+
282+
283+
def reply_specified_group_chat(open_conversation_id: str) -> ChatbotMessage:
284+
d = {
285+
"conversationId": open_conversation_id,
286+
"conversationType": '2',
287+
"messageId": str(uuid.uuid1()),
288+
}
289+
return ChatbotMessage.from_dict(d)
290+
291+
272292
class ChatbotHandler(CallbackHandler):
273293

274294
def __init__(self):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='dingtalk-stream',
5-
version='0.7.4',
5+
version='0.7.5',
66
description='A Python library for sending messages to DingTalk chatbot',
77
long_description=open('README.md').read(),
88
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)