N
N
nak-alexey2020-08-04 09:49:13
Python
nak-alexey, 2020-08-04 09:49:13

Why doesn't python send messages to telegram?

There is the following code

def send_telegram(text: str):
    token = token
    url = "https://api.telegram.org/bot"
    channel_id = channel_id
    url += token
    method = url + "/newpost"

    r = requests.post(method, data={
         "chat_id": channel_id,
         "text": text
          })

send_telegram("hello world!")

When it is executed, the message is not sent to the bot, all details are correct.
when I do print(r.text) writes
{"ok":false,"error_code":404,"description":"Not Found"}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Krostelev, 2020-08-04
@nak-alexey

What is the newpost method ?
Maybe you should use sendMessage ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question