Remove ThreadType completely
This commit is contained in:
@@ -16,50 +16,48 @@ old_nicknames = {
|
||||
|
||||
|
||||
class KeepBot(fbchat.Client):
|
||||
def on_color_change(self, author_id, new_color, thread_id, thread_type, **kwargs):
|
||||
if old_thread_id == thread_id and old_color != new_color:
|
||||
def on_color_change(self, author_id, new_color, thread, **kwargs):
|
||||
if old_thread_id == thread.id and old_color != new_color:
|
||||
print(
|
||||
"{} changed the thread color. It will be changed back".format(author_id)
|
||||
)
|
||||
self.change_thread_color(old_color, thread_id=thread_id)
|
||||
thread.set_color(old_color)
|
||||
|
||||
def on_emoji_change(self, author_id, new_emoji, thread_id, thread_type, **kwargs):
|
||||
if old_thread_id == thread_id and new_emoji != old_emoji:
|
||||
def on_emoji_change(self, author_id, new_emoji, thread, **kwargs):
|
||||
if old_thread_id == thread.id and new_emoji != old_emoji:
|
||||
print(
|
||||
"{} changed the thread emoji. It will be changed back".format(author_id)
|
||||
)
|
||||
self.change_thread_emoji(old_emoji, thread_id=thread_id)
|
||||
thread.set_emoji(old_emoji)
|
||||
|
||||
def on_people_added(self, added_ids, author_id, thread_id, **kwargs):
|
||||
if old_thread_id == thread_id and author_id != session.user_id:
|
||||
def on_people_added(self, added_ids, author_id, thread, **kwargs):
|
||||
if old_thread_id == thread.id and author_id != session.user_id:
|
||||
print("{} got added. They will be removed".format(added_ids))
|
||||
for added_id in added_ids:
|
||||
self.remove_user_from_group(added_id, thread_id=thread_id)
|
||||
thread.remove_participant(added_id)
|
||||
|
||||
def on_person_removed(self, removed_id, author_id, thread_id, **kwargs):
|
||||
def on_person_removed(self, removed_id, author_id, thread, **kwargs):
|
||||
# No point in trying to add ourself
|
||||
if (
|
||||
old_thread_id == thread_id
|
||||
old_thread_id == thread.id
|
||||
and removed_id != session.user_id
|
||||
and author_id != session.user_id
|
||||
):
|
||||
print("{} got removed. They will be re-added".format(removed_id))
|
||||
self.add_users_to_group(removed_id, thread_id=thread_id)
|
||||
thread.add_participants(removed_id)
|
||||
|
||||
def on_title_change(self, author_id, new_title, thread_id, thread_type, **kwargs):
|
||||
if old_thread_id == thread_id and old_title != new_title:
|
||||
def on_title_change(self, author_id, new_title, thread, **kwargs):
|
||||
if old_thread_id == thread.id and old_title != new_title:
|
||||
print(
|
||||
"{} changed the thread title. It will be changed back".format(author_id)
|
||||
)
|
||||
self.change_thread_title(
|
||||
old_title, thread_id=thread_id, thread_type=thread_type
|
||||
)
|
||||
thread.set_title(old_title)
|
||||
|
||||
def on_nickname_change(
|
||||
self, author_id, changed_for, new_nickname, thread_id, thread_type, **kwargs
|
||||
self, author_id, changed_for, new_nickname, thread, **kwargs
|
||||
):
|
||||
if (
|
||||
old_thread_id == thread_id
|
||||
old_thread_id == thread.id
|
||||
and changed_for in old_nicknames
|
||||
and old_nicknames[changed_for] != new_nickname
|
||||
):
|
||||
@@ -68,11 +66,8 @@ class KeepBot(fbchat.Client):
|
||||
author_id, changed_for
|
||||
)
|
||||
)
|
||||
self.change_nickname(
|
||||
old_nicknames[changed_for],
|
||||
changed_for,
|
||||
thread_id=thread_id,
|
||||
thread_type=thread_type,
|
||||
thread.set_nickname(
|
||||
changed_for, old_nicknames[changed_for],
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user