Created
March 18, 2020 04:12
-
-
Save gpollo/a1b137c66b57178070d8cee49fa8898c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import fbchat | |
import time | |
import qng.generator | |
username = "<redacted>" | |
password = "<redacted>" | |
thread_id = "<redacted>" | |
generator = qng.generator.QuebNameGenerator() | |
def random_name(gender): | |
if gender == "female_singular": | |
return generator.generate(gender='female') | |
else: | |
return generator.generate(gender='male') | |
def change_nickname(user, thread_id): | |
old_nickname = user.nickname | |
new_nickname = random_name(user.gender) | |
client.changeNickname(new_nickname, user.uid, thread_id=thread_id, thread_type=thread.type) | |
print("{}: '{}' to '{}'".format(user.first_name, old_nickname, new_nickname)) | |
time.sleep(1) | |
client = fbchat.Client(username, password) | |
thread = client.fetchThreadInfo(thread_id)[thread_id] | |
if thread.type == fbchat.ThreadType.USER: | |
change_nickname(thread, thread_id) | |
else: | |
users = client.fetchUserInfo(*thread.nicknames.keys()) | |
for (user_id, nickname) in thread.nicknames.items(): | |
users[user_id].nickname = nickname | |
change_nickname(users[user_id], thread_id) | |
client.logout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment