From 86a163e3370d16c5fc0c6d22d1995a6ad01354dc Mon Sep 17 00:00:00 2001 From: ThatAlexanderA <38069912+ThatAlexanderA@users.noreply.github.com> Date: Sat, 14 Jul 2018 12:40:42 +0200 Subject: [PATCH 1/2] Added create group def --- fbchat/client.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/fbchat/client.py b/fbchat/client.py index 5b5dbe1..221cbec 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -1033,7 +1033,25 @@ class Client(object): is_gif = (mimetype == 'image/gif') image_id = self._uploadImage(image_path, open(image_path, 'rb'), mimetype) return self.sendImage(image_id=image_id, message=message, thread_id=thread_id, thread_type=thread_type, is_gif=is_gif) - + + def createGroup(self, message, person_ids=None): + """Creates a group with the given ids + :param person_ids: A list of people to create the group with. + :return: Returns error if couldn't create group, returns True when the group created. + """ + payload = { + "send" : "send", + "body": message, + "ids" : person_ids + } + r = self._post(self.req_url.CREATE_GROUP, payload) + if "send_success" in r.url: + log.debug("The group was created successfully!") + return True + else: + log.warning("Error while creating group") + return False + def addUsersToGroup(self, user_ids, thread_id=None): """ Adds users to a group. From 4993da727ab6f6bf836f38fa744bdaf5a1857b2a Mon Sep 17 00:00:00 2001 From: ThatAlexanderA <38069912+ThatAlexanderA@users.noreply.github.com> Date: Sat, 14 Jul 2018 12:42:18 +0200 Subject: [PATCH 2/2] Added create group url --- fbchat/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fbchat/utils.py b/fbchat/utils.py index d33a70f..2517459 100644 --- a/fbchat/utils.py +++ b/fbchat/utils.py @@ -125,6 +125,7 @@ class ReqUrl(object): EVENT_REMINDER = "https://www.facebook.com/ajax/eventreminder/create" MODERN_SETTINGS_MENU = "https://www.facebook.com/bluebar/modern_settings_menu/" REMOVE_FRIEND = "https://m.facebook.com/a/removefriend.php" + CREATE_GROUP = "https://m.facebook.com/messages/send/?icm=1" pull_channel = 0