-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
return richer account information (#21)
* added more fields for user information * Increment version to 1.1.0 (reflecting the new functionality) --------- Co-authored-by: Galen Reich <[email protected]>
- Loading branch information
1 parent
ac84e34
commit 3636963
Showing
2 changed files
with
12 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,22 @@ def get_names(client: TelegramClient, phone_number: str) -> dict: | |
# The response from DeleteContactsRequest contains more information than from ImportContactsRequest | ||
del_user = client(functions.contacts.DeleteContactsRequest(id=[users[0].get('id')])) | ||
user = del_user.to_dict().get('users')[0] | ||
user_was_online = user.get('status', {}).get('was_online') | ||
# getting more information about the user | ||
result.update({ | ||
"id": user.get('id'), | ||
"username": user.get('username'), | ||
"first_name": user.get('first_name'), | ||
"last_name": user.get('last_name') | ||
"last_name": user.get('last_name'), | ||
"fake" : user.get('fake'), | ||
"verified" : user.get('verified'), | ||
"premium" : user.get('premium'), | ||
"mutual_contact" : user.get('mutual_contact'), | ||
"bot" : user.get('bot'), | ||
"bot_chat_history" : user.get('bot_chat_history'), | ||
"restricted" : user.get('restricted'), | ||
"restriction_reason" : user.get('restriction_reason'), | ||
"user_was_online": user_was_online.strftime("%Y-%m-%d %H:%M:%S %Z") if user_was_online else None | ||
}) | ||
else: | ||
result.update({"error": f'This phone number matched multiple Telegram accounts, which is unexpected. Please contact the developer: [email protected]'}) | ||
|