[Python] Telegram Bot "chat not found"

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I have the following code in Python to send a message to myself from a bot.

    import requests

    token = '123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI'
    method = 'sendMessage'
    myuserid = 1949275XX
    response = requests.post(
    url='https://api.telegram.org/bot{0}/{1}'.format(token, method),
    data={'chat_id': myuserid, 'text': 'hello friend'}
    ).json()
    print(response)


    but this returns {'description': 'Bad Request: chat not found', 'error_code': 400, 'ok': False}

    What am I doing wrong? I got myuserid by sending /getid to @myidbot and I got my token from @BotFather

    Continue reading...

Compartilhe esta Página