From 26444104bedd795d26d1f017753186aa34d97dfd Mon Sep 17 00:00:00 2001 From: Sven Skender Date: Sat, 12 Nov 2016 19:49:07 +0100 Subject: [PATCH 1/2] Update client.py to kick chat participants remove_user_from_chat(threadID, userID) --- fbchat/client.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/fbchat/client.py b/fbchat/client.py index 777de09..95e1e80 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -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/" class Client(object): """A client for the Facebook Chat (Messenger). @@ -574,6 +575,24 @@ 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 From 0f1bb94a7fe6a83cb4dafb6b373b8131bbc9945e Mon Sep 17 00:00:00 2001 From: Sven Skender Date: Sat, 10 Dec 2016 21:28:05 +0100 Subject: [PATCH 2/2] Update client.py --- fbchat/client.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/fbchat/client.py b/fbchat/client.py index 95e1e80..9513725 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -595,6 +595,52 @@ class Client(object): 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 + + def on_message(self, mid, author_id, author_name, message, metadata): '''