I want to create a telegram bot in which a user can send a media group along with text and another user will receive it as a media group. I know that it can be done with sendmediagroup, but how to do it so that the media does not need to be saved, but can be forwarded immediately, like copy_message or forward_message?
You can just use sendMediaGroup() to send media files instead of forwarding it. Forwarding media group files is not supported yet I think.
Related
My telegram bot receives messages sent by user to my bot in private chats but not receives messages sent by users in group chats. Any options/api for getting group chat messages also,.
Talk to #botfather and disable the privacy mode.
Sequence within a BotFather chat:
You: /setprivacy
BotFather: Choose a bot to change group messages settings.
You: #your_name_bot
BotFather: 'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username.
'Disable' - your bot will receive all messages that people send to groups.
Current status is: ENABLED
You: Disable
BotFather: Success! The new status is: DISABLED. /help
By default A Bot will receive only messages addressed to it by any user directly via posting by /command#YourBot any message you send.
After that it vill be available via getUpdates API call.
In browser it will be:
https://api.telegram.org/botToken/getupdates
Find the related message in output JSON and grab chatId. It will allow you to answer back with:
https://api.telegram.org/botToken/sendmessage?chat_id=123456788&text=My Answer
Make your bot by admin in group.
You can access all avaliable settings from all of your bots by sending /mybots to Botfather. Choose the bot, then Bot Settings and Group Privacy. If its disable (default), you can tap on Turn off.
Now its possible to receive the chat history using GetUpdates. This can be done via HTTP API or the frameworks. For example, in C# (.NET Core) like this:
var bot = new TelegramBotClient(ApiToken);
var updates = bot.GetUpdatesAsync().Result;
foreach(var update in updates) {
Console.WriteLine($"{update.ChannelPost.Date} {update.ChannelPost.Text}");
}
But keep in mind that this feature has some kind of perfect forward secrecy implemented. So you only get messages that were send after group privacy is disabled. As a result, the GetUpdates result is empty until some post was made.
if you added your bot before disable the privacy mode, you should remove the bot from the group and add it again
I have been asked to try and get something working in our slack environment for our campus locations to use. The goal is to have a user input the location which would initiate the API call to the other system and return some basic high level system health stats.
I am familiar with how to setup webhooks to slack, just not sure if it's possible to do this or not with slack.
The slack API (https://api.slack.com/) is fairly complex to get set up, but it will do what you want once you get there. It has a web API that you can register to receive hooks from when things appear in messages or chats, for example, and thus you can trigger things to run when people say certain things, for example.
If I understand correctly, you want a user to input a location on slack, and based on their input to make an API call to a different service.
You have several options to get the input from the user:
You can create a bot that the user can chat with
You can create a shortcut or workflow that users can use to fill some kind of form
You can allow for interactions on your application's home page
All these options will get slack to send a payload to some endpoint you define. You will have to set up some basic back end to handle this and call your external APIs from.
I'm currently working on a similar project and recommend using some serverless, fast setup. I have opted for Lambda and API gateway for this. The experience is:
The user goes to the app home page and presses a button
The user gets a form to fill
On form submission, slack sends a payload to an endpoint set via API gateway
API gateway summons a lambda function
The function parses and validates the payload, and ultimately makes a request to my external API
I already have the main script. Now I only need the method that will send a certaing message from my account (my name) to another person automatically. Is it possible to send messages that way?
You would have to use the Telegram Database Library, which is a set of APIs you can use to control your user's actions via HTTP requests. Then you'll use the sendMessage class to send a message as yourself. The Get Started page pretty much has everything you need for your project.
Source: https://core.telegram.org/#tdlib-build-your-own-telegram
I've got a bluetooth RGB bulb that I want to use for notifications in discord. It seems that following standard guides I would need to get an admin to add a bot account to each discord I wanted this functionality in.
Is there a way to get access to messages accessible in my main account without getting another account/bot added? I only need to be able to read out the messages so I can parse them and trigger RGB stuff.
I would prefer to do this in python if possible but other solutions are fine if need be.
Self bots are against discord's TOS.
You can try using on_message(message) and using that to parse the message.content
I'm having a problem forwarding messages with multiple media files (in my particular case, photos).
I'm using forwardMessage method to forward the message that user sends to bot (which, in some cases, might contain more than one photo):
bot.forwardMessage(admin_id, from_chat_id, message_id)
But, the thing is, according to Telegram API v3.5, the message which contain media group breaks up into array of messages, and hence the bot breaks up the message from user into multiple messages. E.g. if user have sent a message with 3 photos, then the bot forwards 3 messages, each of which contains a photo.
What I want is to forward a message with multiple media files as it is, as one message, not as multiple messages.
I know that probably I can take each photo from each message that the bot receives, put them one-by-one into array, and then send it from the bot using sendMediaGroup method, but I'd like to know if I can get it working with forwardMessage method.
Thanks in advance.
You can't forward original content via forwardMessage, for instance, you can't forward with an inline keyboard.
I think this may be a mistake, you can suggest that to #BotSupport.
Telegram API had updated a method call sendMediaGroup for sending images as album.
https://core.telegram.org/bots/api#sendmediagroup
Have a look :)