From b60ac863b4c947d1ef8d611ec1bac0e7a52541ec Mon Sep 17 00:00:00 2001 From: zhanhuasheng Date: Fri, 8 Mar 2024 09:50:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=B8=8D=E5=90=8C=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utils/websocket_handler.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/Utils/websocket_handler.py b/Utils/websocket_handler.py index 7b2652d..9c844e5 100644 --- a/Utils/websocket_handler.py +++ b/Utils/websocket_handler.py @@ -95,24 +95,14 @@ async def ws_action(ws,case): async def ws_send_handler(case,ws): data = case['data'] # 消息数据 - msgType = 'newstext' if data['type'] in ['text', 'emoji']: content = r'{"contentList":"%s","attachmentList":[]}' % data['content'] - elif data['type'] == 'image': - content = "{\"contentList\":\"

\",\"attachmentList\":[]}"%livechatData.imgSrc - elif data['type'] == 'file': - content = r'{"contentList":"","attachmentList":[{"src":"%s","blobSrc":"%s","name":"新建 文本文档.txt","size":0,"type":"text/plain"}]}'%(livechatData.fileSrc,livechatData.fileSrc) - elif data['type'] == 'article': - content = r'{"contentList":"
article title

article_detail

View all →
","attachmentList":[]}' %data['content'] - elif data['type'] == 'rate': - content = r'[&*{"reviewContent":"%s","thumbsReviews":{"good":"","bad":"FeedbackURL"},"startReviews":{"one_start":"FeedbackURL","two_start":"FeedbackURL","three_start":"FeedbackURL","four_start":"","five_start":"www.baidu.com"},"reviewTitle":"%s","reviewChoose":"thumbs","askSendReview":"true","autoSendReview":"false","primaryColor":"#2C23E5"}]'%(livechatData.rateContent,livechatData.rateTitle) + else: + content = getattr(livechatData,data['type']) + if data['type'] != 'rate': + msgType = 'newstext' + else: msgType = 'rate' - elif data['type'] == 'link': - content = "{\"contentList\":\"%s\",\"attachmentList\":[]}"%(livechatData.linkHref,livechatData.linkTitle) - elif data['type'] == 'product': - content = "{\"contentList\":\"
Selling Plans Ski Wax
\",\"attachmentList\":[]}" - elif data['type'] == 'coupon': - content = r'{"contentList":"优惠券","attachmentList":[]}' fromId = data['fromId'] if data.get('fromId') else getattr(Global, 'customerId') siteId = data['siteId'] if data.get('siteId') else getattr(Global, 'shopId') uid = data['uid'] if data.get('uid') else getattr(Global, 'userId') -- GitLab