Update client.py
This commit is contained in:
@@ -1080,6 +1080,50 @@ class Client(object):
|
||||
}
|
||||
|
||||
j = self._post(self.req_url.REMOVE_USER, data, fix_request=True, as_json=True)
|
||||
|
||||
def changeThreadImage(self, image_id, thread_id=None, thread_type=ThreadType.USER):
|
||||
|
||||
thread_id, thread_type = self._getThread(thread_id, thread_type)
|
||||
|
||||
if thread_type == ThreadType.GROUP:
|
||||
data = {
|
||||
'thread_image_id': image_id,
|
||||
'thread_id': thread_id
|
||||
}
|
||||
|
||||
j = self._post(self.req_url.THREAD_IMAGE, data, fix_request=True, as_json=True)
|
||||
|
||||
def changeThreadImageRemote(self, image_url, thread_id=None, thread_type=ThreadType.USER):
|
||||
|
||||
thread_id, thread_type = self._getThread(thread_id, thread_type)
|
||||
|
||||
if thread_type == ThreadType.GROUP:
|
||||
mimetype = guess_type(image_url)[0]
|
||||
is_gif = (mimetype == 'image/gif')
|
||||
remote_image = requests.get(image_url).content
|
||||
image_id = self._uploadImage(image_url, remote_image, mimetype)
|
||||
data = {
|
||||
'thread_image_id': image_id,
|
||||
'thread_id': thread_id
|
||||
}
|
||||
|
||||
j = self._post(self.req_url.THREAD_IMAGE, data, fix_request=True, as_json=True)
|
||||
|
||||
def changeThreadImageLocal(self, image_path, thread_id=None, thread_type=ThreadType.USER):
|
||||
|
||||
thread_id, thread_type = self._getThread(thread_id, thread_type)
|
||||
|
||||
if thread_type == ThreadType.GROUP:
|
||||
|
||||
mimetype = guess_type(image_path)[0]
|
||||
is_gif = (mimetype == 'image/gif')
|
||||
image_id = self._uploadImage(image_path, open(image_path, 'rb'), mimetype)
|
||||
data = {
|
||||
'thread_image_id': image_id,
|
||||
'thread_id': thread_id
|
||||
}
|
||||
|
||||
j = self._post(self.req_url.THREAD_IMAGE, data, fix_request=True, as_json=True)
|
||||
|
||||
def changeThreadTitle(self, title, thread_id=None, thread_type=ThreadType.USER):
|
||||
"""
|
||||
@@ -1094,18 +1138,17 @@ class Client(object):
|
||||
"""
|
||||
|
||||
thread_id, thread_type = self._getThread(thread_id, thread_type)
|
||||
|
||||
|
||||
if thread_type == ThreadType.USER:
|
||||
# The thread is a user, so we change the user's nickname
|
||||
return self.changeNickname(title, thread_id, thread_id=thread_id, thread_type=thread_type)
|
||||
else:
|
||||
data = self._getSendData(thread_id=thread_id, thread_type=thread_type)
|
||||
data = {
|
||||
'thread_name': title,
|
||||
'thread_id': thread_id,
|
||||
}
|
||||
|
||||
data['action_type'] = 'ma-type:log-message'
|
||||
data['log_message_data[name]'] = title
|
||||
data['log_message_type'] = 'log:thread-name'
|
||||
|
||||
return self._doSendRequest(data)
|
||||
j = self._post(self.req_url.THREAD_NAME, data, fix_request=True, as_json=True)
|
||||
|
||||
def changeNickname(self, nickname, user_id, thread_id=None, thread_type=ThreadType.USER):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user