User:SoxBot III/Source

The following is automatically generated by SoxBot III. It uses ClueBot classes for interacting with the wiki, and also uses some of ClueBot's code for interacting with IRC.

',' ', file_get_contents(__FILE__))." \n\n\n\n",		'Automated source upload.'); }	//Get list of articles and users to stalk $stalk = array; $edit = array; $tmp = explode("\n",$wpq->getpage('User:'.$user.'/Autostalk.js')); foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $stalk[$tmp3[0]] = trim($tmp3[1]); } } $tmp = explode("\n",$wpq->getpage('User:'.$user.'/Autoedit.js')); foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $edit[$tmp3[0]] = trim($tmp3[1]); } } unset($tmp,$tmp2,$tmp3); //Start IRC feed parser while (1) { $feed = fsockopen($feedhost,$feedport,$feederrno,$feederrstr,30); if (!$feed) { sleep(10); $feed = fsockopen($feedhost,$feedport,$feederrno,$feederrstr,30); if (!$feed) die($feederrstr.' ('.$feederrno.')'); }		fwrite($feed,'USER '.$user.' "1" "1" :SoxBot Wikipedia Bot.'."\n"); fwrite($feed,'NICK '.$user."\n"); while (!feof($feed)) { $rawline = fgets($feed,1024); $line = str_replace(array("\n","\r","\002"),'',$rawline); $line = preg_replace('/\003(\d\d?(,\d\d?)?)?/','',$line); //echo 'FEED: '.$line."\n"; if (!$line) { fclose($feed); break; } $linea= explode(' ',$line,4); if (strtolower($linea[0]) == 'ping') { fwrite($feed,'PONG '.$linea[1]."\n"); } elseif (($linea[1] == '376') or ($linea[1] == '422')) { fwrite($feed,'JOIN '.$feedchannel."\n"); } elseif ((strtolower($linea[1]) == 'privmsg') and (strtolower($linea[2]) == strtolower($feedchannel))) { $message = substr($linea[3],1); if (preg_match('/^\[\[((Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal|Special)(( |_)talk)?:)?([^\x5d]*)\]\] (\S*) (http:\/\/en\.wikipedia\.org\/w\/index\.php\?diff=(\d*)&oldid=(\d*)|http:\/\/en\.wikipedia\.org\/wiki\/\S+)? \* ([^*]*) \* (\(([^)]*)\))? (.*)$/S',$message,$m)) {					$messagereceived = microtime(1);					$change['namespace'] = $m[1];					$change['title'] = $m[5];					$change['flags'] = $m[6];					$change['url'] = $m[7];					$change['revid'] = $m[8];					$change['old_revid'] = $m[9];					$change['user'] = $m[10];					$change['length'] = $m[12];					$change['comment'] = $m[13]; //					include 'cluebot.stalk.config.php';					$pos = strpos($change['flags'], 'B'); 					if ($pos !== false) continue;					$stalkchannel = array;					foreach ($stalk as $key => $value) if (fnmatch(str_replace('_',' ',$key),str_replace('_',' ',$change['user']))) $stalkchannel = array_merge($stalkchannel,explode(',',$value));					foreach ($edit as $key => $value) if (fnmatch(str_replace('_',' ',$key),str_replace('_',' ',$change['namespace'].$change['title']))) $stalkchannel = array_merge($stalkchannel,explode(',',$value)); //					if ($change['user'] == $owner) $stalkchannel[] = $ircchannel; $stalkchannel = array_unique($stalkchannel); foreach ($stalkchannel as $y) { fwrite($irc,'PRIVMSG '.$y.' :New edit: '.$change['namespace'].$change['title'].' http://en.wikipedia.org/w/index.php?diff=prev'.'&oldid='.urlencode($change['revid']).' * '.$change['user'] .							' * '.$change['comment']."\n"); sleep(1); }					//Update $stalk, $edit, and $channels variables if (($change['namespace'] == 'User:')) { if (strtolower($change['title']) == strtolower($user.'/Run')) { $run = $wpq->getpage('User:'.$user.'/Run'); } if (strtolower($change['title']) == strtolower($user.'/Whitelist')) { $whitelist = $wpq->getpage('User:'.$user.'/Whitelist'); } if (strtolower($change['title']) == strtolower($user.'/Autostalk.js')) { fwrite( $irc,'PART '.implode(',',$stalk)." Parting due to ".$change['user']." editing User:".$user.'/Autostalk.js'."\n" ); sleep(2); unset($stalk); $tmp = explode("\n",$wpq->getpage('User:'.$user.'/Autostalk.js')); foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $stalk[$tmp3[0]] = trim($tmp3[1]); } } unset($tmp,$tmp2,$tmp3); print_r($stalk); fwrite( $irc,'JOIN '.implode(',',$stalk)."\n" ); sleep(2); }						echo $change['title']; if (strtolower($change['title']) == strtolower($user.'/Autoedit.js')) { fwrite( $irc,'PART '.implode(',',$edit)." Parting due to ".$change['user']." editing User:".$user.'/Autoedit.js'."\n" ); sleep(2); unset($edit); $tmp = explode("\n",$wpq->getpage('User:'.$user.'/Autoedit.js')); foreach ($tmp as $tmp2) { if (substr($tmp2,0,1) != '#') { $tmp3 = explode('|',$tmp2,2); $edit[$tmp3[0]] = trim($tmp3[1]); } } unset($tmp,$tmp2,$tmp3); print_r($edit); fwrite( $irc,'JOIN '.implode(',',$edit)."\n" ); sleep(2); }						if (strtolower($change['title']) == strtolower($owner.'/Channels.js')) { $ircconfig = explode("\n",$wpq->getpage('User:'.$owner.'/Channels.js')); $tmp = array; foreach($ircconfig as $tmpline) { if (substr($tmpline,0,1) != '#') { $tmpline = explode('=',$tmpline,2); $tmp[trim($tmpline[0])] = trim($tmpline[1]); } } print_r($tmp); $tmpold = array; $tmpnew = array; foreach ($tmp as $tmp2) foreach (explode(',',$tmp2) as $tmp3) $tmpnew[$tmp3] = 1; foreach (explode(',',$ircchannel.','.$irctechchannel.','.$ircotherchannels.','.$ircvandalismchannel.','.$ircaivchannel.','.$ircverbosechannel.','.$irclogchannels.','.$ircwikilinkchannels.','.$ircpeakchannels) as $tmp3) $tmpold[$tmp3] = 1; foreach ($tmpold as $tmp2 => $tmp3) if (isset($tmpnew[$tmp2])) unset($tmpold[$tmp2],$tmpnew[$tmp2]); foreach ($tmpnew as $tmp2 => $tmp3) $tmpnew1[] = $tmp2; foreach ($tmpold as $tmp2 => $tmp3) $tmpold1[] = $tmp2; $tmpold = $tmpold1; $tmpnew = $tmpnew1; unset($tmpold1,$tmpnew1); fwrite( $irc,'JOIN '.implode(',',$tmpnew)."\n" ); fwrite( $irc,'PART '.implode(',',$tmpold)." Parting due to ".$change['user']." editing User:".$owner.'/Channels.js'."\n" ); $ircchannel = $tmp['ircchannel']; $irctechchannel = $tmp['irctechchannel']; $ircverbosechannel = $tmp['ircverbosechannel']; $ircotherchannels = $tmp['ircotherchannels']; $ircvandalismchannel = $tmp['ircvandalismchannel']; $ircaivchannel = $tmp['ircaivchannel']; $irclogchannels = $tmp['irclogchannels']; $ircwikilinkchannels = $tmp['ircwikilinkchannels']; $ircpeakchannels = $tmp['ircpeakchannels']; unset($tmp,$tmpline,$tmpold,$tmpnew,$tmp2,$tmp3); }					}					if (($change['namespace'] != '') || ($change['flags'] == 'move')) continue; //Ignore moves and nonmainspace edits //Add namespace to the title $change['title'] = $change['namespace'].$change['title']; //Don't bother with forking if it is disabled if (!preg_match('/(yes|enable|true)/i',$run)) { continue; }					//Start the fork!!! $feedpid = @pcntl_fork; //$pids[$feedpid] = $feedpid; if ($feedpid != 0) continue; //echo posix_getpid."\n"; $diff = $wpi->diff($change['title'],$change['old_revid'],$change['revid']);//Get diff $score = score($testlist,$diff[0],$log);//Match edit against $scorelist $score -= score($testlist,$diff[1],$log2);//Add points for each instance removed. $url = 'http://en.wikipedia.org/w/index.php?title='.urlencode($change['title']).'&diff='.urlencode($change['revid']).'&oldid='.urlencode($change['old_revid']);//Url of the diff $tmp = unserialize(file_get_contents('/home/soxred93/bots/soxbot-test/titles.txt')); if (						($score <= SCORELIMIT)						&& (!preg_match('/\