danog / MadelineProto

Async PHP client API for the telegram MTProto protocol
https://docs.madelineproto.xyz
GNU Affero General Public License v3.0
2.74k stars 617 forks source link

Install error / difficulties #1527

Closed humpataa closed 2 weeks ago

humpataa commented 2 weeks ago

I have downloaded .phar file. I have added it to my code:

    require_once 'madeline81.phar';
/*
    if (!file_exists('madeline.php')) {
        copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
    }
    include 'madeline.php';
*/
    $MadelineProto = new \danog\MadelineProto\API('session.madeline');
    $MadelineProto->start();

    $me = $MadelineProto->getSelf();

    $MadelineProto->logger($me);

    if (!$me['bot']) {
        $MadelineProto->messages->sendMessage(peer: '@stickeroptimizerbot', message: "/start");

        $MadelineProto->channels->joinChannel(channel: '@MadelineProto');

        try {
            $MadelineProto->messages->importChatInvite(hash: 'https://t.me/+Por5orOjwgccnt2w');
        } catch (\danog\MadelineProto\RPCErrorException $e) {
            $MadelineProto->logger($e);
        }
    }
    $MadelineProto->echo('OK, done!');

I have removed top lines as I don't think it needs to be done because I have included phar-file, correct?

This is the error I get:

Amp\File\FilesystemException: Could not create directory '/var/www/vhosts/xxx/httpdocs/mad/session.madeline': mkdir(): Permission denied in phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/amphp/file/src/Driver/BlockingFilesystemDriver.php:158 Stack trace: #0 [internal function]: Amp\File\Driver\BlockingFilesystemDriver::Amp\File\Driver\{closure}() #1 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/amphp/file/src/Driver/BlockingFilesystemDriver.php(162): mkdir() #2 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/amphp/file/src/Filesystem.php(242): Amp\File\Driver\BlockingFilesystemDriver->createDirectory() #3 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/amphp/file/src/functions.php(235): Amp\File\Filesystem->createDirectory() #4 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/danog/madelineproto/src/SessionPaths.php(104): Amp\File\createDirectory() #5 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/danog/madelineproto/src/API.php(186): danog\MadelineProto\SessionPaths->__construct() #6 /var/www/vhosts/xxxx/httpdocs/mad/mad.php(9): danog\MadelineProto\API->__construct() #7 {main} Amp\File\FilesystemException: Could not create directory '/var/www/vhosts/xxxx/httpdocs/mad/session.madeline': mkdir(): Permission denied in phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/amphp/file/src/Driver/BlockingFilesystemDriver.php:158
Stack trace:
#0 [internal function]: Amp\File\Driver\BlockingFilesystemDriver::Amp\File\Driver\{closure}()
#1 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/amphp/file/src/Driver/BlockingFilesystemDriver.php(162): mkdir()
#2 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/amphp/file/src/Filesystem.php(242): Amp\File\Driver\BlockingFilesystemDriver->createDirectory()
#3 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/amphp/file/src/functions.php(235): Amp\File\Filesystem->createDirectory()
#4 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/danog/madelineproto/src/SessionPaths.php(104): Amp\File\createDirectory()
#5 phar:///var/www/vhosts/xxxx/httpdocs/mad/madeline81.phar/vendor/danog/madelineproto/src/API.php(186): danog\MadelineProto\SessionPaths->__construct()
#6 /var/www/vhosts/xxxx/httpdocs/mad/mad.php(9): danog\MadelineProto\API->__construct()
#7 {main}

I get banned from Telegram channel when I post this. Your docs ask to post problems, instantly getting kicked is not nice. Please advise.

danog commented 2 weeks ago

Sorry, it was due to the bot, unbanned.

Your issue is caused by the fact that you've got some permission issues, make sure the webserver process has permissions to write in that directory.