问题
I have many telegram channels, 24\7 they send messages in the format
- "buy usdjpy sl 145.2 tp 167.4"
- "eurusd sell sl 145.2 tp 167.4"
- "eurusd sl 145.2 tp 167.4 SELL"
or these words in some order
My idea is to create app that checks every channel's message, and redirects it to my channel if it is in the above format.
Does telegram api allow it?
回答1:
I solved a similar problem with TdLib. Their GitHub site has full C++, Java and C# examples that you can just modify.
I worked on the Java example, and applied most of my changes to the UpdatesHandler.onResult
method (line 353). The C++ and C# examples have a similar structure. This method gets called by Td whenever any event occurs. Hence you can just intercept them there.
If you're not really sure where to begin, start by adding simple System.out.println
statements (if using Java) to each of the case statements in the aforementioned method, and make sure you read the starting guide.
They actually have examples for many other languages (Python included), but from my point of view they are not as complete as the three I mentioned before.
回答2:
You cannot scrape from a telegram channel with a bot, unless, the bot is an administrator in the channel, which only the owner can add.
Once that is done, you can easily redirect posts to your channel by listening for channel_post
updates.
回答3:
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 that allows you to setup forwarding of messages from any Telegram channels to your own Telegram channel.
This bot has a flexible filtering system so it should be pretty easy to setup filters to skip certain types of messages (ads, media content and etc.) and to leave only those messages that you want to see in your destination channel.
回答4:
I have written a simple python code, using the telethon
python module.
What the code basically does, is forwarding messages from various telegram channels through the telegram client api to a channel of your choosing. You can find it here.
Using the client api, one is able to read messages from groups and channels that your user is a part of. No bots required.
The telethon
module makes it easy to filter messages that you want to be read. Feel free to fork the project and make the desired changes. You should look at the module documentation here.
回答5:
This is very easy to do with Full Telegram API.
- first on your mobile phone subscribe to all the interested channels
- Next you develop a simple telegram client the receives all the updates from these channels
- Next you build some parsers that can understand the channel messages and filter out what you are interested in
- Finally you send the filtered content (re-formatted) to your own channel.
that's all that is required.
回答6:
Is this what are you looking for? telegram-forward-bot
In the readme file:
Simple Telegram Bot for forwarding messages easily between various related channels and groups.
This bot allows you to automatically forward messages between different channels. We use it on our Student Comitee because we have like 15 different Telegram groups for each commission we are working on. Then, if we want some commission receives some important information, we can automatically forward to them using hashtags at the beggining of the message (or the caption of a media file).
I think I know your feeling, I'am trader and I follow various prediction channel. But not all of the information is usefull (sometimes ads). Hope this work for you :)
回答7:
Got the solution to this problem. Here is bot which automatically forwards messages from one channel to another without the forward tag. Moreover the copying speed is legit! @copythatbot This is the golden tool everyone is looking for.
来源:https://stackoverflow.com/questions/42430232/how-can-i-redirect-messages-from-telegram-channels-that-are-in-certain-formatt