can make it so that by means of a POST telegram request the bot will send a message to a specific user
The code for this action looks something like this:
import request
id_user = '1234567890'
message = ‘Hello!’
url = “https://api.telegram.org/botTOKEN_MY_BOT/sendMessage”
payload = {
'chat_id': id_user,
'text': message
}
requests.post(url, data=payload)
——————
Do you know if it is also possible, using the REQUESTS library, to perform requests through which a telegram bot running on TELETHON will send a message to a specific user?
Interested in sending via REQUESTS
Yeah it's possible but it's like you go through a 1000 km way instead on going through a 10 km way which is shorter and better. Telegram bot frameworks have been made to ease working with bot api
Yes, thank you, but still, if you know, please give me a code example) Something like (pseudo code): import request import Telethon.session as TS id_user = '1234567890' message = ‘Hello!’ url = “https://api.telegram.org/botTS/sendMessage” payload = { 'api_id': api_id, 'api_hash', api_hash, 'chat_id': id_user, 'text': message } requests.post(url, data=payload)
There is none. if you want one, you have to make your own API for it
Does this mean that I can ONLY send messages from the executable file in which TELETHON is running? Or are there other ways?
yes. unless you make your own api for it
The question is in continuation of the topic of my own api. For example, I launched Flask with endpoint, which accepts the request and after processing it, how should the method of sending a message on behalf of the TELETHON bot be called? I don't understand it, because a file with Flask is one file, and a file with TELEPHONE is another file. It is likely that you need to import some methods from the running TELETHON file into the Flask file. Am I right?
The flask api needs the telethon to run with it in the same place. then you call your own api with "requests" aka the Flask, your api needs to call telethon' client instance to conduct the action also telethon is async, using Flask will be harder, use Quart instead
For an async approach, instead of Flask, I should use QUART or AioHTTP, right?)
Hello dear sir , i have one question, currently I am steaming to another platform using item_download , so is there any limitations, that 1000 or 10k can viewer can watch a video at once ? 😄 I am asking this question to avoid in trouble in future Currently i have 30 50 viewer
you have to test it on your own. Telegram downloads have limits for active processes at once. unless you cache them locally and download once
Обсуждают сегодня