Git Product home page Git Product logo

madelineprotodocs's Issues

URl Does not working with FileCallbackInterface

hi i have url i get from api , it's allow me to use it only from the server who did request it .

it's kind weird , but here is the case:

when i use curl and do file_get_contents ,
its work fine but when use \danog\MadelineProto\FileCallback , exceptions does not show me anything.
even madelineproto.log file is not.

they bot same url .

this work :

$curl_handle = curl_init();
                curl_setopt($curl_handle, CURLOPT_URL, $url);
                curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
                curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
                $query = file_get_contents($url);
                curl_close($curl_handle);
                echo $query;

this not work

$peer = '@any';
new \danog\MadelineProto\FileCallback(
           $url,
            function ($progress, $speed, $time) use ($MadelineProto, $peer) {
                try {
                    yield $MadelineProto->messages->sendMessage(['peer' => $peer, 'message' => "Upload progress: $progress%\nSpeed: $speed mbps\nTime elapsed since start: $time"]);
                } catch (\Throwable $e) {
print_r($e); // this not show anything even madelineproto.log  say everythig good . 
}
            }
        );

both same url .

exception does not show me anything ?
can someone help ?

Be Aware that i have this issue only with some urls that they not working with madeline.

my class that i use :


class MyCallback implements \danog\MadelineProto\FileCallbackInterface
{
    private $file;
    private $peer;
    private $id;
    private $byte;
    private $MadelineProto;
    private $prev;
    public function __construct($file, $peer, $id, $byte, $MadelineProto)
    {
        $this->file = $file;
        $this->peer = $peer;
        $this->id   = $id;
        $this->byte = $byte;
        $this->MadelineProto = $MadelineProto;
    }
    public function getFile()
    {
        return $this->file;
    }

    public function __invoke($progress, $speed, $time)
    {
        try {
            if ($speed != 0 && isset($this->byte)) {
                $content = "\nspeed: " . $speed . " M/s 🔺\ntime: " . gmdate("H:i:s", $time) . " ▫️\nsize: " . (float) number_format($this->byte / 1048576, 4) . ' MB ⏎';
            } else {
                $content = null;
            }
            $now = \time();
            if ($now - $this->prev < 5 && $progress < 100) {
                return;
            }
            $this->prev = $now;
            yield $this->MadelineProto->messages->editMessage(['peer' => $this->peer, 'id' => $this->id, 'message' => "<b>Progress: " . (int) $progress . '% 🔝' . $content . "</b>", 'parse_mode' => 'html']);
        } catch (Exception $e) {
            print_r($e); // this also not give anything ?
        }
    }
}

error and bad files

why madeline.php and... will copy in root folder and public_html\folder?
and this error in line 100
if (\strpos($contents, 'new \danog\MadelineProto\Server') && \in_array($contents, [\file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/2270bd9a94d168a5e6731ffd7e61821ea244beff/mtproxyd'), \file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/7cabb718ec3ccb79e3c8e3d34f5bccbe3f63b0fd/mtproxyd')]) && ($mtproxyd = \file_get_contents('https://phar.madelineproto.xyz/mtproxyd?v=new'))) {
\file_put_contents($file, $mtproxyd);

        return;
    }

How I do generating phone_code_hash to be passing in to auth.signIn() method

I am strugling to use Method: auth.signIn() but I have no ide how to generate one of it's parameter called phone_code_hash
this is the usage of the method above from official documentation https://docs.madelineproto.xyz/API_docs/methods/auth.signIn.html

_$auth_Authorization = $MadelineProto->auth->signIn(['phone_number' => 'string', 'phone_code_hash' => 'string', 'phone_code' => 'string', ]);

please help me to properly generate phone_code_hash in madeline proto @danog

MSG_ID_INVALID error in startBot method

Why does this error occur?

code:

$MadelineProto->messages->startBot([
'bot' => '@SpamBot',
'start_param' => 'string'
]);

log:

Serialization: Connected to IPC socket!
Exception: Telegram returned an RPC error: Invalid message ID provided (400) (MSG_ID_INVALID), caused by phar...
Revision: aeed13260f3a397f11564a1cfb706e25663422db-74



TL trace:




Client.php(237): __call("methodCallAsyncRead",["messages.startBot",{"bot":"@SpamBot","start_param":"string"},{"apifactory":true}])


AbstractAPIFactory.php(183): methodCallAsyncRead("messages.startBot",{"bot":"@SpamBot","start_param":"string"},{"apifactory":true})


__call_async()





Previous TL trace:


['messages.startBot']


CallHandler.php(59): methodCallAsyncRead("messages.startBot",{"bot":"@SpamBot","start_param":"string"},{"apifactory":true})


Server.php(241): methodCallAsyncRead("messages.startBot",{"bot":"@SpamBot","start_param":"string"},{"apifactory":true})


clientRequest()





Previous TL trace:


['messages.startBot']


ResponseHandler.php(185): handleRpcError({},{"_":"rpc_error","error_code":400,"error_message":"MSG_ID_INVALID"})


ResponseHandler.php(67): handleResponse({})


Driver.php(102): handleMessages("hjxt",null)


Driver.php(61): tick()


Loop.php(87): run()


Tools.php(313): run({})


entry.php(99): wait({})


entry.php(122): {closure}()

Get people nearby

Hi. It is great job. But I can not use getLocated
$MadelineProto = new \danog\MadelineProto\API('session.madeline'); $MadelineProto->start(); $inputGeoPoint = ['_' => 'inputGeoPoint', 'lat' => 55.753930, 'long' => 37.615714]; $location = $MadelineProto->contacts->getLocated(['background'=> false, 'geo_point' => $inputGeoPoint, 'self_expires' => 0]); dd($location);
But return error : INVALID INPUT
array:7 [▼ "_" => "updates" "updates" => [] "users" => [] "chats" => [] "date" => 1611055246 "seq" => 0 "request" => array:12 [▼ "apifactory" => true "datacenter" => 2 "_" => "contacts.getLocated" "type" => "Updates" "contentRelated" => true "promise" => Amp\Deferred {#3975 ▶} "method" => true "unencrypted" => false "body" => array:3 [▼ "background" => false "geo_point" => array:3 [▼ "_" => "inputGeoPoint" "lat" => 55.75393 "long" => 37.615714 ] "self_expires" => 0 ] "serialized_body" => b"D¼HÓ\x01\x00\x00\x00ɬ·ó”¼:Ç€àK@<Øb·ÏÎB@\x00\x00\x00\x00"(INVALID INPUT) "sent" => 1611055247 "tries" => 0 ] ]

getPeerDialogs can't return the error

Hey,
My problem is when I use messages.getPeerDialogs and give it an array of usernames, when there is a unoccupied username between them it will return an error but it doesn't specify which username is making it returning this error, any idea what should I do?
Thank you

how do after getting media from the user, wait to get the file name and then save the file with the arrived name?

my code is:

<?php

namespace App\Events;

use danog\MadelineProto\EventHandler;
use danog\MadelineProto\RPCErrorException;
use danog\MadelineProto\Magic;
use danog\MadelineProto\Shutdown;

class TelegramEventHandler extends EventHandler
{
    const Report = "xxxx"; //Admin Username
    const Admins = [xxxx]; //Admin UserID
    private string $time;

    public function onStart()
    {
        $this->time = time();
    }

    public function getReportPeers(): array
    {
        return [self::Report];
    }

    public function onUpdateNewMessage(array $update)
    {
        if ($update['message']['_'] !== 'message' || $update['message']['date'] <= $this->time) {
            return;
        }

        try {
            $message = $update['message'];
            $msgId = $message['id'] ?? null;
            $isOut = $message['out'] ?? false;
            $text = $message['message'] ?? '';
            $fromId = $message['from_id']['user_id'] ?? null;
            $replyTo = $message['reply_to']['reply_to_msg_id'] ?? null;
            $peer = $this->getID($update);

            if (in_array($fromId, self::Admins)) {       
               if (isset($update['message']['media']['_']) && $update['message']['media']['_'] !== 'messageMediaWebPage') {
                    $this->messages->sendMessage([
                        'peer' => $peer,
                        'message' => 'Please enter the file name:',
                        'reply_to_msg_id' => $msgId,
                    ]);

                    // Wait for the user to reply with the file name
                    $response = $this->messages->getMessages([
                        'id' => [$msgId],
                        'min_id' => $msgId,
                        'wait_time' => 30, // Wait for 30 seconds
                    ]);

                    if (isset($response['messages'][0]['message'])) {
                        $fileName = $response['messages'][0]['message'];
                        // Save the file with the provided file name
                        $this->downloadToFile($update, storage_path('app/' . $fileName));
                    } else {
                        $this->messages->sendMessage([
                            'peer' => $peer,
                            'message' => 'Sorry, I did not receive a file name. Please try again.',
                            'reply_to_msg_id' => $msgId,
                        ]);
                    }
               }             
            }

        } catch (RPCErrorException $e) {
            $this->report($e->rpc);
            $this->logger($e);
        }
    }

}

$settings = new Settings;
$settings->getLogger()->setLevel(Logger::LEVEL_ULTRA_VERBOSE);

MP::startAndLoopBot('session', 'token', $settings);

But I get this error:
\danog\MadelineProto\Exception: isset is not supported, please yield the entire Coroutine first!

how do? please guide me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.