Update client.py

This commit is contained in:
kapi2289
2018-07-03 23:13:47 +02:00
committed by GitHub
parent af86550e71
commit 5b965e63f8

View File

@@ -1081,6 +1081,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):
"""
Changes title of a thread.
@@ -1099,13 +1143,12 @@ class Client(object):
# 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):
"""