Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
willdesk_apiauto
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
29
Issues
29
List
Boards
Labels
Service Desk
Milestones
Merge Requests
29
Merge Requests
29
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
桦生 詹
willdesk_apiauto
Commits
b60ac863
Commit
b60ac863
authored
Mar 08, 2024
by
zhanhuasheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兼容不同消息类型
parent
c8af987e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
15 deletions
+5
-15
Utils/websocket_handler.py
Utils/websocket_handler.py
+5
-15
No files found.
Utils/websocket_handler.py
View file @
b60ac863
...
...
@@ -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
\"
:
\"
<div data-type=
\\\"
willdesk-image
\\\"
class=
\\\"
willdesk-chat-image
\\\"
contenteditable=
\\\"
false
\\\"
><img src=
\\\"
%s
\\\"
data-width=
\\\"
64
\\\"
data-height=
\\\"
64
\\\"
data-size=
\\\"
1268
\\\"
data-chattagtype=
\\\"
wd-img
\\\"
style=
\\\"
max-height: 200px; max-width: 200px; vertical-align: bottom; margin: 2px 0px; border-radius: 4px; width: 64px; height: 64px;
\\\"
></div> <br>
\"
,
\"
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":"<div data-type="willdesk-faq" style="background: rgb(255, 255, 255); border-radius: 8px; min-width: 230px; max-width: 100%; width: 300px; box-sizing: border-box; position: relative; border: 0.5px solid rgb(229, 229, 235);"><div style="padding: 12px 16px 0px; color: rgb(18, 17, 39); font-size: 16px; font-weight: 600; line-height: 24px; overflow: hidden; display: -webkit-box; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">article title</div><div style="padding: 4px 16px 12px; color: rgb(108, 107, 128); font-size: 14px; max-height: 48px; font-weight: 400; line-height: 24px; overflow: hidden; display: -webkit-box; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2;"><p>article_detail</p></div><a href="%s" title="faq" target="_blank" style="box-sizing: border-box; margin-top: 8px; text-decoration: none; padding: 8px 16px; background: rgb(243, 243, 246); color: rgb(44, 35, 229); font-size: 14px; font-family: Inter; line-height: 22px; width: 100%; border-radius: 0px 0px 8px 8px; display: inline-block;">View all →</a></div>","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
\"
:
\"
<a class=
\\\"
wd-chat-link
\\\"
data-type=
\\\"
willdesk-link
\\\"
href=
\\\"
%s
\\\"
contenteditable=
\\\"
false
\\\"
target=
\\\"
_blank
\\\"
>%s</a>
\"
,
\"
attachmentList
\"
:[]}"
%
(
livechatData
.
linkHref
,
livechatData
.
linkTitle
)
elif
data
[
'type'
]
==
'product'
:
content
=
"{
\"
contentList
\"
:
\"
<a href=
\\\"
https://zhs-test.myshopify.com/products/selling-plans-ski-wax
\\\"
title=
\\\"
https://zhs-test.myshopify.com/products/selling-plans-ski-wax
\\\"
data-type=
\\\"
willdesk-product
\\\"
target=
\\\"
_blank
\\\"
style=
\\\"
display: flex; background: rgb(255, 255, 255); border-radius: 8px; min-height: 80px; max-height: 150px; min-width: 100px; max-width: 100%; width: 300px; box-sizing: border-box; position: relative; text-decoration: none; padding: 12px 16px; border: 1px solid rgb(231, 233, 236);
\\\"
><img src=
\\\"
https://cdn.shopify.com/s/files/1/0690/4551/8586/products/snowboard_wax.png?v=1708331992
\\\"
style=
\\\"
width: 110px; height: 110px; max-height: 150px; object-fit: cover; border-radius: 8px; margin-right: 4%; flex-shrink: 0; border: 0.5px solid rgb(231, 233, 236);
\\\"
><div style=
\\\"
width: calc(100% - 118px); display: flex; flex-direction: column; position: relative; justify-content: center;
\\\"
><div style=
\\\"
width: 100%; max-height: 48px; line-height: 24px; color: rgb(18, 17, 39); font-size: 14px; font-weight: bold; overflow: hidden; display: -webkit-box; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
\\\"
>Selling Plans Ski Wax</div></div></a>
\"
,
\"
attachmentList
\"
:[]}"
elif
data
[
'type'
]
==
'coupon'
:
content
=
r
'{"contentList":"<a class="wd-chat-link" data-type="willdesk-link" href="https://tt-zldev003.myshopify.com/discount/V-0QE73BP5" contenteditable="false" style="margin-right: 8px" target="_blank">优惠券</a>","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'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment