Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加了2个功能接口 #254

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion wxbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ def __init__(self):
self.encry_chat_room_id_list = [] # 存储群聊的EncryChatRoomId,获取群内成员头像时需要用到

self.file_index = 0

#获取群成员数量
def get_group_count(self):
group_count = []

if len(self.group_list) == 0:
return ""

for group in self.group_list:
group_name = group["NickName"]
group_size = len(self.group_members[group["UserName"]])
group_count.append({'group_name': group_name, 'count': group_size})

return group_count

#在未传入bot_conf的情况下尝试载入本地配置文件,WxbotManage使用
def load_conf(self,bot_conf):
Expand Down Expand Up @@ -378,7 +392,6 @@ def get_group_member_name(self, gid, uid):
def get_contact_info(self, uid):
return self.account_info['normal_member'].get(uid)


def get_group_member_info(self, uid):
return self.account_info['group_member'].get(uid)

Expand Down Expand Up @@ -1116,6 +1129,32 @@ def send_img_msg_by_uid(self, fpath, uid):
except Exception,e:
return False

# 发送图片扩展
def send_img_msg_by_uid_ex(self, ftype, mid, uid):
url = self.base_uri + '/webwxsendmsgimg?fun=async&f=json'
data = {
'BaseRequest': self.base_request,
'Msg': {
'Type': 3,
'MediaId': mid,
'FromUserName': self.my_account['UserName'],
'ToUserName': uid,
'LocalID': str(time.time() * 1e7),
'ClientMsgId': str(time.time() * 1e7), }, }
if ftype == '.gif':
url = self.base_uri + '/webwxsendemoticon?fun=sys'
data['Msg']['Type'] = 47
data['Msg']['EmojiFlag'] = 2
try:
r = self.session.post(url, data=json.dumps(data), timeout=120)
res = json.loads(r.text)
if res['BaseResponse']['Ret'] == 0:
return True
else:
return False
except Exception,e:
return False

def get_user_id(self, name):
if name == '':
return None
Expand Down