コード例 #1
0
ファイル: misc_functions.php プロジェクト: Riamse/cluebotng
function doInit()
{
    if (Config::$pass == null) {
        Config::$pass = trim(file_get_contents(getenv("HOME") . '/.cluebotng.password.only'));
    }
    API::init();
    API::$a->login(Config::$user, Config::$pass);
    Globals::$mysql = false;
    checkMySQL();
    Globals::$tfas = 0;
    Globals::$stdin = fopen('php://stdin', 'r');
    Globals::$run = API::$q->getpage('User:'******'/Run');
    Globals::$wl = API::$q->getpage('Wikipedia:Huggle/Whitelist');
    Globals::$optin = API::$q->getpage('User:'******'/Optin');
    Globals::$aoptin = API::$q->getpage('User:'******'/AngryOptin');
    Globals::$stalk = array();
    Globals::$edit = array();
    $tmp = explode("\n", API::$q->getpage('User:'******'/CBAutostalk.js'));
    foreach ($tmp as $tmp2) {
        if (substr($tmp2, 0, 1) != '#') {
            $tmp3 = explode('|', $tmp2, 2);
            Globals::$stalk[$tmp3[0]] = trim($tmp3[1]);
        }
    }
    $tmp = explode("\n", API::$q->getpage('User:'******'/CBAutoedit.js'));
    foreach ($tmp as $tmp2) {
        if (substr($tmp2, 0, 1) != '#') {
            $tmp3 = explode('|', $tmp2, 2);
            Globals::$edit[$tmp3[0]] = trim($tmp3[1]);
        }
    }
}
コード例 #2
0
function doInit()
{
    if (Config::$pass == null) {
        Config::$pass = trim(file_get_contents(getenv('HOME') . '/.cluebotng.password.only'));
    }
    Api::init();
    Api::$a->login(Config::$user, Config::$pass);
    Globals::$tfas = 0;
    Globals::$stdin = fopen('php://stdin', 'r');
    Globals::$run = Api::$q->getpage('User:'******'/Run');
    Globals::$wl = Api::$q->getpage('Wikipedia:Huggle/Whitelist');
    Globals::$optin = Api::$q->getpage('User:'******'/Optin');
    Globals::$aoptin = Api::$q->getpage('User:'******'/AngryOptin');
    Globals::$stalk = array();
    Globals::$edit = array();
    $tmp = explode("\n", Api::$q->getpage('User:'******'/CBAutostalk.js'));
    foreach ($tmp as $tmp2) {
        if (strlen($tmp2) > 0 && substr($tmp2, 0, 1) != '#') {
            $tmp3 = explode('|', $tmp2, 2);
            if (count($tmp3) == 2) {
                Globals::$stalk[$tmp3[0]] = trim($tmp3[1]);
            } else {
                print "Skipping auto stalk entry: {$tmp2}\n";
            }
        }
    }
    $tmp = explode("\n", Api::$q->getpage('User:'******'/CBAutoedit.js'));
    foreach ($tmp as $tmp2) {
        if (strlen($tmp2) > 0 && substr($tmp2, 0, 1) != '#') {
            $tmp3 = explode('|', $tmp2, 2);
            if (count($tmp3) == 2) {
                Globals::$edit[$tmp3[0]] = trim($tmp3[1]);
            } else {
                print "Skipping auto edit entry: {$tmp2}\n";
            }
        }
    }
}
コード例 #3
0
 public static function processEdit($change)
 {
     if (time() - Globals::$tfas >= 1800 and 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 (Config::$fork) {
         $pid = pcntl_fork();
         if ($pid != 0) {
             echo 'Forked - ' . $pid . "\n";
             return;
         }
     }
     $change = parseFeedData($change);
     $change['justtitle'] = $change['title'];
     if (in_array('namespace', $change) && $change['namespace'] != 'Main:') {
         $change['title'] = $change['namespace'] . $change['title'];
     }
     self::processEditThread($change);
     if (Config::$fork) {
         die;
     }
 }
コード例 #4
0
 public static function shouldRevert($change)
 {
     $reason = 'Default revert';
     if (preg_match('/(assisted|manual)/iS', Config::$status)) {
         echo 'Revert [y/N]? ';
         if (strtolower(substr(fgets(Globals::$stdin, 3), 0, 1)) != 'y') {
             return array(false, 'Manual mode says no');
         }
     }
     if (!preg_match('/(yes|enable|true)/iS', Globals::$run)) {
         return array(false, 'Run disabled');
     }
     if ($change['user'] == Config::$user) {
         return array(false, 'User is myself');
     }
     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');
     }
     if ($change['all']['user'] == $change['all']['common']['creator']) {
         return array(false, 'User is creator');
     }
     if ($change['all']['user_edit_count'] > 50) {
         if ($change['all']['user_warns'] / $change['all']['user_edit_count'] < 0.1) {
             return array(false, 'User has edit count');
         } else {
             $reason = 'User has edit count, but warns > 10%';
         }
     }
     if (Globals::$tfa == $change['title']) {
         return array(true, 'Angry-reverting on TFA');
     }
     if (preg_match('/\\* \\[\\[(' . preg_quote($change['title'], '/') . ')\\]\\] \\- .*/i', Globals::$aoptin)) {
         IRC::say('debugchannel', 'Angry-reverting [[' . $change['title'] . ']].');
         return array(true, 'Angry-reverting on angry-optin');
     }
     $titles = unserialize(file_get_contents('titles.txt'));
     if (!isset($titles[$change['title'] . $change['user']]) or time() - $titles[$change['title'] . $change['user']] > 24 * 60 * 60) {
         $titles[$change['title'] . $change['user']] = time();
         file_put_contents('titles.txt', serialize($titles));
         return array(true, $reason);
     }
     return array(false, 'Reverted before');
 }