__init__.py
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# coding=utf-8
import logging
import requests
_logger = logging.getLogger(__name__)
oauth_client_cache = {}
def send_msg(env, slug_list, msg):
if env.cr.dbname not in oauth_client_cache:
obj = env.ref('weodoo.weodoo_config_default')
oauth_client_cache[env.cr.dbname] = {
"id": obj.id,
"oauth_key": obj.oauth_client_key,
"oauth_secret": obj.oauth_client_secret,
}
oauth_client = oauth_client_cache[env.cr.dbname]
mtype = msg["mtype"]
if mtype=="text":
data = {
"oauth_key": oauth_client["oauth_key"],
"oauth_secret": oauth_client["oauth_secret"],
"slug": ','.join(slug_list),
"content": msg["content"],
}
url = "https://i.calluu.cn/auth3rd/send_text"
ret = requests.post(url, data)
_logger.info(ret)
elif mtype=='card':
data = {
"oauth_key": oauth_client["oauth_key"],
"oauth_secret": oauth_client["oauth_secret"],
"slug": ','.join(slug_list),
"title": msg["title"],
"description": msg["description"],
"url": msg["url"],
"btntxt": msg.get("btntxt", "详情"),
}
url = "https://i.calluu.cn/auth3rd/send_card"
ret = requests.post(url, data)
_logger.info(ret)
elif mtype=='image':
pass
elif mtype=='voice':
pass