bellingcat / telegram-phone-number-checker

Check if phone numbers are connected to Telegram accounts.
https://pypi.org/project/telegram-phone-number-checker/
MIT License
1.02k stars 172 forks source link

TypeError: Cannot cast NoneType to any kind of Peer.. #14

Closed 0x4442 closed 4 months ago

0x4442 commented 4 months ago

Hey, I've some trouble using the checker. Some of my phonenumbers working fine. But some throw the following error: error": "TypeError: Cannot cast NoneType to any kind of Peer.. --> The error might have occurred due to the inability to delete the phone_number='+111111111111' from the contact list."

I can't find the problem, why this happens random to some phonenumbers. If a number works, it works every time I try, same with numbers which didn't works.

Thanks for help.

GalenReich commented 4 months ago

I've been having the same issue recently, I think it might be related to whether accounts have usernames set.

GalenReich commented 4 months ago

@0x4442, your issue should be solved now, you'll need to reinstall the tool with:

pip install telegram-phone-number-checker==1.0.6

Please let us know if you have any further issues!

0x4442 commented 4 months ago

@0x4442, your issue should be solved now, you'll need to reinstall the tool with:

pip install telegram-phone-number-checker==1.0.6

Please let us know if you have any further issues!

Hey @GalenReich , thanks for your fast response. It now works and don't throws the error anymore. But there is now a new "feature" ;)

before the patch when I search for a phonenumber he gives me all information back: phonenumber -> ID, name, username... or the error. Now I do the single search or multi search and get only: phonenumber -> ID and no error. Output before the patch: { }, "+987654321": { "id": 321654987, "username": "Galen_Reich", "first_name": "Galen", "last_name": "Reich" } }

Output after the patch: { "+123456789: { "id": 789456123, "username": null, "first_name": "", "last_name": null }, "+987654321": { "id": 321654987, "username": "Galen_Reich", "first_name": "", "last_name": null } }

GalenReich commented 4 months ago

Hmmm, I can replicate this, but I don't think it originates with my changes (as much as I like introducing new features 😅). It could be that Telegram is returning different information.

Would you be able to pip install telegram-phone-number-checker==1.0.5 and check that the output before the patch still returns the first_name and last_name fields?

0x4442 commented 4 months ago

I did, installed with 1.0.6 and it works with complication (error is gone but last_name/first_name is empty/null) as written before. Tried in another VM with 1.0.5 and it come to the error as i opened this issue but showed first_name and last_name correct.

GalenReich commented 4 months ago

When I run 1.0.5 I don't get first_name last_name anymore (I did a few days ago). I suspect Telegram has changed something in the last few days.

But if 1.0.5 is still returning first_name last_name for you, then I'll need to look closer!

From my testing it looks like Telegram is not resolving a number into a name unless that number has added you as a contact.

0x4442 commented 4 months ago

well i can confirm that in 1.0.5 i get with the "problem"-number the error and with the other all data ID, first_name, last_name, username. In 1.0.6 the "problem"-number give ID and no error, but the other number gives back the ID too. I think it has something to do when a number have no username/last-/first-name.

GalenReich commented 4 months ago

Okay, that's really useful to know, thank you! I think you are right, perhaps chaning to not match by username has had this unforeseen consequence - I'll reopen this

GalenReich commented 4 months ago

Okay, second time lucky - hopefully 1.0.7 fixes all the issues!

0x4442 commented 4 months ago

tried and works completely fine! Thanks for your help and fast response.

GalenReich commented 4 months ago

Hooray! Thank you for your issue and you patience with getting it sorted! Also, if you're interested in being part of the wider Bellingcat community, you can join our Bellingcat Discord too.