Skip to content

Commit

Permalink
return richer account information (#21)
Browse files Browse the repository at this point in the history
* 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
BDFL669 and GalenReich authored Mar 5, 2024
1 parent ac84e34 commit 3636963
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "telegram-phone-number-checker"
version = "1.0.8"
version = "1.1.0"
description = "Check if phone numbers are connected to Telegram accounts."
authors = ["Bellingcat"]
license = "MIT"
Expand Down
12 changes: 11 additions & 1 deletion telegram_phone_number_checker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]'})
Expand Down

0 comments on commit 3636963

Please sign in to comment.