Merge branch 'master' of https://github.com/danog/MadelineProto
This commit is contained in:
commit
8d7b910058
8
bot.php
8
bot.php
@ -33,10 +33,6 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
||||
if (isset($update['message']['out']) && $update['message']['out']) {
|
||||
return;
|
||||
}
|
||||
if (isset($update['message']['media']) && $update['message']['media']['_'] !== 'messageMediaGame') {
|
||||
//yield $this->download_to_dir($update, '/tmp');
|
||||
yield $this->messages->sendMedia(['peer' => $update, 'message' => $update['message']['message'], 'media' => $update]);
|
||||
}
|
||||
|
||||
$res = json_encode($update, JSON_PRETTY_PRINT);
|
||||
if ($res == '') {
|
||||
@ -46,6 +42,10 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
||||
|
||||
try {
|
||||
yield $this->messages->sendMessage(['peer' => $update, 'message' => "<code>$res</code>", 'reply_to_msg_id' => isset($update['message']['id']) ? $update['message']['id'] : null, 'parse_mode' => 'HTML']); //'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]);
|
||||
if (isset($update['message']['media']) && $update['message']['media']['_'] !== 'messageMediaGame') {
|
||||
yield $this->messages->sendMedia(['peer' => $update, 'message' => $update['message']['message'], 'media' => $update]);
|
||||
//yield $this->download_to_dir($update, '/tmp')
|
||||
}
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
\danog\MadelineProto\Logger::log((string) $e, \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
|
@ -150,6 +150,15 @@ trait Files
|
||||
{
|
||||
$res = [$this->constructors->find_by_predicate($media['_'])['type'] => $media];
|
||||
switch ($media['_']) {
|
||||
case 'messageMediaPoll':
|
||||
$res['Poll'] = $media['poll'];
|
||||
$res['InputMedia'] = ['_' => 'inputMediaPoll', 'poll' => $res['Poll']];
|
||||
break;
|
||||
case 'updateMessagePoll':
|
||||
$res['Poll'] = $media['poll'];
|
||||
$res['InputMedia'] = ['_' => 'inputMediaPoll', 'poll' => $res['Poll']];
|
||||
$res['MessageMedia'] = ['_' => 'messageMediaPoll', 'poll' => $res['Poll'], 'results' => $media['results']];
|
||||
break;
|
||||
case 'messageMediaPhoto':
|
||||
if (!isset($media['photo']['access_hash'])) {
|
||||
throw new \danog\MadelineProto\Exception('No access hash');
|
||||
@ -172,6 +181,9 @@ trait Files
|
||||
$res['InputMedia']['ttl_seconds'] = $media['ttl_seconds'];
|
||||
}
|
||||
break;
|
||||
case 'poll':
|
||||
$res['InputMedia'] = ['_' => 'inputMediaPoll', 'poll' => $res['Poll']];
|
||||
break;
|
||||
case 'document':
|
||||
if (!isset($media['access_hash'])) {
|
||||
throw new \danog\MadelineProto\Exception('No access hash');
|
||||
|
Loading…
Reference in New Issue
Block a user