Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2018-03-29 21:05:15 +00:00 committed by StyleCI Bot
parent 91fa43094d
commit acb73834d4
2 changed files with 70 additions and 58 deletions

View File

@ -36,12 +36,12 @@ $MadelineProto->session = 'session.madeline';
$MadelineProto->inputEncryptedFileAudio = $MadelineProto->upload_encrypted('tests/mosconi.mp3');
}*/
class EventHandler extends \danog\MadelineProto\EventHandler
{
private $times = [];
private $calls = [];
private $my_users = [];
public function configureCall($call)
{
include 'songs.php';
@ -59,6 +59,7 @@ class EventHandler extends \danog\MadelineProto\EventHandler
$call->parseConfig();
$call->playOnHold($songs);
}
public function handleMessage($chat_id, $from_id, $message)
{
try {
@ -100,7 +101,7 @@ Propic art by @magnaluna on [deviantart](https://magnaluna.deviantart.com).", 'p
}
}
if ($message === '/broadcast' && $from_id === 101374607) {
$time = time()+100;
$time = time() + 100;
foreach ($this->get_dialogs() as $peer) {
if (isset($peer['user_id'])) {
$this->programmed_call[] = [$peer['user_id'], $time];
@ -135,6 +136,7 @@ Propic art by @magnaluna on [deviantart](https://magnaluna.deviantart.com).", 'p
$message = isset($update['message']['message']) ? $update['message']['message'] : '';
$this->handleMessage($chat_id, $from_id, $message);
}
public function onUpdateNewEncryptedMessage($update)
{
return;
@ -143,16 +145,24 @@ Propic art by @magnaluna on [deviantart](https://magnaluna.deviantart.com).", 'p
$message = isset($update['message']['decrypted_message']['message']) ? $update['message']['decrypted_message']['message'] : '';
$this->handleMessage($chat_id, $from_id, $message);
}
public function onUpdateEncryption($update) {
public function onUpdateEncryption($update)
{
return;
try {
if ($update['chat']['_'] !== 'encryptedChat') return;
if ($update['chat']['_'] !== 'encryptedChat') {
return;
}
$chat_id = $this->get_info($update)['InputEncryptedChat'];
$from_id = $this->get_secret_chat($chat_id)['user_id'];
$message = '';
} catch (\danog\MadelineProto\Exception $e) { return; }
} catch (\danog\MadelineProto\Exception $e) {
return;
}
$this->handleMessage($chat_id, $from_id, $message);
}
public function onUpdatePhoneCall($update)
{
if (is_object($update['phone_call']) && isset($update['phone_call']->madeline) && $update['phone_call']->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_INCOMING) {
@ -168,6 +178,7 @@ Propic art by @magnaluna on [deviantart](https://magnaluna.deviantart.com).", 'p
}
}
}
public function onLoop()
{
foreach ($this->programmed_call as $key => $pair) {
@ -209,7 +220,6 @@ Propic art by @magnaluna on [deviantart](https://magnaluna.deviantart.com).", 'p
}
}
}
}
}

View File

@ -19,10 +19,12 @@ namespace danog\MadelineProto\Wrappers;
trait Loop
{
private $loop_callback;
public function setLoopCallback($callback)
{
$this->loop_callback = $callback;
}
public function loop($max_forks = 0)
{
if (in_array($this->settings['updates']['callback'], [['danog\\MadelineProto\\API', 'get_updates_update_handler'], 'get_updates_update_handler'])) {
@ -51,7 +53,7 @@ trait Loop
die;
}
}
if ($this->loop_callback !== NULL) {
if ($this->loop_callback !== null) {
($this->loop_callback)();
}
}
@ -62,7 +64,7 @@ trait Loop
$offset = $update['update_id'] + 1;
$this->settings['updates']['callback']($update['update']);
}
if ($this->loop_callback !== NULL) {
if ($this->loop_callback !== null) {
($this->loop_callback)();
}
}