Skip to content

Commit

Permalink
Merge pull request #19 from cluebotng/feature/cleanup
Browse files Browse the repository at this point in the history
Cleanup function calls
  • Loading branch information
DamianZaremba authored Dec 13, 2024
2 parents c9d0ac6 + 1f71b86 commit 139afd9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
16 changes: 2 additions & 14 deletions action_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static function doRevert($change)
if ($revdata === false) {
return;
}
if (($revdata['user'] == Config::$user) or (in_array($revdata['user'], explode(',', Config::$friends)))) {
if (($revdata['user'] == Config::$user) or (in_array($revdata['user'], Config::$friends))) {
return false;
}
if (Config::$dry) {
Expand Down Expand Up @@ -172,18 +172,6 @@ public static function shouldRevert($change)
if (Config::$angry) {
return array(true, 'Angry-reverting in angry mode');
}
if ((time() - Globals::$tfas) >= 1800) {
if (
preg_match(
'/\(\'\'\'\[\[([^|]*)\|more...\]\]\'\'\'\)/iU',
Api::$q->getpage('Wikipedia:Today\'s featured article/' . date('F j, Y')),
$tfam
)
) {
Globals::$tfas = time();
Globals::$tfa = $tfam[1];
}
}
if (!self::findAndParseBots($change)) {
return array(false, 'Exclusion compliance');
}
Expand Down Expand Up @@ -222,7 +210,7 @@ public static function shouldRevert($change)
public static function findAndParseBots($change)
{
$text = $change['all']['current']['text'];
if (stripos('{{nobots}}', $text) !== false) {
if (stripos($text, '{{nobots}}') !== false) {
return false;
}
$botname = preg_quote(Config::$user, '/');
Expand Down
2 changes: 1 addition & 1 deletion cluebot-ng.config.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace CluebotNG;
public static $status = 'auto';
public static $angry = false;
public static $owner = 'Cobi';
public static $friends = 'ClueBot,DASHBotAV';
public static $friends = ['ClueBot', 'DASHBotAV'];
public static $mw_mysql_host = 'enwiki.labsdb';
public static $mw_mysql_port = 3306;
public static $mw_mysql_user = '';
Expand Down
4 changes: 2 additions & 2 deletions feed_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static function loop($line)
}
$data['line'] = $message;
$data['rawline'] = $rawmessage;
if (stripos('N', $data['flags']) !== false) {
if (stripos($data['flags'], 'N') !== false) {
self::bail($data, 'New article');
return;
}
Expand Down Expand Up @@ -128,7 +128,7 @@ public static function bail($change, $why = '', $score = 'N/A', $reverted = fals
$rchange['edit_reason'] = $why;
$rchange['edit_score'] = $score;

if (!in_array('raw_line', $change)) {
if (!array_key_exists('rawline', $change)) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions process_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function processEdit($change)
if (
(time() - Globals::$tfas) >= 1800 and
preg_match(
'/\(\'\'\'\[\[([^|]*)\|more...\]\]\'\'\'\)/iU',
'/{{TFAFULL\|([^}]+)}}/iU',
Api::$q->getpage('Wikipedia:Today\'s featured article/' . date('F j, Y')),
$tfam
)
Expand All @@ -56,7 +56,7 @@ public static function processEdit($change)
}
$change = parseFeedData($change);
$change['justtitle'] = $change['title'];
if (in_array('namespace', $change) && $change['namespace'] != 'Main:') {
if (array_key_exists('namespace', $change) && $change['namespace'] != 'Main:') {
$change['title'] = $change['namespace'] . $change['title'];
}
self::processEditThread($change);
Expand All @@ -75,7 +75,7 @@ public static function processEditThread($change)
} else {
$change['edit_score'] = $s;
}
if (!in_array('all', $change)) {
if (!array_key_exists('all', $change)) {
Feed::bail($change, 'Missing edit data', $s);
return;
}
Expand Down

0 comments on commit 139afd9

Please sign in to comment.