Merge pull request #80 from sskender/master
Update client.py to kick chat participants, rename threads
This commit is contained in:
@@ -39,6 +39,7 @@ StickyURL ="https://0-edge-chat.facebook.com/pull"
|
||||
PingURL ="https://0-channel-proxy-06-ash2.facebook.com/active_ping"
|
||||
UploadURL ="https://upload.facebook.com/ajax/mercury/upload.php"
|
||||
UserInfoURL ="https://www.facebook.com/chat/user_info/"
|
||||
RemoveUserURL="https://www.facebook.com/chat/remove_participants/"
|
||||
LogoutURL ="https://www.facebook.com/logout.php"
|
||||
|
||||
class Client(object):
|
||||
@@ -595,6 +596,70 @@ class Client(object):
|
||||
return full_data
|
||||
|
||||
|
||||
def remove_user_from_chat(self, threadID, userID):
|
||||
"""Remove user (userID) from group chat (threadID)
|
||||
|
||||
:param threadID: group chat id
|
||||
:param userID: user id to remove from chat
|
||||
"""
|
||||
|
||||
data = {
|
||||
"uid" : userID,
|
||||
"tid" : threadID
|
||||
}
|
||||
|
||||
r = self._post(RemoveUserURL, data)
|
||||
|
||||
self._console(r)
|
||||
self._console(data)
|
||||
|
||||
return r.ok
|
||||
|
||||
|
||||
def changeThreadTitle(self, threadID, newTitle):
|
||||
"""Change title of a group conversation
|
||||
|
||||
:param threadID: group chat id
|
||||
:param newTitle: new group chat title
|
||||
"""
|
||||
|
||||
messageAndOTID = generateOfflineThreadingID()
|
||||
timestamp = now()
|
||||
date = datetime.now()
|
||||
data = {
|
||||
'client' : self.client,
|
||||
'action_type' : 'ma-type:log-message',
|
||||
'author' : 'fbid:' + str(self.uid),
|
||||
'thread_id' : '',
|
||||
'author_email' : '',
|
||||
'coordinates' : '',
|
||||
'timestamp' : timestamp,
|
||||
'timestamp_absolute' : 'Today',
|
||||
'timestamp_relative' : str(date.hour) + ":" + str(date.minute).zfill(2),
|
||||
'timestamp_time_passed' : '0',
|
||||
'is_unread' : False,
|
||||
'is_cleared' : False,
|
||||
'is_forward' : False,
|
||||
'is_filtered_content' : False,
|
||||
'is_spoof_warning' : False,
|
||||
'source' : 'source:chat:web',
|
||||
'source_tags[0]' : 'source:chat',
|
||||
'status' : '0',
|
||||
'offline_threading_id' : messageAndOTID,
|
||||
'message_id' : messageAndOTID,
|
||||
'threading_id': generateMessageID(self.client_id),
|
||||
'manual_retry_cnt' : '0',
|
||||
'thread_fbid' : threadID,
|
||||
'log_message_data[name]' : newTitle,
|
||||
'log_message_type' : 'log:thread-name'
|
||||
}
|
||||
|
||||
r = self._post(SendURL, data)
|
||||
|
||||
self._console(r)
|
||||
self._console(data)
|
||||
|
||||
return r.ok
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user