yzk_wechat_event/apps/jqr/ksy_http.py

96 lines
3.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import requests
class Http(object):
BASE_URL = 'http://114.215.169.94:7035'
@classmethod
def get_new_user_msg(cls, corpid, userid, external_userid=None, chat_id=None, uid=None):
uid = uid or 3
url = f'{cls.BASE_URL}/api/newusermsg/getnewusermsg'
send_type = 0
if chat_id is not None:
send_type = 1
params = {
'corpId': corpid,
'userId': userid,
'externalUserId': external_userid,
'groupId': chat_id,
'uId': uid,
'sendType': send_type,
}
res = requests.get(url, params=params)
if res.status_code == 200:
return True, res.json().get('data')
return False, None
@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
@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
s sendType 0 私聊1 群聊;
s sendTableType 0 新客欢迎表1 关键词回复表2 群发任务表
c contentId 主键Id
c contenrName 内容名称
s sendForm 0 极速群发1=高级群发
"""
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
if __name__ == '__main__':
success, data = Http.get_new_user_msg('ww056d00fac4950f54', 'QingFeng', 'wmy1VmQgAAWxMDKJdWrY1mY_Gl8HAHwQ')
print(success)
print(data)