add thread color change

This commit is contained in:
Dainius
2017-05-16 12:03:20 +03:00
parent fb88f8d459
commit e1e1a0d611
3 changed files with 67 additions and 29 deletions

View File

@@ -52,6 +52,7 @@ LogoutURL ="https://www.facebook.com/logout.php"
AllUsersURL ="https://www.facebook.com/chat/user_info_all"
SaveDeviceURL="https://m.facebook.com/login/save-device/cancel/"
CheckpointURL="https://m.facebook.com/login/checkpoint/"
ChatColorURL="https://www.facebook.com/messaging/save_thread_color/?source=thread_settings&dpr=1"
facebookEncoding = 'UTF-8'
# Log settings
@@ -505,6 +506,7 @@ class Client(object):
users.append(User(entry))
return users # have bug TypeError: __repr__ returned non-string (type bytes)
"""
SEND METHODS
"""
@@ -612,7 +614,7 @@ class Client(object):
:param thread_type: specify whether thread_id is user or group chat
:return: a list of message ids of the sent message(s)
"""
data = self._getSendData(thread_id=thread_id, thread_type=ThreadType.GROUP)
data = self._getSendData(thread_id=thread_id, thread_type=thread_type)
data['action_type'] = 'ma-type:user-generated-message'
data['body'] = message or ''
@@ -785,6 +787,22 @@ class Client(object):
return self._doSendRequest(data)
def changeThreadColor(self, new_color, thread_id=None, thread_type=None):
# type: (ChatColor, str, ThreadType) -> bool
if thread_id is None and self.def_thread_type == ThreadType.GROUP:
thread_id = self.def_thread_id
elif thread_id is None:
raise ValueError('Default Thread ID is not set.')
data = {
"color_choice": new_color.value,
"thread_or_other_fbid": thread_id
}
r = self._post(ChatColorURL, data)
return r.ok
"""
END SEND METHODS
"""
@@ -1129,7 +1147,7 @@ class Client(object):
self.onUnknownMesssageType(msg=m)
except Exception as e:
self.onMessageError(exception=e, msg=msg)
self.onMessageError(exception=e, msg=m)
@deprecated(deprecated_in='0.10.2', details='Use startListening() instead')

View File

@@ -73,18 +73,9 @@ class TypingStatus(Enum):
TYPING = 1
class EmojiSize(Enum):
LARGE = {
'value': '369239383222810',
'name': 'large'
}
MEDIUM = {
'value': '369239343222814',
'name': 'medium'
}
SMALL = {
'value': '369239263222822',
'name': 'small'
}
LARGE = '369239383222810'
MEDIUM = '369239343222814'
SMALL = '369239263222822'
LIKES = {
'l': EmojiSize.LARGE,
@@ -94,3 +85,20 @@ LIKES = {
LIKES['large'] = LIKES['l']
LIKES['medium'] =LIKES['m']
LIKES['small'] = LIKES['s']
class ChatColor(Enum):
MESSENGER_BLUE = ''
VIKING = '#44bec7'
GOLDEN_POPPY = '#ffc300'
RADICAL_RED = '#fa3c4c'
SHOCKING = '#d696bb'
PICTON_BLUE = '#6699cc'
FREE_SPEECH_GREEN = '#13cf13'
PUMPKIN = '#ff7e29'
LIGHT_CORAL = '#e68585'
MEDIUM_SLATE_BLUE = '#7646ff'
DEEP_SKY_BLUE = '#20cef5'
FERN = '#67b868'
CAMEO = '#d4a88c'
BRILLIANT_ROSE = '#ff5ca1'
BILOBA_FLOWER = '#a695c7'