Apply fixes from StyleCI
This commit is contained in:
parent
2e3551e218
commit
65f1add013
49
magna.php
49
magna.php
@ -80,7 +80,9 @@ if ($MadelineProto === false) {
|
|||||||
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::FATAL_ERROR);
|
\danog\MadelineProto\Logger::log(['hey'], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||||
|
|
||||||
$message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION'));
|
$message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION'));
|
||||||
if (!isset($MadelineProto->programmed_call)) $MadelineProto->programmed_call = [];
|
if (!isset($MadelineProto->programmed_call)) {
|
||||||
|
$MadelineProto->programmed_call = [];
|
||||||
|
}
|
||||||
|
|
||||||
echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL; echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
|
echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL; echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
|
||||||
/*
|
/*
|
||||||
@ -98,25 +100,24 @@ $users = [];
|
|||||||
if ($time < time()) {
|
if ($time < time()) {
|
||||||
if (!isset($calls[$user])) {
|
if (!isset($calls[$user])) {
|
||||||
try {
|
try {
|
||||||
include 'songs.php';
|
include 'songs.php';
|
||||||
$call = $MadelineProto->request_call($user);
|
$call = $MadelineProto->request_call($user);
|
||||||
$call->configuration['enable_NS'] = false;
|
$call->configuration['enable_NS'] = false;
|
||||||
$call->configuration['enable_AGC'] = false;
|
$call->configuration['enable_AGC'] = false;
|
||||||
$call->configuration['enable_AEC'] = false;
|
$call->configuration['enable_AEC'] = false;
|
||||||
$call->configuration['shared_config'] = [
|
$call->configuration['shared_config'] = [
|
||||||
'audio_init_bitrate' => 70 * 1000,
|
'audio_init_bitrate' => 70 * 1000,
|
||||||
'audio_max_bitrate' => 100 * 1000,
|
'audio_max_bitrate' => 100 * 1000,
|
||||||
'audio_min_bitrate' => 15 * 1000,
|
'audio_min_bitrate' => 15 * 1000,
|
||||||
//'audio_bitrate_step_decr' => 0,
|
//'audio_bitrate_step_decr' => 0,
|
||||||
//'audio_bitrate_step_incr' => 2000,
|
//'audio_bitrate_step_incr' => 2000,
|
||||||
];
|
];
|
||||||
$call->parseConfig();
|
$call->parseConfig();
|
||||||
$calls[$call->getOtherID()] = $call;
|
$calls[$call->getOtherID()] = $call;
|
||||||
$times[$call->getOtherID()] = [time(), $MadelineProto->messages->sendMessage(['peer' => $call->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$call->getDebugString()])['id']];
|
$times[$call->getOtherID()] = [time(), $MadelineProto->messages->sendMessage(['peer' => $call->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$call->getDebugString()])['id']];
|
||||||
$call->playOnHold($songs);
|
$call->playOnHold($songs);
|
||||||
|
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
echo $e;
|
echo $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($MadelineProto->programmed_call[$key]);
|
unset($MadelineProto->programmed_call[$key]);
|
||||||
@ -125,12 +126,13 @@ echo $e;
|
|||||||
foreach ($calls as $key => $call) {
|
foreach ($calls as $key => $call) {
|
||||||
if ($call->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
|
if ($call->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
|
||||||
unset($calls[$key]);
|
unset($calls[$key]);
|
||||||
} else if ($times[$call->getOtherID()][0] < time()) {
|
} elseif ($times[$call->getOtherID()][0] < time()) {
|
||||||
$times[$call->getOtherID()][0] += 10;
|
$times[$call->getOtherID()][0] += 10;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto->messages->editMessage(['id' => $times[$call->getOtherID()][1], 'peer' => $call->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$call->getDebugString()]);
|
$MadelineProto->messages->editMessage(['id' => $times[$call->getOtherID()][1], 'peer' => $call->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$call->getDebugString()]);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
echo $e;
|
echo $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +147,7 @@ echo $e;
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!isset($users[$update['update']['message']['from_id']]) ||isset($update['update']['message']['message']) && $update['update']['message']['message'] === '/start') {
|
if (!isset($users[$update['update']['message']['from_id']]) || isset($update['update']['message']['message']) && $update['update']['message']['message'] === '/start') {
|
||||||
$users[$update['update']['message']['from_id']] = true;
|
$users[$update['update']['message']['from_id']] = true;
|
||||||
$update['update']['message']['message'] = '/call';
|
$update['update']['message']['message'] = '/call';
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => "Hi, I'm @magnaluna the webradio.
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => "Hi, I'm @magnaluna the webradio.
|
||||||
@ -182,21 +184,22 @@ Propic art by @magnaluna on deviantart.", 'parse_mode' => 'Markdown']);
|
|||||||
$calls[$call->getOtherID()] = $call;
|
$calls[$call->getOtherID()] = $call;
|
||||||
$times[$call->getOtherID()] = [time(), $MadelineProto->messages->sendMessage(['peer' => $call->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$call->getDebugString()])['id']];
|
$times[$call->getOtherID()] = [time(), $MadelineProto->messages->sendMessage(['peer' => $call->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$call->getDebugString()])['id']];
|
||||||
|
|
||||||
|
|
||||||
$call->playOnHold($songs);
|
$call->playOnHold($songs);
|
||||||
}
|
}
|
||||||
if (isset($update['update']['message']['message']) && strpos($update['update']['message']['message'], '/program') === 0) {
|
if (isset($update['update']['message']['message']) && strpos($update['update']['message']['message'], '/program') === 0) {
|
||||||
$time = strtotime(str_replace('/program ', '', $update['update']['message']['message']));
|
$time = strtotime(str_replace('/program ', '', $update['update']['message']['message']));
|
||||||
if ($time === false) {
|
if ($time === false) {
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => "Invalid time provided"]);
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'Invalid time provided']);
|
||||||
} else {
|
} else {
|
||||||
$MadelineProto->programmed_call[]= [$update['update']['message']['from_id'], $time];
|
$MadelineProto->programmed_call[] = [$update['update']['message']['from_id'], $time];
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => "OK"]);
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'OK']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
try {
|
try {
|
||||||
if (strpos($e->rpc, 'FLOOD_WAIT_') === 0) $MadelineProto->programmed_call[]= [$update['update']['message']['from_id'], time()+1+str_replace('FLOOD_WAIT_', '', $e->rpc)];
|
if (strpos($e->rpc, 'FLOOD_WAIT_') === 0) {
|
||||||
|
$MadelineProto->programmed_call[] = [$update['update']['message']['from_id'], time() + 1 + str_replace('FLOOD_WAIT_', '', $e->rpc)];
|
||||||
|
}
|
||||||
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => (string) $e]);
|
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => (string) $e]);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
}
|
}
|
||||||
@ -223,9 +226,11 @@ Propic art by @magnaluna on deviantart.", 'parse_mode' => 'Markdown']);
|
|||||||
echo 'DID NOT ACCEPT A CALL';
|
echo 'DID NOT ACCEPT A CALL';
|
||||||
}
|
}
|
||||||
$calls[$update['update']['phone_call']->getOtherID()] = $update['update']['phone_call'];
|
$calls[$update['update']['phone_call']->getOtherID()] = $update['update']['phone_call'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$times[$update['update']['phone_call']->getOtherID()] = [time(), $MadelineProto->messages->sendMessage(['peer' => $update['update']['phone_call']->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$update['update']['phone_call']->getDebugString()])['id']];
|
$times[$update['update']['phone_call']->getOtherID()] = [time(), $MadelineProto->messages->sendMessage(['peer' => $update['update']['phone_call']->getOtherID(), 'message' => 'Total running calls: '.count($calls).PHP_EOL.PHP_EOL.$update['update']['phone_call']->getDebugString()])['id']];
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) { ; }
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
|
}
|
||||||
$update['update']['phone_call']->playOnHold($songs);
|
$update['update']['phone_call']->playOnHold($songs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user