i've set up a working telegram bot that get's triggered on a /mission command. I want to use the bot within groups to enable a fast response feedback system for my organization. the flow is like follows:
1) a API client (no bot, just pure api) sends a message to a group, triggering the bot using /mission .
2) the bot responds to the command and the feedback process starts..
As a normal user, I can trigger the bot whereas the api user won't even reach my bot using webhooks.
Is there any known limitation on what APIs can trigger?
thanks!
Telegram MTProto API has same limits and same benefits of a normal Telegram user. So, you can trigger all bots you want, but be careful with FLOOD_WAIT error: an user sends too much messages in one second or in one minute, Telegram blocks the user for x seconds.
If you don't want to setup tg-cli, and other stuff to run MTProto client on your server and control it, I suggest you to use PWRTelegram APIs, so logging in as user.
Related
I need to synchronize telegram channel posts with my site. So, I created a bot, a channel, added my bot to this channel(with admin rights, it has access to messages) and binded my bot's webhook to the specified server url. Everything goes well, post creation updates are correctly sent to the server url. The only problem is that the update of channel post deletion from telegram is not tracked, so admin has manually delete posts from the server database. Any idea, how to set up bot or webhook in order to track post deletion?
This is not possible using Bot API since Telegram doesn't send most of the events to Bot accounts.
You should instead use MTRPOTO to connect to a number on Telegram as a normal user (not a bot) that is the admin or subscriber of that channel and receive all of the events from Telegram.
I'd suggest you use Telethon (A Python MTPROTO library).
Upon a message deletion, you will receive MessageDeleted event.
There's an example on Telethon's document website:
from telethon import events
#client.on(events.MessageDeleted)
async def handler(event):
# Log all deleted message IDs
for msg_id in event.deleted_ids:
print('Message', msg_id, 'was deleted in', event.chat_id)
But if you insist on doing this with bot API, there's a spaghetti solution. You can forward channel posts to another chat with their Ids, if you get a message doesn't exist error, that means the message was deleted.
I tried this:
https://api.telegram.org/botXXtokenxx/sendMessage?chat_id=chat_id&text=text
But this is to send a message from the bot.
But what I need to do to send to the bot? (not from the bot)
You can either use a regular Telegram client (Telegram, Telegram X, Telegram Desktop, etc) to do it manually, or if you need an API (for whatever reason)...
You need the client API.
https://core.telegram.org/#getting-started
Once you have an API key for the client API and all that, you can send messages as explained here.
https://core.telegram.org/method/messages.sendMessage
Note that a human should be triggering this, as Telegram encourages (may be against ToS?) using a bot API for programatic access rather than the client API.
I have problems with telegram's api in c#. I search any solutions how to recevie message from Telegram using API. I found only library for Telegram BOT(send message etc.), but I need only recevie message from one user. There is option "Get.Message" in Telegram Api, but I can't find simply library to use this option.
using the telegram client api you can get updates automatically from telegram when a message is received. You simply need to handle the response once the session is created and a connection is made
Just in case you don't want realtime updates, you can use messages.GetHistory and supply the number of messages you'd like to retrieve. You need to provide the chat ID and access hash which you can get from contactsResolveUsername
enter link description here
I'm working on Telegram bot api in my java application. I have created a super group and add my bot to this as an administrator. I want to get all messages in that super group(not deleted messages) via bot. Is there any useful method for doing that?
Yes. first, you should "disable" privacy of your bot so it can access to all messages in groups. second, use getUpdates to see recent updates and user messages will be there.
I am new to the Telegram API.
I would like to automate posting messages to my public telegram channel.
I read a few posts that with bots I can achieve this, but I am not sure if that's the best way and whether the API has an option to directly post to a channel.
I would like to get some start points on how to achieve this?
Which API should I use?
Whether I need a dev account or bot, etc?
You can use bots to send message to channels. But there is some limitation, like size of files.
create your bot, by sending message to #botfather
add the bot to your channel. stackoverflow
write a code to send message to your channel. bot api
After 1 year of working with telegram API, I wanted to update this answer for best possible ways to interact with telegram API.
For posting to channels, both telegram API and telegram bot API can post to channels.
I worked directly with both the APIs, but I found the following clients for telegram API and bot API to be faster and easier to interact with telegram.
Telegram API client:
https://github.com/LonamiWebs/Telethon
Telegram bot API:
https://github.com/python-telegram-bot/python-telegram-bot
It is impossible to read messages from Telegram channels using Telegram Bot API.
In order to be able to scrape messages from Telegram channels that you do not own, you need to develop you own Telegram client that is capable of:
Joining your desired channels by links
Forwarding messages, arriving to the channels your client is subscribed to, to your own Telegram channel
In order to develop your own Telegram client, you need to use some implementation of MTProto.
You can find a lot of implementations of MTProto on https://github.com using mtproto keyword.
A few examples of well-documented implementations:
In PHP: https://github.com/danog/MadelineProto
In Python: http://github.com/LonamiWebs/Telethon
But probably it would be an overkill to develop your own solution to this problem if the only thing you want is to have several redirections from existing Telegram channels to your own channel.
There are applications that provide such a service.
For example, there is MultiFeed Bot from telespace.me team:
https://telespace.me/apps/multifeed_bot
It allows you to setup forwarding of messages within Telegram as well as redirections to external services.