Rename .uid -> .id everywhere

This commit is contained in:
Mads Marquart
2020-01-08 23:09:51 +01:00
parent 45c0a4772d
commit a5abb05ab3
35 changed files with 171 additions and 180 deletions

View File

@@ -3,13 +3,13 @@ import fbchat
# Subclass fbchat.Client and override required methods
class EchoBot(fbchat.Client):
def on_message(self, author_id, message_object, thread_id, thread_type, **kwargs):
self.mark_as_delivered(thread_id, message_object.uid)
self.mark_as_delivered(thread_id, message_object.id)
self.mark_as_read(thread_id)
print("{} from {} in {}".format(message_object, thread_id, thread_type.name))
# If you're not the author, echo
if author_id != self.uid:
if author_id != session.user_id:
self.send(message_object, thread_id=thread_id, thread_type=thread_type)

View File

@@ -8,7 +8,7 @@ client = fbchat.Client(session)
# Fetches a list of all users you're currently chatting with, as `User` objects
users = client.fetch_all_users()
print("users' IDs: {}".format([user.uid for user in users]))
print("users' IDs: {}".format([user.id for user in users]))
print("users' names: {}".format([user.name for user in users]))
@@ -25,7 +25,7 @@ print("users' names: {}".format([users[k].name for k in users]))
# and then we just take the first one, aka. the most likely one:
user = client.search_for_users("<name of user>")[0]
print("user ID: {}".format(user.uid))
print("user ID: {}".format(user.id))
print("user's name: {}".format(user.name))
print("user's photo: {}".format(user.photo))
print("Is user client's friend: {}".format(user.is_friend))

View File

@@ -31,7 +31,7 @@ class KeepBot(fbchat.Client):
self.change_thread_emoji(old_emoji, thread_id=thread_id)
def on_people_added(self, added_ids, author_id, thread_id, **kwargs):
if old_thread_id == thread_id and author_id != self.uid:
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)
@@ -40,8 +40,8 @@ class KeepBot(fbchat.Client):
# No point in trying to add ourself
if (
old_thread_id == thread_id
and removed_id != self.uid
and author_id != self.uid
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)