How to make when a user clicks the button, he was sent a certain file (file, photo, video) from a private channel (bot admin in the channel) in the user's PM in the bot?
I tried to send a link via send.message (link to the message in the private channel), gives an error: aiogram.utils.exceptions.InvalidHTTPUrlContent: Failed to get http url content
Related
I started writing a bot for a private chat in Telegram. I ran into a problem.
url = "here I entered the link for the invitation"
channel = waiting for the client.get_entity(url)
Returned the error `ValueError: cannot find any object matching the 'link'
Nothing came of it.
As a result, I changed the chat type to public, created a link, inserted it into the url = ""
It worked, but how to receive and filter messages from a public chat.
Tried to get a link via
https://t.me/getmyid_bot
so im playing a little bit around with my telegram bot, now im already able to send normal messages and pictures. But now i want to be able to send pre recorded voice messages as an answer. In the documentation it says to use send_voice for this matter and it recommends using the file_id of a file thats already on the telegram servers. So thats what i did i send a voice message to the #RawDataBot and he returned to me the file_id of the voice message.
Problem is: When i try to trigger it i get the following error: telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: wrong file identifier/HTTP URL specified
Any ideas here on what i might be doing wrong? Here is the relevant code:
import telebot
API_KEY = <MY_API_KEY>
bot = telebot.TeleBot(API_KEY)
#start
#bot.message_handler(commands=['start'])
def start (message):
bot.send_message(message.chat.id,Textstart)
#bot.message_handler(commands=['pic'])
def start (photo):
bot.send_photo(photo.chat.id, "https://de.wikipedia.org/wiki/Zeus#/media/Datei:Zeus_Otricoli_Pio-Clementino_Inv257.jpg")
#here is the part where he is supposed to send the voice message if someone types in /audio
#bot.message_handler(commands=['audio'])
def start (voice):
bot.send_voice(voice.chat.id,"AwACAgIAAxkBAAEWjl5i5bjyudWAM9IISKWhE1Gjs5ntQgACLx8AApcNKEv97pVasPhBoCkE",)
bot.polling()
There are multiple reasons, but I think it is because of these:
file_id is unique for each individual bot and can't be transferred from one bot to another.
file_id uniquely identifies a file, but a file can have different valid file_ids even for the same bot.
See here.
elif message.text == 'Test':
video = open('static/ct_ramp.mkv','rb')
await message.answer_video(video)
video.close()
I use aiogram and this code to sending my video but I should upload it to see
: https://i.stack.imgur.com/NcYjg.png
How can I send it and see it right now?
You can't. Each user must configure their own Telegram client for automatic downloading of media. You or your bot can't force that in the user side.
What you can do is configure your own Telegram client (android, desktop, etc.) to use automatic download of videos, then the autoplay feature will work for big size videos for you.
I have made a website , and there are users in it who can send and receive messages to each other, i need to develop a mechanism in which when message is send to a user & if user is login it shows him a message that you have received a message without refreshing the page or fetching from database if message received . just like it is working in facebook and many other sites actually i want to make a chat between 2 users.
I'm working on a chat application using GAE's Channel API in Python.
I don't think I've set it up correctly. When I leave a page I get the following error message in my browser console:
http://localhost:8080/_ah/channel/dev?command=disconnect&channel=0e0acee3bd…122e0acaa86eeb-channel-1354440420-1452408747-mike|5066549580791808&client=1 400 (Bad Request)
Also, when I send chat message it sends duplicate messages, so I'm guessing users are not being properly disconnected.
I've set it up such that when user visits page, my backend code checks if they are logged in, and if so will automatically create token based on their username and the permalink ID of the page.
I then create a token, calling channel.create_channel method and pass that token as a value in the dict I include when I render my template (Jinja).
In my front-end I open the channel with the token. My on-close function is:
socket.onclose = function(){
connected = false;
}
In my app.yaml file I have included inbound_services: - channel presence.
In my backend code, I have '/_ah/channel/disconnected/'routed to a class that gets that permalink's entity instance, finds the client id from a list of connections and removes that connection from the entity.
Can you someone help me think about the Channel API the right way?