Remove ThreadType completely

This commit is contained in:
Mads Marquart
2020-01-09 11:13:48 +01:00
parent ded6039b69
commit 2ec0be9635
19 changed files with 250 additions and 601 deletions

View File

@@ -2,21 +2,17 @@ import fbchat
class RemoveBot(fbchat.Client):
def on_message(self, author_id, message_object, thread_id, thread_type, **kwargs):
def on_message(self, author_id, message_object, thread, **kwargs):
# We can only kick people from group chats, so no need to try if it's a user chat
if (
message_object.text == "Remove me!"
and thread_type == fbchat.ThreadType.GROUP
):
print("{} will be removed from {}".format(author_id, thread_id))
self.remove_user_from_group(author_id, thread_id=thread_id)
if message_object.text == "Remove me!" and isinstance(thread, fbchat.Group):
print("{} will be removed from {}".format(author_id, thread))
thread.remove_participant(author_id)
else:
# Sends the data to the inherited on_message, so that we can still see when a message is recieved
super(RemoveBot, self).on_message(
author_id=author_id,
message_object=message_object,
thread_id=thread_id,
thread_type=thread_type,
thread=thread,
**kwargs,
)