majn / telegram-purple

Adds support for Telegram to Pidgin, Adium, Finch and other Libpurple based messengers.
GNU General Public License v2.0
735 stars 81 forks source link

Correcting phone number #35

Closed 3pt142 closed 6 years ago

3pt142 commented 9 years ago

It would be nice if Pidgin would correct numbers from 7~ to 8~, otherwise I was confused and could not connect

majn commented 9 years ago

Pidgin should display a warning when connection fails because of an invalid phone number, either PHONE_NUMBER_INVALID or "Invalid or non-existing phone number.", did it do that?

Implementing better input validation is probably a good idea, nonetheless.

3pt142 commented 9 years ago

No, Pidgin did not do that. 3.17.6-1-ARCH, Pidgin 2.10.11 (libpurple 2.10.11)

gammy commented 9 years ago

7~ to 8~, what does that mean?

3pt142 commented 9 years ago

For example +7 901 555 55 55 to 89015555555

gammy commented 9 years ago

I'm sorry, I'm stumped: So pidgin should change the country code "47" to "48"? Why? I'm curious since the plugin actually won't accept my number as valid/existing even though the official client works just fine with it.

3pt142 commented 9 years ago

I have russian phone number (+7...), this plugin worked only with 8... one week ago. Now it works only with +7... I'm stumped too :)

majn commented 9 years ago

@gammy what number format did you enter?

It should only work with the full country code in front of the phone number. +491573123456 for 01573123456 in Germany

instead of +49, the phone number should start with +7 for Russia, don't enter any special characters or spaces at all, it should work.

majn commented 9 years ago

@workintrust Last Week I've added some input validation for the username input, this might have caused the bug, I'll have to look at it I wasn't aware of that until now.

gammy commented 9 years ago

@majn In my case my country code is +46 (Sweden) although searching the web for similar issues led me here. So, I enter "+46739xxxxxx" (without quotes) where "739" is my mobile number prefix; in-land that'd be "0739", ie exactly as you described in your German example. Presumably any input validation should accept this. Can I perhaps view the post-validation string with some debug flags to pidgin?

gammy commented 9 years ago

Looking at https://github.com/majn/telegram-purple/commit/dbd7d5638b29b515bcf356998ddeac8d7f74a74b I don't see anything that sticks out in particular. The problem might be elsewhere.

majn commented 9 years ago

I'm going to remove the input validation in the next minor version, there isn't really a point in doing this, I should just pass the input as-is to the telegram server, which then will validate the phone number. You can try the current bugfix branch and see if it works (the input validation is gone there) https://github.com/majn/telegram-purple/commits/bugfixes-0.6.1

gammy commented 9 years ago

@majn I just tried the bugfixes branch and noticed that you've removed the function now. I still get the error message, albeit in the nicer message box.

majn commented 9 years ago

@gammy Thanks for testing this.

Without the validation, the entered phone number is just read from the settings and put into the libtgl function, so either:

  1. There is some bug in libtgl. You could test this with the telegram terminal application ( https://github.com/vysheng/tg ), which uses the same library. if it fails there too, I don't think that it is a bug in telegram-purple.
  2. The Telegram Server refuses the phone number, or refuses the query because of flood protection or something like that. Run pidgin with "-d" flag on the terminal to see the output, it contains the error code of why the request failed.
gammy commented 9 years ago

@majn, I'd take a closer look if I had more time!

telegram-cli (git-r754.01f5d9a-1) worked just fine with the telephone number. Running pidgin with the debug flag doesn't reveal anything new:

(13:10:07) prpl-telegram: error for query #6109734461934723072: #400 PHONE_NUMBER_INVALID
(13:10:07) connection: Connection error on 0x2bfab80 (reason: 2 description: Please enter only numbers in the international phone number format, a leading + following by the country prefix and the phone number.
Don't use any whitespaces or any other special characters.)
(13:10:07) account: Disconnecting account XXX (0x24702d0)
(13:10:07) connection: Disconnecting connection 0x2bfab80
(13:10:07) prpl-telegram: tgprpl_close()
majn commented 9 years ago

It works in telegram-cli, so apparently I'm doing something wrong. This should help me finding the issue, thanks.

gammy commented 9 years ago

Any progress on this? I just gave the plugin another go (on master, 8fec18e8c434e4546ab88e2d3143c59c47d9c169) and it remains the same. If you have more tests for me, I'd be willing to try them out.

ghsrcgh commented 7 years ago

The correct numbers for Russia is +79xxxxxx. Format: 89xxxxxx it is an internal format in Russia, not used for international calls/etc (it will fail, of course). WebTelegram at telegram.org allows to enter number only in format (+CountryCode) (PhoneNumber). So it is OK to validate in the same way as Telegram's do.

User @workintrust had entered incorrect number.

dennissherb commented 1 year ago

This problem persists for me, trying to set up pidgin with israel +972501231231 for 0501231231 but the phone number is still invalid for some reason