Apply fixes from StyleCI (#12124)

This commit is contained in:
Jellyfrog
2020-09-21 15:59:34 +02:00
committed by GitHub
parent 0d56bbd946
commit 29f45ca352
816 changed files with 5038 additions and 5038 deletions

View File

@@ -174,7 +174,7 @@ class IRCBot
$inactive_seconds = time() - $this->last_activity;
$max_inactive = $this->config['irc_conn_timeout'];
if ($inactive_seconds > $max_inactive) {
$this->log("No data from server since " . $max_inactive . " seconds. Restarting.");
$this->log('No data from server since ' . $max_inactive . ' seconds. Restarting.');
break;
}
}
@@ -309,49 +309,49 @@ class IRCBot
}
}
if (($this->config['irc_ctcp']) && (preg_match("/^:" . chr(1) . ".*/", $ex[3]))) {
if (($this->config['irc_ctcp']) && (preg_match('/^:' . chr(1) . '.*/', $ex[3]))) {
// Handle CTCP
$ctcp = trim(preg_replace("/[^A-Z]/", "", $ex[3]));
$ctcp = trim(preg_replace('/[^A-Z]/', '', $ex[3]));
$ctcp_reply = null;
$this->log("Received irc CTCP: " . $ctcp . " from " . $this->getUser($this->data));
$this->log('Received irc CTCP: ' . $ctcp . ' from ' . $this->getUser($this->data));
switch ($ctcp) {
case 'VERSION':
$ctcp_reply = chr(1) . "$ctcp " . $this->config['irc_ctcp_version'] . chr(1);
break;
case 'PING':
$ctcp_reply = chr(1) . "$ctcp " . $ex[4] . " " . $ex[5] . chr(1);
$ctcp_reply = chr(1) . "$ctcp " . $ex[4] . ' ' . $ex[5] . chr(1);
break;
case 'TIME':
$ctcp_reply = chr(1) . "$ctcp " . date('c') . chr(1);
break;
}
if ($ctcp_reply !== null) {
$this->log("Sending irc CTCP: " . 'NOTICE ' . $this->getUser($this->data) . " :" . $ctcp_reply);
$this->log('Sending irc CTCP: ' . 'NOTICE ' . $this->getUser($this->data) . ' :' . $ctcp_reply);
return $this->ircRaw('NOTICE ' . $this->getUser($this->data) . " :" . $ctcp_reply);
return $this->ircRaw('NOTICE ' . $this->getUser($this->data) . ' :' . $ctcp_reply);
}
}
if (($ex[1] == 'NICK') && (preg_replace("/^:/", "", $ex[2]) == $this->nick)) {
if (($ex[1] == 'NICK') && (preg_replace('/^:/', '', $ex[2]) == $this->nick)) {
// Nickname changed successfully
if ($this->debug) {
$this->log("Regained our real nick");
$this->log('Regained our real nick');
}
unset($this->tempnick);
}
if (($ex[1] == 433) || ($ex[1] == 437)) {
// Nickname already in use / temp unavailable
if ($this->debug) {
$this->log("Nickname already in use...");
$this->log('Nickname already in use...');
}
if ($ex[2] != "*") {
if ($ex[2] != '*') {
$this->tempnick = $ex[2];
}
if (! isset($this->tempnick)) {
$this->tempnick = $this->nick . rand(0, 99);
}
if ($this->debug) {
$this->log("Using temp nick " . $this->tempnick);
$this->log('Using temp nick ' . $this->tempnick);
}
return $this->ircRaw('NICK ' . $this->tempnick);
@@ -577,7 +577,7 @@ class IRCBot
global $authorizer;
foreach ($this->config['irc_auth'] as $nms_user => $hosts) {
foreach ($hosts as $host) {
$host = preg_replace("/\*/", ".*", $host);
$host = preg_replace("/\*/", '.*', $host);
if (preg_match("/$host/", $this->getUserHost($this->data))) {
$user_id = LegacyAuth::get()->getUserid(mres($nms_user));
$user = LegacyAuth::get()->getUser($user_id);
@@ -685,7 +685,7 @@ class IRCBot
private function _quit($params)
{
if ($this->user['level'] == 10) {
$this->ircRaw("QUIT :Requested");
$this->ircRaw('QUIT :Requested');
return exit();
} else {
@@ -896,8 +896,8 @@ class IRCBot
$status_counts = [];
$status_colors = [0 => 'green', 3 => 'lightblue', 1 => 'yellow', 2 => 'red'];
$srvcount = dbFetchCell('SELECT COUNT(*) FROM services' . $d_w);
$srvign = dbFetchCell("SELECT COUNT(*) FROM services WHERE service_ignore = 1" . $d_a);
$srvdis = dbFetchCell("SELECT COUNT(*) FROM services WHERE service_disabled = 1" . $d_a);
$srvign = dbFetchCell('SELECT COUNT(*) FROM services WHERE service_ignore = 1' . $d_a);
$srvdis = dbFetchCell('SELECT COUNT(*) FROM services WHERE service_disabled = 1' . $d_a);
$service_status = dbFetchRows("SELECT `service_status`, COUNT(*) AS `count` FROM `services` WHERE `service_disabled`=0 AND `service_ignore`=0 $d_a GROUP BY `service_status`");
$service_status = array_column($service_status, 'count', 'service_status'); // key by status
@@ -926,28 +926,28 @@ class IRCBot
private function _color($text, $fg_color, $bg_color = null, $other = null)
{
$colors = [
'white' => "00",
'black' => "01",
'blue' => "02",
'green' => "03",
'red' => "04",
'brown' => "05",
'purple' => "06",
'orange' => "07",
'yellow' => "08",
'lightgreen' => "09",
'cyan' => "10",
'lightcyan' => "11",
'lightblue' => "12",
'pink' => "13",
'grey' => "14",
'lightgrey' => "15",
'white' => '00',
'black' => '01',
'blue' => '02',
'green' => '03',
'red' => '04',
'brown' => '05',
'purple' => '06',
'orange' => '07',
'yellow' => '08',
'lightgreen' => '09',
'cyan' => '10',
'lightcyan' => '11',
'lightblue' => '12',
'pink' => '13',
'grey' => '14',
'lightgrey' => '15',
];
$ret = chr(3);
if (array_key_exists($fg_color, $colors)) {
$ret .= $colors[$fg_color];
if (array_key_exists($bg_color, $colors)) {
$ret .= "," . $colors[$fg_color];
$ret .= ',' . $colors[$fg_color];
}
}
switch ($other) {