Skip to content

Commit 0f35e8d

Browse files
author
devin
committed
fix: 修复 webhook 更新后参数重复问题
1 parent e010ea2 commit 0f35e8d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

dingtalkchatbot/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__title__ = 'DingtalkChatbot'
22
__description__ = '一个钉钉自定义机器人消息的Python封装库'
33
__url__ = 'https://github.com/zhuifengshen/DingtalkChatbot'
4-
__version__ = '1.5.2'
4+
__version__ = '1.5.3'
55
__author__ = 'devin'
66
__author_email__ = '[email protected]'
77
__license__ = 'MIT'

dingtalkchatbot/chatbot.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ def update_webhook(self):
8989
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
9090

9191
sign = quote_plus(base64.b64encode(hmac_code))
92-
self.webhook = '{}&timestamp={}&sign={}'.format(self.webhook, str(timestamp), sign)
93-
94-
92+
if 'timestamp'in self.webhook:
93+
self.webhook = '{}&timestamp={}&sign={}'.format(self.webhook[:self.webhook.find('&timestamp')], str(timestamp), sign)
94+
else:
95+
self.webhook = '{}&timestamp={}&sign={}'.format(self.webhook, str(timestamp), sign)
9596

9697
def msg_open_type(self, url):
9798
"""
@@ -437,6 +438,7 @@ def get_data(self):
437438
class CardItem(object):
438439
"""
439440
ActionCard和FeedCard消息类型中的子控件
441+
440442
注意:
441443
1、发送FeedCard消息时,参数pic_url必须传入参数值;
442444
2、发送ActionCard消息时,参数pic_url不需要传入参数值;

0 commit comments

Comments
 (0)