Repost from a third-party Telegram channel (PHP MadelineProto)

 
3r3-31. Having decided to tackle a shameless copy-paste (or rather, its automation) of posts from someone else's Telegram-channel into my own, I first got into the documentation on telegram bots. But as it turned out, bots not only have no methods for receiving messages, they simply cannot be added to another channel.
 
 
The solution was needed in PHP and the next hour was spent searching for it. It's amazing how little information about this is [i] (although no, no wonder who writes this in PHP at all ) 3r339. . In general, the road with StackOverflow resulted in 3r311. MadelineProto
. The library has quite a few links in the network
 
 
What is 3r320. Madeline [/b] ? This is a PHP telegram client that provides methods for working both on behalf of the user and on behalf of the bot. The purpose of the article is to first shorten the search path 3r320. Madeline [/b] and draw attention to it. It is also interesting to learn from habravchan that there is a similar on other PL?
 
 
Well, of course, publish for example a piece of code that solved my problem:
 
 
3r330. //Connecting Madeline from github
if (! file_exists (__ DIR__. '/madeline.php')) {
copy ('https://phar.madelineproto.xyz/madeline.php', __DIR__. '/madeline.php');
}
include __DIR__. '/madeline.php';
$ MadelineProto = new danogMadelineProtoAPI ('session.madeline');
$ MadelineProto-> start ();
$ me = $ MadelineProto-> get_self ();
danogMadelineProtoLogger :: log ($ me);
/* Get the message history * /
$ messages = $ MadelineProto-> messages-> getHistory ([
/* Название канала, без @ */
'peer' => 'chatname',
'offset_id' => 0,
'offset_date' => 0,
'add_offset' => 0,
'limit' => 20,
'max_id' => 9999999,
/* ID сообщения, с которого начинаем поиск */
'min_id' => $lastid,
]);
/* Messages, sorting by date (new above) * /
$ messages = $ messages['messages'];
foreach (array_reverse ($ messages) as $ i => $ message) {3r33838. /* Helmet post to your channel * /
$ MadelineProto-> messages-> sendMessage ([
'peer' => 'mychatname',
'message' => $message['message']
]);
}
+ 0 -

Add comment