Skip to content

Commit

Permalink
Drop UDP relay support
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianZaremba committed Jul 23, 2021
1 parent 38ff51f commit 0beba7a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 45 deletions.
9 changes: 6 additions & 3 deletions action_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ class Action
{
public static function doWarn($change, $report)
{
global $logger;
$warning = self::getWarningLevel($change['user'], $tpcontent) + 1;
if (!Config::$dry) {
if ($warning >= 4) {
/* Report them if they have been warned 4 times. */
self::aiv($change, $report);
} else {
/* Warn them if they haven't been warned 4 times. */
IRC::debug("Warning " . $change['user'] . " (" . $warning . ")");
$logger->addInfo("Warning " . $change['user'] . " (" . $warning . ")");
self::warn($change, $report, $tpcontent, $warning);
}
}
Expand Down Expand Up @@ -74,9 +75,10 @@ public static function getWarningLevel($user, &$content = null)

private static function aiv($change, $report)
{
global $logger;
$aivdata = Api::$q->getpage('Wikipedia:Administrator_intervention_against_vandalism/TB2');
if (!preg_match('/' . preg_quote($change['user'], '/') . '/i', $aivdata)) {
IRC::debug(
$logger->addInfo(
'!admin Reporting [[User:' . $change['user'] .
']] to [[WP:AIV]]. Contributions: [[Special:Contributions/' . $change['user'] .
']] Block: [[Special:Blockip/' . $change['user'] . ']]'
Expand Down Expand Up @@ -153,6 +155,7 @@ public static function doRevert($change)

public static function shouldRevert($change)
{
global $logger;
$reason = 'Default revert';
if (preg_match('/(assisted|manual)/iS', Config::$status)) {
echo 'Revert [y/N]? ';
Expand Down Expand Up @@ -198,7 +201,7 @@ public static function shouldRevert($change)
return array(true, 'Angry-reverting on TFA');
}
if (preg_match('/\* \[\[(' . preg_quote($change['title'], '/') . ')\]\] \- .*/i', Globals::$aoptin)) {
IRC::debug('Angry-reverting [[' . $change['title'] . ']].');
$logger->addInfo('Angry-reverting [[' . $change['title'] . ']].');

return array(true, 'Angry-reverting on angry-optin');
}
Expand Down
2 changes: 0 additions & 2 deletions cbng.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ function parseFeedData($feedData, $useOld = false)
and isset($api['revisions'][1]['*']))
) {
$logger->addError("Failed to get all edit info: " . var_export($feedData, true) . ", " . var_export($cb, true));
IRC::debug("Failed to get edit info for \x0315[[\x0307" . $feedData['title'] . "\x0315]] " .
"by \"\x0303" . $feedData['user'] . "\x0315\" (\x0312 " . $feedData['url'] . " \x0315)");
return false;
}
$data = array(
Expand Down
1 change: 0 additions & 1 deletion cluebot-ng.config.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace CluebotNG;
public static $cb_mysql_user = '';
public static $cb_mysql_pass = '';
public static $cb_mysql_db = 'cb';
public static $udpport = 3334;
public static $coreport = 3565;
public static $fork = true;
public static $dry = false;
Expand Down
1 change: 1 addition & 0 deletions feed_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ private static function loop($line)

public static function bail($change, $why = '', $score = 'N/A', $reverted = false)
{
global $logger;
$rchange = $change;
$rchange['edit_reason'] = $why;
$rchange['edit_score'] = $score;
Expand Down
31 changes: 0 additions & 31 deletions irc_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,35 +104,4 @@ public static function init()
}
self::$chans = $tmp;
}

public static function debug($message)
{
return self::message('#wikipedia-en-cbngdebug', $message);
}

public static function spam($message)
{
return self::message('#wikipedia-en-cbngfeed', $message);
}

public static function revert($message)
{
return self::message('#wikipedia-en-cbngrevertfeed', $message);
}

private static function message($channel, $message)
{
global $logger;
$relay_node = Db::getCurrentRelayNode();
if (!isset($relay_node)) {
$logger->addError("Could not get relay node. Failed to send: " . $message);
return;
}
$logger->addInfo('Saying to ' . $channel . ': ' . $message);
$udp = fsockopen('udp://' . $relay_node, Config::$udpport);
if ($udp !== false) {
fwrite($udp, $channel . ':' . $message);
fclose($udp);
}
}
}
16 changes: 8 additions & 8 deletions process_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public static function processEditThread($change)
}
$oftVand[$change['title']][] = time();
file_put_contents('oftenvandalized.txt', serialize($oftVand));
$ircreport = "\x0315[[\x0307" . $change['title'] . "\x0315]] by \"\x0303" . $change['user'] .
"\x0315\" (\x0312 " . $change['url'] . " \x0315) \x0306" . $s . "\x0315 (";
$ircreport = "[[" . $change['title'] . "]] by \"" . $change['user'] .
"\" (" . $change['url'] . " )" . $s . " (";
$change['mysqlid'] = Db::detectedVandalism(
$change['user'],
$change['title'],
Expand All @@ -123,9 +123,9 @@ public static function processEditThread($change)
$rbret = Action::doRevert($change);
if ($rbret !== false) {
$change['edit_status'] = 'reverted';
IRC::revert(
$ircreport . "\x0304Reverted\x0315) (\x0313" . $revertReason .
"\x0315) (\x0302" . (microtime(true) - $change['startTime']) . " \x0315s)"
$logger->addInfo(
$ircreport . "Reverted) (" . $revertReason .
") (" . (microtime(true) - $change['startTime']) . " s)"
);
Action::doWarn($change, $report);
Db::vandalismReverted($change['mysqlid']);
Expand All @@ -134,9 +134,9 @@ public static function processEditThread($change)
$change['edit_status'] = 'beaten';
$rv2 = Api::$a->revisions($change['title'], 1);
if ($change['user'] != $rv2[0]['user']) {
IRC::revert(
$ircreport . "\x0303Not Reverted\x0315) (\x0313Beaten by " .
$rv2[0]['user'] . "\x0315) (\x0302" . (microtime(true) - $change['startTime']) . " \x0315s)"
$logger->addInfo(
$ircreport . "Not Reverted) (Beaten by " .
$rv2[0]['user'] . ") (" . (microtime(true) - $change['startTime']) . " s)"
);
Db::vandalismRevertBeaten($change['mysqlid'], $change['title'], $rv2[0]['user'], $change['url']);
Feed::bail($change, 'Beaten by ' . $rv2[0]['user'], $s);
Expand Down

0 comments on commit 0beba7a

Please sign in to comment.