Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!file_exists('madeline.php')) {
- copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
- }
- include 'madeline.php';
- class EventHandler extends \danog\MadelineProto\EventHandler
- {
- public function __construct($MadelineProto)
- {
- parent::__construct($MadelineProto);
- }
- public function onUpdateSomethingElse($update)
- {
- // See the docs for a full list of updates: http://docs.madelineproto.xyz/API_docs/types/Update.html
- }
- public function onUpdateNewChannelMessage($update)
- {
- yield $this->onUpdateNewMessage($update);
- }
- public function onUpdateNewMessage($update)
- {
- if (isset($update['message']['out']) && $update['message']['out']) {
- return;
- }
- $res = json_encode($update, JSON_PRETTY_PRINT);
- if ($res == '') {
- $res = var_export($update, true);
- }
- try {
- if (strpos($update['message']['message'] , '@ ') !== false) {
- yield $this->messages->sendMessage(['peer' => '@avalanchetoday', 'message' => $update['message']['message'], 'reply_to_msg_id' => $update['message']['id']]);
- } }catch (\danog\MadelineProto\RPCErrorException $e) {
- yield $this->messages->sendMessage(['peer' => '@danogentili', 'message' => $e]);
- }
- }
- }
- $MadelineProto = new \danog\MadelineProto\API('session.madeline');
- $MadelineProto->async(true);
- $MadelineProto->loop(function () use ($MadelineProto) {
- yield $MadelineProto->start();
- yield $MadelineProto->setEventHandler('\EventHandler');
- });
- $MadelineProto->loop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement