2023-12-27 15:21:02 +08:00
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Http(object):
|
|
|
|
|
BASE_URL = 'http://114.215.169.94:7035'
|
|
|
|
|
|
|
|
|
|
@classmethod
|
2024-01-02 18:42:29 +08:00
|
|
|
|
def get_new_user_msg(cls, corpid, userid, external_userid=None, chat_id=None, uid=None):
|
2023-12-28 14:30:15 +08:00
|
|
|
|
uid = uid or 3
|
2023-12-27 15:21:02 +08:00
|
|
|
|
url = f'{cls.BASE_URL}/api/newusermsg/getnewusermsg'
|
2024-01-02 18:42:29 +08:00
|
|
|
|
send_type = 0
|
|
|
|
|
if chat_id is not None:
|
|
|
|
|
send_type = 1
|
2023-12-27 15:21:02 +08:00
|
|
|
|
params = {
|
|
|
|
|
'corpId': corpid,
|
|
|
|
|
'userId': userid,
|
2023-12-28 14:30:15 +08:00
|
|
|
|
'externalUserId': external_userid,
|
2024-01-02 18:42:29 +08:00
|
|
|
|
'groupId': chat_id,
|
2023-12-28 14:30:15 +08:00
|
|
|
|
'uId': uid,
|
2024-01-02 18:42:29 +08:00
|
|
|
|
'sendType': send_type,
|
2023-12-27 15:21:02 +08:00
|
|
|
|
}
|
|
|
|
|
res = requests.get(url, params=params)
|
|
|
|
|
if res.status_code == 200:
|
|
|
|
|
return True, res.json().get('data')
|
|
|
|
|
return False, None
|
|
|
|
|
|
2023-12-28 17:14:59 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
def get_keyword_reply_msg(cls, corpid, userid, external_userid, uid=None, send_type=0, content=None):
|
|
|
|
|
# sendType 0 私聊,1 群聊
|
|
|
|
|
uid = uid or 3
|
|
|
|
|
url = f'{cls.BASE_URL}/api/newusermsg/getkeywordreplymsg'
|
|
|
|
|
params = {
|
|
|
|
|
'corpId': corpid,
|
|
|
|
|
'userId': userid,
|
|
|
|
|
'externalUserId': external_userid,
|
|
|
|
|
'uId': uid,
|
|
|
|
|
'sendType': send_type,
|
|
|
|
|
'content': content,
|
|
|
|
|
}
|
|
|
|
|
res = requests.get(url, params=params)
|
|
|
|
|
if res.status_code == 200:
|
|
|
|
|
return True, res.json().get('data')
|
|
|
|
|
return False, None
|
|
|
|
|
|
2024-01-02 17:21:18 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
def get_appoint_user_msg(cls, corpid, userid, external_userid, group_id, uid=None, send_type=0, send_table_type=0,
|
|
|
|
|
send_form=None, content_id=None, content_name=None):
|
|
|
|
|
"""
|
|
|
|
|
groupId 群id;
|
2024-01-02 18:42:29 +08:00
|
|
|
|
s sendType 0 私聊,1 群聊;
|
|
|
|
|
s sendTableType 0 新客欢迎表,1 关键词回复表,2 群发任务表
|
|
|
|
|
c contentId 主键Id
|
|
|
|
|
c contenrName 内容名称
|
|
|
|
|
s sendForm 0 极速群发,1=高级群发
|
2024-01-02 17:21:18 +08:00
|
|
|
|
"""
|
|
|
|
|
uid = uid or 3
|
|
|
|
|
url = f'{cls.BASE_URL}/api/newusermsg/getappointusermsg'
|
|
|
|
|
params = {
|
|
|
|
|
'corpId': corpid,
|
|
|
|
|
'userId': userid,
|
|
|
|
|
'groupId': group_id,
|
|
|
|
|
'externalUserId': external_userid,
|
|
|
|
|
'uId': uid,
|
|
|
|
|
'sendType': send_type,
|
|
|
|
|
'sendTableType': send_table_type,
|
|
|
|
|
'sendForm': send_form,
|
|
|
|
|
'contentId': content_id,
|
|
|
|
|
'contenrName': content_name,
|
|
|
|
|
}
|
|
|
|
|
res = requests.get(url, params=params)
|
|
|
|
|
if res.status_code == 200:
|
|
|
|
|
return True, res.json().get('data')
|
|
|
|
|
return False, None
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def get_agent_send_msg(cls, msg_id, corpid=None, userid=None, external_userid=None, uid=None):
|
|
|
|
|
uid = uid or 3
|
|
|
|
|
url = f'{cls.BASE_URL}/api/newusermsg/getagentsendmsg'
|
|
|
|
|
params = {
|
|
|
|
|
'corpId': corpid,
|
|
|
|
|
'userId': userid,
|
|
|
|
|
'externalUserId': external_userid,
|
|
|
|
|
'msgId': msg_id,
|
|
|
|
|
'uId': uid,
|
|
|
|
|
}
|
|
|
|
|
res = requests.get(url, params=params)
|
|
|
|
|
if res.status_code == 200:
|
|
|
|
|
return True, res.json().get('data')
|
|
|
|
|
return False, None
|
|
|
|
|
|
2023-12-27 15:21:02 +08:00
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2024-01-02 17:21:18 +08:00
|
|
|
|
success, data = Http.get_new_user_msg('ww056d00fac4950f54', 'QingFeng', 'wmy1VmQgAAWxMDKJdWrY1mY_Gl8HAHwQ')
|
2023-12-28 13:43:46 +08:00
|
|
|
|
print(success)
|
|
|
|
|
print(data)
|