danog / MadelineProto

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

Error while sending messages #61

Closed MarcoBuster closed 7 years ago

MarcoBuster commented 7 years ago

Hello @danog , I'm sending massive messages (1 per seconds) to my private bots (personal scopes) with my userbot. But, with updates disabled, after few minutes i have this error:

2017-02-09 18:45:26,925 [ERROR]: HTTP CODE: 500 #!/usr/bin/env php
MTProto:                Resetting session id and seq_no in DC 2...
MTProto:                Resetting session id and seq_no in DC 4...
CallHandler:            Calling method (try number 1 for messages.sendMessage)...
CallHandler:            Calling method (try number 1 for contacts.resolveUsername)...
ResponseHandler:        Received msg_container.
ResponseHandler:        Received new_session_created.
ResponseHandler:        Received msgs_ack.
ResponseHandler:        Receive rpc_result.

and the messages aren't sent. My code:

#!/usr/bin/env php
<?php
require 'MadelineProto/vendor/autoload.php';
$settings = [];

$MadelineProto = \danog\MadelineProto\Serialization::deserialize('bot.madeline');

function sm($chatID, $text)
{
   global $MadelineProto;
   var_export($MadelineProto->messages->sendMessage(['peer' => $chatID, 'message' => $text]));
}

$peer = $_GET["peer"];
$message = $_GET["message"];
// $peer = "@marcobuster";
// $message = "Test";

sm($peer, $message);
?>

How to fix this?

danog commented 7 years ago

Please provide the full logfile and the text of the exception.

MarcoBuster commented 7 years ago

@danog There is no logfile and no exception, only http-code 500

danog commented 7 years ago

@MarcoBuster The error 500 is caused by an exception.

MarcoBuster commented 7 years ago

@danog Your program doesn't return any exception {{shrug}}

MarcoBuster commented 7 years ago

Exception fixed with last commit (https://www.github.com/danog/MadelineProto/commit/81c1bcd2082758e8de14bc17cdfb441b0669a2dc)