2017-06-01 22:21:15 +02:00
#!/usr/bin/env php
< ? php
2019-10-28 22:39:23 +01:00
/**
* Secret chat bot .
*
* Copyright 2016 - 2019 Daniil Gentili
* ( https :// daniil . it )
* This file is part of MadelineProto .
* MadelineProto is free software : you can redistribute it and / or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation , either version 3 of the License , or ( at your option ) any later version .
* MadelineProto is distributed in the hope that it will be useful , but WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
* See the GNU Affero General Public License for more details .
* You should have received a copy of the GNU General Public License along with MadelineProto .
* If not , see < http :// www . gnu . org / licenses />.
*
* @ author Daniil Gentili < daniil @ daniil . it >
* @ copyright 2016 - 2019 Daniil Gentili < daniil @ daniil . it >
* @ license https :// opensource . org / licenses / AGPL - 3.0 AGPLv3
*
2019-10-31 15:07:35 +01:00
* @ link https :// docs . madelineproto . xyz MadelineProto documentation
2019-10-28 22:39:23 +01:00
*/
2019-10-28 19:48:59 +01:00
\set_include_path ( \get_include_path () . ':' . \realpath ( \dirname ( __FILE__ ) . '/MadelineProto/' ));
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
2018-03-23 16:39:58 +01:00
/*
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
* Various ways to load MadelineProto
*/
2019-12-26 15:14:27 +01:00
if ( \file_exists ( __DIR__ . '/../vendor/autoload.php' )) {
2019-10-28 22:39:23 +01:00
include 'vendor/autoload.php' ;
} else {
2019-10-28 19:48:59 +01:00
if ( ! \file_exists ( 'madeline.php' )) {
\copy ( 'https://phar.madelineproto.xyz/madeline.php' , 'madeline.php' );
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
include 'madeline.php' ;
2017-06-01 22:21:15 +02:00
}
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
class EventHandler extends \danog\MadelineProto\EventHandler
{
private $sent = [ - 440592694 => true ];
2018-03-23 16:39:58 +01:00
public function onUpdateNewEncryptedMessage ( $update )
{
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
try {
2018-03-23 16:39:58 +01:00
if ( isset ( $update [ 'message' ][ 'decrypted_message' ][ 'media' ])) {
2019-12-26 15:14:27 +01:00
$this -> logger ( yield $this -> downloadToDir ( $update , '.' ));
2018-03-23 16:39:58 +01:00
}
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
if ( isset ( $this -> sent [ $update [ 'message' ][ 'chat_id' ]])) {
return ;
}
$secret_media = [];
// Photo uploaded as document, secret chat
2019-12-26 15:14:27 +01:00
$secret_media [ 'document_photo' ] = [ 'peer' => $update , 'file' => 'tests/faust.jpg' , 'message' => [ '_' => 'decryptedMessage' , 'ttl' => 0 , 'message' => '' , 'media' => [ '_' => 'decryptedMessageMediaDocument' , 'thumb' => \file_get_contents ( 'tests/faust.preview.jpg' ), 'thumb_w' => 90 , 'thumb_h' => 90 , 'mime_type' => \mime_content_type ( 'tests/faust.jpg' ), 'caption' => 'This file was uploaded using MadelineProto' , 'file_name' => 'faust.jpg' , 'size' => \filesize ( 'tests/faust.jpg' ), 'attributes' => [[ '_' => 'documentAttributeImageSize' , 'w' => 1280 , 'h' => 914 ]]]]];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
// Photo, secret chat
2019-12-26 15:14:27 +01:00
$secret_media [ 'photo' ] = [ 'peer' => $update , 'file' => 'tests/faust.jpg' , 'message' => [ '_' => 'decryptedMessage' , 'ttl' => 0 , 'message' => '' , 'media' => [ '_' => 'decryptedMessageMediaPhoto' , 'thumb' => \file_get_contents ( 'tests/faust.preview.jpg' ), 'thumb_w' => 90 , 'thumb_h' => 90 , 'caption' => 'This file was uploaded using MadelineProto' , 'size' => \filesize ( 'tests/faust.jpg' ), 'w' => 1280 , 'h' => 914 ]]];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
// GIF, secret chat
2019-12-26 15:14:27 +01:00
$secret_media [ 'gif' ] = [ 'peer' => $update , 'file' => 'tests/pony.mp4' , 'message' => [ '_' => 'decryptedMessage' , 'ttl' => 0 , 'message' => '' , 'media' => [ '_' => 'decryptedMessageMediaDocument' , 'thumb' => \file_get_contents ( 'tests/pony.preview.jpg' ), 'thumb_w' => 90 , 'thumb_h' => 90 , 'mime_type' => \mime_content_type ( 'tests/pony.mp4' ), 'caption' => 'test' , 'file_name' => 'pony.mp4' , 'size' => \filesize ( 'tests/faust.jpg' ), 'attributes' => [[ '_' => 'documentAttributeAnimated' ]]]]];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
// Sticker, secret chat
2019-12-26 15:14:27 +01:00
$secret_media [ 'sticker' ] = [ 'peer' => $update , 'file' => 'tests/lel.webp' , 'message' => [ '_' => 'decryptedMessage' , 'ttl' => 0 , 'message' => '' , 'media' => [ '_' => 'decryptedMessageMediaDocument' , 'thumb' => \file_get_contents ( 'tests/lel.preview.jpg' ), 'thumb_w' => 90 , 'thumb_h' => 90 , 'mime_type' => \mime_content_type ( 'tests/lel.webp' ), 'caption' => 'test' , 'file_name' => 'lel.webp' , 'size' => \filesize ( 'tests/lel.webp' ), 'attributes' => [[ '_' => 'documentAttributeSticker' , 'alt' => 'LEL' , 'stickerset' => [ '_' => 'inputStickerSetEmpty' ]]]]]];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
// Document, secrey chat
2019-12-26 15:14:27 +01:00
$secret_media [ 'document' ] = [ 'peer' => $update , 'file' => 'tests/60' , 'message' => [ '_' => 'decryptedMessage' , 'ttl' => 0 , 'message' => '' , 'media' => [ '_' => 'decryptedMessageMediaDocument' , 'thumb' => \file_get_contents ( 'tests/faust.preview.jpg' ), 'thumb_w' => 90 , 'thumb_h' => 90 , 'mime_type' => 'magic/magic' , 'caption' => 'test' , 'file_name' => 'magic.magic' , 'size' => \filesize ( 'tests/60' ), 'attributes' => [[ '_' => 'documentAttributeFilename' , 'file_name' => 'fairy' ]]]]];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
// Video, secret chat
2019-12-26 15:14:27 +01:00
$secret_media [ 'video' ] = [ 'peer' => $update , 'file' => 'tests/swing.mp4' , 'message' => [ '_' => 'decryptedMessage' , 'ttl' => 0 , 'message' => '' , 'media' => [ '_' => 'decryptedMessageMediaDocument' , 'thumb' => \file_get_contents ( 'tests/swing.preview.jpg' ), 'thumb_w' => 90 , 'thumb_h' => 90 , 'mime_type' => \mime_content_type ( 'tests/swing.mp4' ), 'caption' => 'test' , 'file_name' => 'swing.mp4' , 'size' => \filesize ( 'tests/swing.mp4' ), 'attributes' => [[ '_' => 'documentAttributeVideo' , 'duration' => 5 , 'w' => 1280 , 'h' => 720 ]]]]];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
// audio, secret chat
2019-12-26 15:14:27 +01:00
$secret_media [ 'audio' ] = [ 'peer' => $update , 'file' => 'tests/mosconi.mp3' , 'message' => [ '_' => 'decryptedMessage' , 'ttl' => 0 , 'message' => '' , 'media' => [ '_' => 'decryptedMessageMediaDocument' , 'thumb' => \file_get_contents ( 'tests/faust.preview.jpg' ), 'thumb_w' => 90 , 'thumb_h' => 90 , 'mime_type' => \mime_content_type ( 'tests/mosconi.mp3' ), 'caption' => 'test' , 'file_name' => 'mosconi.mp3' , 'size' => \filesize ( 'tests/mosconi.mp3' ), 'attributes' => [[ '_' => 'documentAttributeAudio' , 'voice' => false , 'duration' => 1 , 'title' => 'AH NON LO SO IO' , 'performer' => 'IL DIO GERMANO MOSCONI' ]]]]];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
2019-12-26 15:14:27 +01:00
$secret_media [ 'voice' ] = [ 'peer' => $update , 'file' => 'tests/mosconi.mp3' , 'message' => [ '_' => 'decryptedMessage' , 'ttl' => 0 , 'message' => '' , 'media' => [ '_' => 'decryptedMessageMediaDocument' , 'thumb' => \file_get_contents ( 'tests/faust.preview.jpg' ), 'thumb_w' => 90 , 'thumb_h' => 90 , 'mime_type' => \mime_content_type ( 'tests/mosconi.mp3' ), 'caption' => 'test' , 'file_name' => 'mosconi.mp3' , 'size' => \filesize ( 'tests/mosconi.mp3' ), 'attributes' => [[ '_' => 'documentAttributeAudio' , 'voice' => true , 'duration' => 1 , 'title' => 'AH NON LO SO IO' , 'performer' => 'IL DIO GERMANO MOSCONI' ]]]]];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
foreach ( $secret_media as $type => $smessage ) {
2019-12-26 15:14:27 +01:00
yield $this -> messages -> sendEncryptedFile ( $smessage );
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
$i = 0 ;
while ( $i < 10 ) {
2019-12-26 15:14:27 +01:00
$this -> logger ( " SENDING MESSAGE $i TO " . $update [ 'message' ][ 'chat_id' ]);
2019-06-01 18:15:14 +02:00
// You can also use the sendEncrypted parameter for more options in secret chats
//yield $this->messages->sendEncrypted(['peer' => $update, 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => (string) ($i++)]]);
yield $this -> messages -> sendMessage ([ 'peer' => $update , 'message' => ( string ) ( $i ++ )]);
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
$this -> sent [ $update [ 'message' ][ 'chat_id' ]] = true ;
} catch ( \danog\MadelineProto\RPCErrorException $e ) {
\danog\MadelineProto\Logger :: log ( $e );
} catch ( \danog\MadelineProto\Exception $e ) {
\danog\MadelineProto\Logger :: log ( $e );
}
}
2017-06-01 22:21:15 +02:00
}
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
2019-10-28 19:48:59 +01:00
if ( \file_exists ( '.env' )) {
2017-06-01 22:21:15 +02:00
echo 'Loading .env...' . PHP_EOL ;
2019-10-28 19:48:59 +01:00
$dotenv = Dotenv\Dotenv :: create ( \getcwd ());
2017-06-01 22:21:15 +02:00
$dotenv -> load ();
}
echo 'Loading settings...' . PHP_EOL ;
2019-10-28 19:48:59 +01:00
$settings = \json_decode ( \getenv ( 'MTPROTO_SETTINGS' ), true ) ? : [];
2017-06-01 22:21:15 +02:00
2018-03-30 18:07:54 +02:00
$MadelineProto = new \danog\MadelineProto\API ( 's.madeline' , $settings );
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
$MadelineProto -> start ();
$MadelineProto -> setEventHandler ( '\EventHandler' );
2019-06-01 18:15:14 +02:00
$MadelineProto -> async ( true );
2018-03-23 16:39:58 +01:00
$MadelineProto -> loop ();