sc-common-interface 2.3.6__tar.gz → 2.3.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.6
3
+ Version: 2.3.8
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -56,19 +56,23 @@ def send__live_comment(data):
56
56
  platform = "FACEBOOK"
57
57
  page_id = ""
58
58
  post_id = ""
59
+ group_id = ""
59
60
  if "page_id" in data:
60
61
  page_id = data['page_id']
61
62
  if "platform" in data:
62
63
  platform = data['platform']
63
64
  if "post_id" in data:
64
65
  post_id = data['post_id']
66
+ if "group_id" in data:
67
+ post_id = data['group_id']
65
68
  if page_id == "" or post_id == "":
66
69
  info = get_live_info(data)
67
70
  platform_list = jsonpath(info, "$..relatedPostList..platform")
68
71
  i = platform_list.index(platform)
69
72
  page_id = info["data"]["relatedPostList"][i]["page_id"]
70
73
  platform = info["data"]["relatedPostList"][i]["platform"]
71
- post_id = info["data"]["relatedPostList"][i]["post_id"]
74
+ post_id = info["data"]["relatedPostList"][i]["post_id"]
75
+ group_id = info["data"]["relatedPostList"][i]["group_id"]
72
76
  # info = get_live_info(data)
73
77
  # related_post_list = info["data"]["relatedPostList"][0]
74
78
  # page_id = related_post_list["page_id"]
@@ -95,21 +99,21 @@ def send__live_comment(data):
95
99
  "promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
96
100
  "verb": "add", "post_id": post_id, "comment_id": comment_id,
97
101
  "created_time": stamp, "parent_id": post_id}}]}]}
98
- # if platform == "FACEBOOK":
99
- # body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
100
- # "from": {"id": user_id, "name": name},
101
- # "post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
102
- # "permalink_url": "https://www.facebook.com/permalink.php?story_fbid=pfbid02jLK3e6YdFSXp2DmD7j7vtStLXoBzTi8rxKrp6jFhVMUTTEgz6qvZA8soR9Uwydd8l&id=107977035056574",
103
- # "promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
104
- # "verb": "add", "post_id": post_id, "comment_id": comment_id,
105
- # "created_time": stamp, "parent_id": post_id}}]}]}
106
- if platform == "INSTAGRAM":
102
+
103
+ if platform.upper() == "INSTAGRAM":
107
104
  body = {"entry": [{"id": page_id, "time": stamp, "changes": [{"value": {"from": {"id": user_id,
108
105
  "username": name},
109
106
  "media": {"id": post_id,
110
107
  "media_product_type": "FEED"},
111
108
  "id": comment_id, "text": keyword},
112
109
  "field": "comments"}]}], "object": "instagram"}
110
+ elif platform.upper() == "FB_GROUP":
111
+ t_time = stamp*1000
112
+ post_id = post_id.split("_")[-1]
113
+ comment_id = "%d%d" % ( stamp, num)
114
+ body = {"object":"page","entry":[{"id":page_id,"time":t_time,"messaging":[{"recipient":{"id":page_id},"message":keyword,
115
+ "from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
116
+ "verb":"add","parent_id":post_id,"field":"group_feed"}]}]}
113
117
  print(body)
114
118
  url = "%s/facebook/webhook" % env
115
119
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
@@ -392,6 +392,9 @@ def get_page_post(data):
392
392
  response =requests.get(url,headers=headers,params=params).json()
393
393
  return response
394
394
 
395
+
396
+
397
+
395
398
  def relate_post(data):
396
399
  """
397
400
  链接贴文,只链接返回的第一个可链接的贴文
@@ -1014,8 +1017,9 @@ def get_user_conversation_id(data):
1014
1017
  platform = data["platform"].lower()
1015
1018
  url = "%s/mc/conversation/id?type=%s&user_id=%s&party_channel_id=%s" % (env, platform, user_id, page_id)
1016
1019
  # param = {"type":"facebook","user_id":vars["user_id"],"party_channel_id":vars["platform_channel_id"]}
1020
+ print(url)
1017
1021
  response = requests.get(url, headers=headers).json()
1018
- # print(response)
1022
+
1019
1023
  conversation_id = jsonpath(response, "$.data.id")[0]
1020
1024
  return conversation_id,response
1021
1025
 
@@ -1561,10 +1565,75 @@ def get_mc_order_link(url):
1561
1565
  key = location.split("/")[-1].split("?")[0]
1562
1566
  return key
1563
1567
 
1568
+ def edit_message(data):
1569
+ env = data["env"]
1570
+ headers = data["headers"]
1571
+ sales_id = data["sales_id"]
1572
+ url = "%s/api/posts/post/sales/%s/keyword_message" % (env,sales_id)
1573
+ has_interaction_message = "您好,以下商品加单成功!购物车商品总金额: 请按以下按钮结账%d" % int(time.time())
1574
+ no_interaction_message_first = "您好,以下商品加单成功 !购物车商品总金额: 请按以下按钮继续」%d" % int(time.time())
1575
+ second_message = "您好,以下商品加单成功!{products} 购物车商品总金额: {total}请前往购物网站!%d" % int(time.time())
1576
+ first_message_button = "继续"
1577
+ second_message_button = "立即结帐 ️"
1578
+ need_send_message = True
1579
+ message_button = "立即结帐️"
1580
+ has_link = True
1581
+ #留言回复comment_reply
1582
+ comment_reply = True
1583
+ comment_reply_content = "testcopypost您好,谢谢你在贴文下留言订购以下商%d." % int(time.time())
1584
+ #无库存信息
1585
+ all_out_of_stock =True
1586
+ all_out_of_stock_content = "您好,{customerName},以下商品库存不足,请选购其他商品,谢谢!{products}%d" % int(time.time())
1587
+ if "has_interaction_message" in data:
1588
+ has_interaction_message = data["has_interaction_message"]
1589
+ if "no_interaction_message_first" in data:
1590
+ has_interaction_message = data["no_interaction_message_first"]
1591
+ if "first_message_button" in data:
1592
+ first_message_button = data["first_message_button"]
1593
+ if "second_message" in data:
1594
+ second_message = data["second_message"]
1595
+ if "second_message_button" in data:
1596
+ second_message_button = data["second_message_button"]
1597
+ if "need_send_message" in data:
1598
+ need_send_message = data["need_send_message"]
1599
+ if "message_button" in data:
1600
+ message_button = data["message_button"]
1601
+ if "has_link" in data:
1602
+ has_link = data["has_link"]
1603
+ if "comment_reply" in data:
1604
+ comment_reply = data["comment_reply"]
1605
+ if "comment_reply_content" in data:
1606
+ comment_reply_content = data["comment_reply_content"]
1607
+ if "all_out_of_stock" in data:
1608
+ all_out_of_stock = data["all_out_of_stock"]
1609
+ if "all_out_of_stock_content" in data:
1610
+ all_out_of_stock_content = data["all_out_of_stock_content"]
1564
1611
 
1612
+ message = {"has_interaction_message":has_interaction_message,"no_interaction_message_first":no_interaction_message_first,
1613
+ "first_message_button":first_message_button,"second_message_button":second_message_button,"second_message":second_message,
1614
+ "comment_reply_content":comment_reply_content,"all_out_of_stock_content" :all_out_of_stock_content
1615
+
1616
+ }
1617
+ body = {"message_config_req": {"need_send_message": need_send_message,
1618
+ "no_interaction_message": {"first_message": no_interaction_message_first,
1619
+ "first_message_button": first_message_button,
1620
+ "second_message":second_message ,
1621
+ "second_message_button": second_message_button},
1622
+ "has_interaction_message": {"first_message": has_interaction_message,
1623
+ "message_button": message_button}, "has_link": has_link},
1624
+ "comment_reply_req": {"need_reply": comment_reply, "content": comment_reply_content},
1625
+ "all_out_of_stock_req": {"need_reply": all_out_of_stock, "content": all_out_of_stock_content}}
1626
+ response = requests.post(url, headers=headers, json = body).json()
1627
+ return message,response
1565
1628
 
1566
1629
 
1567
1630
 
1568
1631
 
1569
1632
  if __name__=="__main__":
1570
- pass
1633
+ data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIwNmUxNGU2NzAxMWY0ZDNhMGU0ZDgyNDk3ZDAxYmQwZSIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVmNTlmMTI4MzcyZWIzMDAwNmRjNDcwMSJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.gUqa8FJs_vjRJ-kFMhOZx42QtCr7XxcN3gKSK6_4Zvs', 'lang': 'en'}, 'sales_id': 513416, 'platform': 'FB_GROUP'}
1634
+ sales_id,response = create_post_lucky_draw(data)
1635
+ data["sales_id"] = sales_id
1636
+ print(sales_id)
1637
+ data["prize_type"] = "discount"
1638
+ res2 = modify_lucky_draw(data)
1639
+ print(res2)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.6
3
+ Version: 2.3.8
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc-common-interface',
5
- version='2.3.6',
5
+ version='2.3.8',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),