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.
Related
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
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]))
My question is:
how to join my telegram bot to a telegram public channel that I am not an administrator of it, and without asking the channel's admin to add my bot to the channel?
Maybe, the chatId of channel or thru link of channel?
I have heard that some people claim to do this join their bot to channels, and scrape data.
So if Telegram does not allow it, how can they do it? can you think of any work around?
Thank you in advance :)
Answer to your edited question.
It was possible to add a bot to a group/channel with just an invite link. This was achieved by allowing a bot to access the mtproto methods like messages.importChatInvite for private links and channels.joinChannel. However telegram patched this. However, you can still do this with normal user accounts! Since you are using python you can give this a shot. I can confirm the methods still work on Madeline Proto.
Till today, only the Channel Creator can add a bot (as Administrator or Member) to the Channel, whether public or private. Even the other Channel Administrators cannot add a normal member leave alone adding a bot, rather they can only post into the channel.
As far as joining the bot via the invite link, there is yet no such method in Bot API to do so. All such claims of adding the bot to a channel by non Creator are false.
Another way of "scraping the data" from several channels would be to listen to these channels with a Junction Bot aka Channels, Multi Feed Edge Bot, or alike. You just need to go to the channel info and share the link of the desired channel with the Junction Bot to automate the process of receiving new messages from the(se) channel(s). There are also other quite advanced ways described in their FAQ.
Multi Feed Edge Bot also seems to work O'kay, however, you need to follow these steps to add the redirection:
/add #TelespaceNews https://t.me/joinchat/AAAAAFIaTHjZp8ltykgwEQ
You can only add bots to channels you are an admin in them and bots can only be added as admins. for this go to Manager Channel, click on Administrators / Add Administrator then search for the bot you want to add to your channel.