I need telegram bot which can delete message in group channel
i googled it but did not find a solution
Could you tell the library and the method for this, if you know, thank you in advance?
To delete ANY messages you would need the full Telegram API, as you cannot do this from the Bot API.
The required method in Telegram API is:
channels.deleteMessages#84c1fd4e channel:InputChannel id:Vector<int> = messages.AffectedMessages;
Telegram bot API doesn't support delete any message at this time, even in group or private chat.
I think you can try telegram-cli, a third-party unofficial Telegram client, and use it's delete_msg method.
In the bot API 3.0 the method used is "deleteMessage" with parameters chat_id and message_id
Not yet officially announced
You may delete messages only with telegram api, not bot api. With telethon (python client for telegram API) you can do it this way:
client.invoke(DeleteMessagesRequest(chat, [msg.id]))
Related
I have a bot that's supposed to forward news from other news channels. How do I make the bot join these channels so it could access all the messages that are being posted? I'm using pyTelegramBotApi. How should I go about doing this? Any help would be appreciated.
Only a channel admin can subscribe a bot to the channel.
A way that doesn't require admin rights in a source channel is to use the MTProto API (a telegram client library, e.g. Telethon library) instead of the Bot API.
I encountered the problem of deleting all messages (including messages from the bot itself) in the telegram chat. How i can do this? I use the telegram.ext library.
Telegram Bot API doesn't have methods to delete multiple messages. You have to know message_id to delete it.
python-telegram-bot library has support to only Bot API. You can make use of telethon library which supports Telegram API.
There is a delete_message method in the bot object, as described in the python-telegram-bot Documentation
Example:
bot.delete_message(chat_id=message.chat_id,
message_id=message.message_id,
*args,
**kwargs)
Remember that there are some limitations:
A message can only be deleted if it was sent less than 48 hours ago.
Bots can delete outgoing messages in groups and supergroups.
If the
bot is an administrator of a group, it can delete any message there
If the bot has can_delete_messages permission in a supergroup or a
the channel, it can delete any message there.
Hi everyone i want to create a new telegram bot similar to #usinifobot.
this is how it works:
you just send someone username to this bot and it will give you back his/her chat id.
i want to do same thing but i dont khow how to do it with python-telegram-bot.
python-telegram-bot can't help with this, because telegram bot api can't provide ids of unrelated entities to the bot - only ones with which bot iteracts
you need telegram client api for this and to hold a real account (not a bot) online to make checks by another library
and with bot library like python-telegram-bot you could only get ids of users who write to bot, channels and groups bot is in and reposted messages from other users
I created similar bot #username_to_id_bot for getting ids of any entity and faced all these moments
I'm programming a Telegram bot. I want to search for a specific message in a telegram channel and get its message id. Is it possible? Thx in advance.
As far as I know, you aren't able to search though messages (in a specific chat) by just using Telegram's bot API. You need an MTProto client to do that. You can use pyrogram or telethon to interface with MTProto then use messages.search.
But, there is a catch. If the message you're searching is in a channel, you can webscrape https://t.me/s/CHANNELUSERNAME with a library like BeautifulSoup.
I'm working on a Slack bot that #-mentions non-bot users into a particular channel. Is it possible to also invite these users to the channel when they are mentioned? (Like when a non-bot user mentions another non-bot user)
I'm using the Python slack client for this, but I suspect what I want to do is at the API level. Any ideas would be appreciated!
The python library don't have the api call wrapped (you could open an issue for that) but the API itself have a way to invite users to a channel, you just need to make a request to channels.invite