def get_groupchat_rooms_success(user): url = urls.groupchatroomlist_url() auth = (user[0], user[2]) res = requests.get(url, auth=auth, verify=False) data = {} data = json.loads(res.text) if res.status_code != 200: print('error!: user {0} cannot get chat room list'.format(auth[0])) exit(1) else: print('user {0} get chat room list success'.format(auth[0])) return data[0]['id']
def exit_groupchat_rooms_success(roomid, auth): url = urls.groupchatroomlist_url() data = {} data['roomid'] = roomid json.dumps(data) data['delete'] = True json.dumps(data) res = requests.post(url, data, auth=auth, verify=False) if res.status_code != 202: print('error!: user {0} failed in exit chatting room'.format(auth[0])) exit(1) else: print('user {0} exit chatting room success'.format(auth[0]))
def post_groupchat_rooms_success(users): url = urls.groupchatroomlist_url() auth = (users[0][0], users[0][2]) data = {} for i in range(1, len(users)): data['user' + str(i)] = users[i][0] json.dumps(data) res = requests.post(url, data, auth=auth, verify=False) if res.status_code != 201: print('error!: user {0} cannot post chat room with users'.format( auth[0])) exit(1) else: print('user {0} post chat room with users success'.format(auth[0]))
def addusers_groupchat_rooms_success(users, auth, roomid): url = urls.groupchatroomlist_url() data = {} data['roomid'] = roomid json.dumps(data) for i in range(0, len(users)): data['user' + str(i + 1)] = users[i][0] json.dumps(data) res = requests.post(url, data, auth=auth, verify=False) if res.status_code != 200: print('error!: user {0} cannot post chat room with users'.format( auth[0])) exit(1) else: print('user {0} added new users by posting success'.format(auth[0]))