All pastes #1029501 Raw Edit

Mine

public php v1 · immutable
#1029501 ·published 2008-05-26 02:35 UTC
rendered paste body
<?phpini_set("max_execution_time",0); // BUG//// Configuration ////// Disclose voters$vote_config['disclose_voters'] = TRUE;// Disclose voter dispositions// Note: Previous option must be true for this to work$vote_config['disclose_disposition'] = TRUE;// Log votes?$vote_config['log_votes'] = TRUE;// Use bolds?$vote_config['bolds'] = FALSE;// Use colors?$vote_config['colors'] = TRUE;// Which colors would you like to use for the foreground// Note: the Use colors option must be on for this to work$vote_config['color'][0] = '2';$vote_config['color'][1] = '3';// What should all vote triggers be prepended by$vote_config['vote_prefix'] = '@';// Channels this bot should run in// Use all lowercase$vote_config['vote_chans'] = array('#christian_debate', '#trollbot');// Vote types, and the amount of votes required to pass types$vote_config['vote_types'] = array('ban'     => array('citizen'    => 4,                                                      'noncitizen' => 3,                                                      'hostmask'   => 4),                                   'unban'   => array('citizen'    => 3,                                                      'noncitizen' => 4,                                                      'hostmask'   => 4),                                   'kick'    => array('citizen'    => 3,                                                      'noncitizen' => 4,                                                      'hostmask'   => 4),                                   'topic'   => 3,                                   'impeach' => 5,                                   'elect'   => 4);//// Code ////$vote_config['cur_propositions'] = array();function voting_putserv($net, $victim, $message, $highlight_text = NULL){	global $vote_config;	$out_msg = $message;	if ($vote_config['colors'] == FALSE)	{		putserv($net, "PRIVMSG $victim :$out_msg");		return;	}	// If highlight_text is not an array, make it one.	if (!is_array($highlight_text))		$highlight = array($highlight_text);	else		$highlight = $highlight_text;	// foreach element in $highlight, replace the element 	foreach ($highlight as $target)	{		$out_msg = str_replace($target, "\003{$vote_config['color'][1]}{$target}\003{$vote_config['color'][0]}", $out_msg);	}	putserv($net, "PRIVMSG $victim :\003{$vote_config['color'][0]}{$out_msg}");	return;}class VotingProposition{	public $net;	public $chan;	public $type;	public $time;	public $caller;	public $args;	private $required;	function __construct($net = NULL, $chan = NULL, $type = NULL, $time = NULL, $caller = NULL, $args = NULL)	{		$this->net    = $net;		$this->chan   = $chan;		$this->type   = $type;		$this->time   = $time;		$this->caller = $caller;		$this->args   = $args;		// Required votes		$this->required = 0;	}	function evaluate()	{		global $vote_config;		if (!in_array(strtolower($this->chan), $vote_config['vote_chans']))		{			putserv($this->net, "PRIVMSG {$this->chan} :Voting is not enabled in this channel.");			return FALSE;		}		if (in_array(strtolower($this->chan), array_keys($vote_config['cur_propositions'])))		{			// FIXME: Check current prop for FIXME value			voting_putserv($this->net, $this->chan, "Sorry, a vote is currently underway on FIXME. Wait until that one is completed.", "FIXME");			return FALSE;		}		if (empty($this->args))		{			voting_putserv($this->net, $this->chan, "{$this->caller}, hey dumbass, how about using some arguments.");			return FALSE;		}		if (!in_array($this->type, array_keys($vote_config['vote_types'])))		{			voting_putserv($this->net, $this->chan, "{$this->caller}, this vote type has been disabled.");			return FALSE;		}		$botnick = botnick($this->net);		if (!is_array($vote_config['vote_types'][$this->type]))		{			// Simple vote count			$this->required = $vote_config['vote_types'][$this->type];			}		// Look up vote count required.		$arg_array = explode(" ",$this->args);		switch($this->type)		{			case "topic":					if (count($arg_array) == 0)					{						voting_putserv($this->net, $this->chan, "{$this->caller}, to set a new topic, you need to provide an actual topic.");						return FALSE;					}					voting_putserv($this->net, $this->chan, "{$this->caller} wishes to change the channel topic to {$this->args}. You have one minute to vote by messaging {$botnick} with a YES or NO.", array($this->args, "YES", "NO"));					voting_putserv($this->net, $this->chan, "This vote will require ({$this->required}) votes to pass", "({$this->required})");					break;			case "ban":			case "unban":			case "kick":			case "impeach":			case "elect":			case "censure":				if (count($arg_array) > 1)				{					$rest = str_replace("{$arg_array[0]} ","", $this->args);					voting_putserv($this->net, $this->chan, "{$this->caller} has called for a vote to {$this->type} {$arg_array[0]}. Stated reason: {$rest}. You have one minute to vote by messaging {$botnick} with a YES or NO.", array($botnick, $arg_array[0], "YES", "NO", $rest));					voting_putserv($this->net, $this->chan, "This vote will require ({$this->required}) votes to pass", "({$this->required})");					// Has a reason				}				else				{					// No Reason					voting_putserv($this->net, $this->chan, "{$this->caller} has called for a vote to {$this->type} {$arg_array[0]} You have one minute to vote by messaging {$botnick} with a YES or NO.",array($botnick, $arg_array[0], "YES", "NO"));					voting_putserv($this->net, $this->chan, "This vote will require ({$this->required}) votes to pass", "({$this->required})");				}				break;		}		// Start timer for check		// Insert into cur_propositions		return TRUE;	}}bind("DALnet","pub","-","{$vote_config['vote_prefix']}ban","voting_ban");bind("DALnet","pub","-","{$vote_config['vote_prefix']}unban","voting_unban");bind("DALnet","pub","-","{$vote_config['vote_prefix']}kick","voting_kick");bind("DALnet","pub","-","{$vote_config['vote_prefix']}censure","voting_censure");bind("DALnet","pub","-","{$vote_config['vote_prefix']}elect","voting_elect");bind("DALnet","pub","-","{$vote_config['vote_prefix']}impeach","voting_impeach");bind("DALnet","pub","-","{$vote_config['vote_prefix']}topic","voting_topic");function voting_topic($net, $nick, $uhost, $hand, $chan, $arg){	$prop = new VotingProposition($net, $chan, "topic", time(), $nick, $arg);	$prop->evaluate();}function voting_ban($net, $nick, $uhost, $hand, $chan, $arg){	/* ban takes 2 arguments, with one optional	 * ban <1 word uhost or nick> <rest reason>   * fuck it I guess they all do	 */	$prop = new VotingProposition($net, $chan, "ban", time(), $nick, $arg);	$prop->evaluate();}function voting_unban($net, $nick, $uhost, $hand, $chan, $arg){	$prop = new VotingProposition($net, $chan, "unban", time(), $nick, $arg);	$prop->evaluate();}function voting_kick($net, $nick, $uhost, $hand, $chan, $arg){	$prop = new VotingProposition($net, $chan, "kick", time(), $nick, $arg);	$prop->evaluate();}function voting_censure($net, $nick, $uhost, $hand, $chan, $arg){	$prop = new VotingProposition($net, $chan, "censure", time(), $nick, $arg);	$prop->evaluate();}function voting_elect($net, $nick, $uhost, $hand, $chan, $arg){	$prop = new VotingProposition($net, $chan, "elect", time(), $nick, $arg);	$prop->evaluate();}function voting_impeach($net, $nick, $uhost, $hand, $chan, $arg){	$prop = new VotingProposition($net, $chan, "impeach", time(), $nick, $arg);	$prop->evaluate();}?>