Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?php
  2. if (!file_exists('madeline.php')) {
  3. copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
  4. }
  5.  
  6. include 'madeline.php';
  7.  
  8.  
  9. class EventHandler extends \danog\MadelineProto\EventHandler
  10. {
  11. public function __construct($MadelineProto)
  12. {
  13. parent::__construct($MadelineProto);
  14. }
  15. public function onUpdateSomethingElse($update)
  16. {
  17. // See the docs for a full list of updates: http://docs.madelineproto.xyz/API_docs/types/Update.html
  18. }
  19. public function onUpdateNewChannelMessage($update)
  20. {
  21. yield $this->onUpdateNewMessage($update);
  22. }
  23. public function onUpdateNewMessage($update)
  24. {
  25. if (isset($update['message']['out']) && $update['message']['out']) {
  26. return;
  27. }
  28. $res = json_encode($update, JSON_PRETTY_PRINT);
  29. if ($res == '') {
  30. $res = var_export($update, true);
  31. }
  32.  
  33. try {
  34. if (strpos($update['message']['message'] , '@ ') !== false) {
  35. yield $this->messages->sendMessage(['peer' => '@avalanchetoday', 'message' => $update['message']['message'], 'reply_to_msg_id' => $update['message']['id']]);
  36. } }catch (\danog\MadelineProto\RPCErrorException $e) {
  37. yield $this->messages->sendMessage(['peer' => '@danogentili', 'message' => $e]);
  38. }
  39.  
  40.  
  41. }
  42. }
  43.  
  44.  
  45. $MadelineProto = new \danog\MadelineProto\API('session.madeline');
  46. $MadelineProto->async(true);
  47. $MadelineProto->loop(function () use ($MadelineProto) {
  48. yield $MadelineProto->start();
  49. yield $MadelineProto->setEventHandler('\EventHandler');
  50. });
  51. $MadelineProto->loop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement