def add_user_to_group_batch(self, group_id): """群组加人[批量] """ payload = {} url = ('/%s/%s/chatgroups/%s/users' % (self.org, self.app, group_id)) return http_post(url, payload, self.auth)
def acquire_token(self): payload = { 'grant_type': 'client_credentials', 'client_id': self.client_id, 'client_secret': self.client_secret } resp = http_post(url=self.url, payload=payload, auth=None) if resp[0]: self.logger.info('fetched a token :' + resp[1]['access_token']) return Token(resp[1]['access_token'], resp[1]['expires_in']) else: self.logger.error('some errors occurred at acquiring token.') return None
def activate_user(self, username): """用户账号解禁 """ url = ('/%s/%s/users/%s/activate' % (self.org, self.app, username)) return http_post(url, None, self.auth)
def im_user_login(self, payload): """IM用户登录 """ url = ('/%s/%s/users' % (self.org, self.app)) return http_post(url, payload)
def create_new_user(self, payload): """注册IM用户 """ url = ('/%s/%s/users' % (self.org, self.app)) return http_post(url, payload, self.auth)
def send_messages(self, payload): url = ('/%s/%s/messages' % (self.org, self.app)) return http_post(url, payload, self.auth)
def add_friend(self, username, friend): """建立好友关系 """ url = ('/%s/%s/users/%s/contacts/users/%s' % (self.org, self.app, username, friend)) return http_post(url, self.auth)
def modify_groupinfo(self, payload): """修改群组信息 """ url = ('/%s/%s/chatgroups' % (self.org, self.app)) return http_post(url, payload, self.auth)
def add_user_to_group_single(self, group_id, username): """群组加人[单个] """ url = ('/%s/%s/chatgroups/%s/users/%s' % (self.org, self.app, group_id, username)) return http_post(url, self.auth)
def create_group(self, payload): """创建群组 """ url = ('/%s/%s/chatgroups' % (self.org, self.app)) return http_post(url, payload, self.auth)