Найти - Пользователи
Полная версия: pyTelegramBotAPI поиск юзернейма(@username) по ID человека
Начало » Python для новичков » pyTelegramBotAPI поиск юзернейма(@username) по ID человека
1
danker038
API TelegramBot библиотека “telebot”
Есть ли такая возможность узнать юзернейм(@username) или Имя человека зная его id c помощью бота, без личной переписки человека с ботом?
Если есть, то как?

Как пример @SangMataInfo_bot, он может найти все юзернеймы человека по его id
py.user.next
Эти методы попробуй
https://core.telegram.org/method/users.getUsers
https://core.telegram.org/method/users.getFullUser
danker038
немного не разобрался, как их использовать
как и куда вставлять
можете подробнее рассказать?
py.user.next
danker038
как и куда вставлять
У тебя должен быть бот в виде кода. Вот его скинь сюда.
danker038
 import telebot
bot = telebot.TeleBot(token)
def log(message):
    print("Message from {0}, {1}, id = {2}\nMessage text: {3}".format(message.from_user.first_name, message.from_user.last_name,
                  str(message.from_user.id), message.text))
    log(message)
@bot.message_handler(content_types=['text'])
def send_text(message):
    ID = message.text
    """
        тут он должен обработать ID и выдать @username пользователя, никогда не писавший лично боту что 
        либо
    """
    log(message)
bot.polling(none_stop=True)

например я дал боту чей то ID, бот должен отдать его @username, но пользователь может даже не знать этого бота.

py.user.next
Скорее всего, не получится так сделать. У Telegram боты сильно ограничены.

https://core.telegram.org/api
We offer two kinds of APIs for developers. The Bot API allows you to easily create programs that use Telegram messages for an interface. The Telegram API and TDLib allow you to build your own customized Telegram clients.

https://core.telegram.org/api/obtaining_api_id
Obtaining api_id

In order to obtain an API id and develop your own application using the Telegram API you need to do the following:

Sign up for Telegram using any application.
Log in to your Telegram core: https://my.telegram.org.
Go to ‘API development tools’ and fill out the form.
You will get basic addresses as well as the api_id and api_hash parameters required for user authorization.
For the moment each number can only have one api_id connected to it.

We will be sending important developer notifications to the phone number that you use in this process, so please use an up-to-date number connected to your active Telegram account.

То есть тебе придётся делать приложение, потом давать его под наблюдение и ещё сообщать свой телефон.
danker038
Ладно, спасибо!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB