mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-23 10:31:13 +01:00
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']) {
|
if (isset($update['message']['out']) && $update['message']['out']) {
|
||||||
return;
|
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);
|
$res = json_encode($update, JSON_PRETTY_PRINT);
|
||||||
if ($res == '') {
|
if ($res == '') {
|
||||||
@ -46,6 +42,10 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
|||||||
|
|
||||||
try {
|
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']]]);
|
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) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
\danog\MadelineProto\Logger::log((string) $e, \danog\MadelineProto\Logger::FATAL_ERROR);
|
\danog\MadelineProto\Logger::log((string) $e, \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||||
} catch (\danog\MadelineProto\Exception $e) {
|
} catch (\danog\MadelineProto\Exception $e) {
|
||||||
|
@ -150,6 +150,15 @@ trait Files
|
|||||||
{
|
{
|
||||||
$res = [$this->constructors->find_by_predicate($media['_'])['type'] => $media];
|
$res = [$this->constructors->find_by_predicate($media['_'])['type'] => $media];
|
||||||
switch ($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':
|
case 'messageMediaPhoto':
|
||||||
if (!isset($media['photo']['access_hash'])) {
|
if (!isset($media['photo']['access_hash'])) {
|
||||||
throw new \danog\MadelineProto\Exception('No access hash');
|
throw new \danog\MadelineProto\Exception('No access hash');
|
||||||
@ -172,6 +181,9 @@ trait Files
|
|||||||
$res['InputMedia']['ttl_seconds'] = $media['ttl_seconds'];
|
$res['InputMedia']['ttl_seconds'] = $media['ttl_seconds'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'poll':
|
||||||
|
$res['InputMedia'] = ['_' => 'inputMediaPoll', 'poll' => $res['Poll']];
|
||||||
|
break;
|
||||||
case 'document':
|
case 'document':
|
||||||
if (!isset($media['access_hash'])) {
|
if (!isset($media['access_hash'])) {
|
||||||
throw new \danog\MadelineProto\Exception('No access hash');
|
throw new \danog\MadelineProto\Exception('No access hash');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user