Skip to content

Commit

Permalink
Add invite function for add user to group
Browse files Browse the repository at this point in the history
Signed-off-by: mzy <[email protected]>
  • Loading branch information
mzy committed Oct 29, 2016
1 parent 60b2da5 commit 41ea9e2
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions wxbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,17 +724,28 @@ def add_friend_to_group(self,uid,group_name):
gid = group['UserName']
if gid == '':
return False
#获取群成员数量并判断邀请方式
group_num=len(self.group_members[gid])
print '[DEBUG] group_name:%s group_num:%s' % (group_name,group_num)
#通过群id判断uid是否在群中
for user in self.group_members[gid]:
if user['UserName'] == uid:
#已经在群里面了,不用加了
return True
url = self.base_uri + '/webwxupdatechatroom?fun=addmember&pass_ticket=%s' % self.pass_ticket
params ={
"AddMemberList": uid,
"ChatRoomName": gid,
"BaseRequest": self.base_request
}
if group_num<=100:
url = self.base_uri + '/webwxupdatechatroom?fun=addmember&pass_ticket=%s' % self.pass_ticket
params ={
"AddMemberList": uid,
"ChatRoomName": gid,
"BaseRequest": self.base_request
}
else:
url = self.base_uri + '/webwxupdatechatroom?fun=invitemember'
params ={
"InviteMemberList": uid,
"ChatRoomName": gid,
"BaseRequest": self.base_request
}
headers = {'content-type': 'application/json; charset=UTF-8'}
data = json.dumps(params, ensure_ascii=False).encode('utf8')
try:
Expand Down

0 comments on commit 41ea9e2

Please sign in to comment.