# This is the voting module duplicated from Impious
# Some improvements made
# poutine 2007-02-17
## basic Configuration
# Command prefixes
set vote_config(cmd_prefix) "@"
# Which channel should this run in
set vote_config(chan) "#php"
# Who should this bot send votes to?
# Separate nicks with a , no spaces
set vote_config(notify) "Rex_Goodheart,poutine"
# Path to the citizens file
set vote_config(citizens_file) "text/citizens.txt"
# Path to log file
set vote_config(log_file) "text/vote-log.txt"
## vote throttling
# Throttling mode 0 = off, 1 = user, 2 = chan
set vote_config(throttle_mode) 1
# How long in seconds to wait until a user/chan can call for
# another kick vote
# 10 minutes = 600 seconds
set vote_config(throttle_kick) 600
# How long in seconds to wait until a user/chan can call for
# another ban vote
# 10 minutes = 600 seconds
set vote_config(throttle_ban) 600
# How long in seconds to wait until a user/chan can call for
# another elect vote
# 10 minutes = 600 seconds
set vote_config(throttle_elect) 600
# How long in seconds to wait until a user/chan can call for
# another impeach vote
# 10 minutes = 600 seconds
set vote_config(throttle_impeach) 600
# How long in seconds to wait until a user/chan can call for
# another ban vote
# 10 minutes = 600 seconds
set vote_config(throttle_ban) 600
# How long in seconds to wait until a user/chan can call for
# another kick vote
# 10 minutes = 600 seconds
set vote_config(throttle_kick) 600
# How long in seconds to wait until a user/chan can call for
# another censure vote
# 10 minutes = 600 seconds
set vote_config(throttle_censure) 600
# How long in seconds to wait until a user/chan can call for
# another trivia on/off vote
# 10 minutes = 600 seconds
set vote_config(throttle_trivia) 600
# How long in seconds to wait until a user/chan can call for
# another frenzy on/off vote
# 10 minutes = 600 seconds
set vote_config(throttle_frenzy) 600
## Advanced Bans
# Advanced bans
# Advanced bans are bans for a specified amount of time
# its inclusion in the !ban trigger is optional
# You need to setup times for bans, and a default ban time
# You can ignore this if disabled. set this to 0 to disable.
set vote_config(advanced_bans) 1
# Time limits in seconds for bans
# 10 minutes, 30 minutes, 1 hour, 6 hours, 1 day
set vote_config(advanced_ban_times) "600 1800 3600 21600 86400"
set vote_config(advanced_ban_vote_start) 3
set vote_config(advanced_ban_vote_increment) 1
set vote_config(advanced_ban_default_time) "600"
## Basic Vote Counts
# Each setting is self explanatory, vote counts for each punishment
set vote_config(count_impeach) 6
set vote_config(count_elect) 4
set vote_config(cit_count_ban) 5
set vote_config(count_ban) 3
set vote_config(cit_count_kick) 4
set vote_config(count_kick) 3
set vote_config(cit_count_censure) 3
set vote_config(cit_count_trivia) 3
set vote_config(cit_count_frenzy) 3
set vote_config(elect_vote_time) 60
set vote_config(ban_vote_time) 60
set vote_config(kick_vote_time) 60
set vote_config(impeach_vote_time) 60
## COLOR/CONTROL CODES
set vote_config(code1) ""
set vote_config(code2) ""
#### INITIALIZATION ####
# This shouldn't be messed with
set vote_config(impeach_last_time) 0
set vote_config(ban_last_time) 0
set vote_config(elect_last_time) 0
set vote_config(kick_last_time) 0
set vote_config(voteyescount) 0
set vote_config(votenocount) 0
# pending votes
set vote_config(pvoteyescount) 0
set vote_config(pvotenocount) 0
# pending votes waiting for results
set vote_config(pvotewait) 0
set vote_config(invote) 0
set vote_config(vote_type) "ban"
set vote_config(vote_victim) "poutine"
set vote_config(vote_timer) 0
set vote_config(votes) ""
bind pub - "$vote_config(cmd_prefix)confirm" impious:confirm
bind pub - "$vote_config(cmd_prefix)ban" impious:vote_ban
bind pub - "$vote_config(cmd_prefix)crucify" impious:vote_ban
bind pub - "$vote_config(cmd_prefix)elect" impious:vote_elect
bind pub - "$vote_config(cmd_prefix)impeach" impious:vote_impeach
bind pub - "$vote_config(cmd_prefix)kick" impious:vote_kick
bind pub - "$vote_config(cmd_prefix)voice" impious:vote_voice
bind pub - "$vote_config(cmd_prefix)devoice" impious:vote_devoice
bind pub - "$vote_config(cmd_prefix)censure" impious:vote_devoice
bind join - "$vote_config(chan) *" impious:deauth_join
bind nick - "$vote_config(chan) *" impious:deauth_nick
bind raw - "307" impious:verify_cit
proc impious:deauth_join { nick uhost hand chan } {
global vote_config
set vote_config(${nick}_auth) 0
putserv "whois $nick"
}
proc impious:deauth_nick { nick uhost hand chan newnick } {
global vote_config
set vote_config($newnick_auth) 0
putserv "whois $nick"
}
proc vote:yes { nick uhost hand arg } {
global vote_config
set cit [check_cit $nick]
if {$cit == -1} {
return
} elseif {$cit == 0} {
# Citizen is pending, set what it should do when decided
set vote_config(${nick}_onverify) "vote:yes \{$nick\} \{\} \{\} \{$chan\} \{\}"
return
}
if {[lsearch $vote_config(votes) "$nick*"] == -1} {
lappend vote_config(votes) "$nick 1"
incr vote_config(voteyescount)
puthelp "PRIVMSG $nick :Your voting eligibility has been confirmed as $nick addr: [getchanhost $nick] ip: 00.00.00.00 Votes: 1. Your vote has been recorded as YES."
}
}
proc vote:no { nick uhost hand arg } {
global vote_config
set cit [check_cit $nick]
if {$cit == -1} {
return
} elseif {$cit == 0} {
# Citizen is pending, set what it should do when decided
set vote_config(${nick}_onverify) "vote:no \{$nick\} \{\} \{\} \{$chan\} \{\}"
return
}
if {[lsearch $vote_config(votes) "$nick*"] == -1} {
lappend vote_config(votes) "$nick 0"
incr vote_config(votenocount)
puthelp "PRIVMSG $nick :Your voting eligibility has been confirmed as $nick addr: [getchanhost $nick] ip: 00.00.00.00 Votes: 1. Your vote has been recorded as NO."
}
}
proc end_kick { nick chan victim } {
global vote_config botnick
if {$vote_config(voteyescount) >= $vote_config(count_kick)} {
if {$vote_config(voteyescount) > $vote_config(votenocount)} {
set status "passed"
} else {
set status "failed"
}
} else {
set status "failed"
}
puthelp "PRIVMSG $chan :$vote_config(code1)The motion to kick $vote_config(code2)$victim $vote_config(code1)has $status. The vote was $vote_config(code2)YES $vote_config(voteyescount) - NO $vote_config(votenocount). $vote_config(code1)($vote_config(count_kick) votes required for passage)"
unbind msg - "yes" vote:yes
unbind msg - "no" vote:no
if {$status == "passed"} {
putkick $chan $victim "requested by $nick"
}
set vote_config(kick_last_time) [unixtime]
}
proc end_ban { nick chan victim } {
global vote_config botnick
if {$vote_config(voteyescount) >= $vote_config(count_ban)} {
if {$vote_config(voteyescount) > $vote_config(votenocount)} {
set status "passed"
} else {
set status "failed"
}
} else {
set status "failed"
}
puthelp "PRIVMSG $chan :$vote_config(code1)The motion to ban $vote_config(code2)$victim $vote_config(code1)has $status. The vote was $vote_config(code2)YES $vote_config(voteyescount) - NO $vote_config(votenocount). $vote_config(code1)($vote_config(count_ban) votes required for passage)"
unbind msg - "yes" vote:yes
unbind msg - "no" vote:no
set vote_config(ban_last_time) [unixtime]
}
proc end_impeach { nick chan victim } {
global vote_config botnick
if {$vote_config(voteyescount) >= $vote_config(count_impeach)} {
if {$vote_config(voteyescount) > $vote_config(votenocount)} {
set status "passed"
} else {
set status "failed"
}
} else {
set status "failed"
}
puthelp "PRIVMSG $chan :$vote_config(code1)The motion to impeach $vote_config(code2)$victim $vote_config(code1)has $status. The vote was $vote_config(code2)YES $vote_config(voteyescount) - NO $vote_config(votenocount). $vote_config(code1)($vote_config(count_impeach) votes required for passage)"
unbind msg - "yes" vote:yes
unbind msg - "no" vote:no
set vote_config(impeach_last_time) [unixtime]
}
proc end_elect { nick chan victim } {
global vote_config botnick
if {$vote_config(voteyescount) >= $vote_config(count_elect)} {
if {$vote_config(voteyescount) > $vote_config(votenocount)} {
set status "passed"
} else {
set status "failed"
}
} else {
set status "failed"
}
puthelp "PRIVMSG $chan :$vote_config(code1)The motion to elect $vote_config(code2)$victim $vote_config(code1)has $status. The vote was $vote_config(code2)YES $vote_config(voteyescount) - NO $vote_config(votenocount). $vote_config(code1)($vote_config(count_elect) votes required for passage)"
unbind msg - "yes" vote:yes
unbind msg - "no" vote:no
set vote_config(elect_last_time) [unixtime]
}
proc impious:vote_impeach { nick uhost hand chan arg } {
global vote_config botnick
if {$vote_config(chan) != $chan} {
return
}
set cit [check_cit $nick]
if {$cit == -1} {
return
} elseif {$cit == 0} {
# Citizen is pending, set what it should do when decided
set vote_config(${nick}_onverify) "impious:vote_impeach \{$nick\} \{\} \{\} \{$chan\} \{$arg\}"
return
}
if {[expr [unixtime] - $vote_config(impeach_last_time)] < $vote_config(throttle_impeach)} {
set secs [expr $vote_config(throttle_impeach) - ([unixtime] - $vote_config(impeach_last_time))]
puthelp "PRIVMSG $chan :$vote_config(code1)Sorry... another impeach vote will not be allowed for another $secs seconds"
return;
}
set victim [lindex $arg 0]
set reason ""
if {[llength $arg] == 1} {
puthelp "PRIVMSG $chan :$vote_config(code1)$nick has called for a vote to impeach $vote_config(code2)$victim . $vote_config(code1)You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
} elseif {[llength $arg] > 1} {
set reason [lrange $arg 1 end]
puthelp "PRIVMSG $chan :$vote_config(code1)$nick has called for a vote to impeach $vote_config(code2)$victim . $vote_config(code1)Stated reason: $vote_config(code2)$reason . $vote_config(code1)You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
}
bind msg - "yes" vote:yes
bind msg - "no" vote:no
set vote_config(voteyescount) 0
set vote_config(votenocount) 0
set vote_config(votes) ""
utimer $vote_config(impeach_vote_time) "end_impeach $nick $chan $victim"
}
proc impious:vote_elect { nick uhost hand chan arg } {
global vote_config botnick
if {$vote_config(chan) != $chan} {
return
}
set cit [check_cit $nick]
if {$cit == -1} {
return
} elseif {$cit == 0} {
# Citizen is pending, set what it should do when decided
set vote_config(${nick}_onverify) "impious:vote_elect \{$nick\} \{\} \{\} \{$chan\} \{$arg\}"
return
}
if {[expr [unixtime] - $vote_config(elect_last_time)] < $vote_config(throttle_elect)} {
set secs [expr $vote_config(throttle_elect) - ([unixtime] - $vote_config(elect_last_time))]
puthelp "PRIVMSG $chan :$vote_config(code1)Sorry... another elect vote will not be allowed for another $secs seconds"
return;
}
set victim [lindex $arg 0]
set reason ""
if {[llength $arg] == 1} {
puthelp "PRIVMSG $chan :$vote_config(code1)$nick has called for a vote to elect $vote_config(code2)$victim . $vote_config(code1)You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
} elseif {[llength $arg] > 1} {
set reason [lrange $arg 1 end]
puthelp "PRIVMSG $chan :$vote_config(code1)$nick has called for a vote to elect $vote_config(code2)$victim . $vote_config(code1)Stated reason: $vote_config(code2)$reason . $vote_config(code1)You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
}
bind msg - "yes" vote:yes
bind msg - "no" vote:no
set vote_config(voteyescount) 0
set vote_config(votenocount) 0
set vote_config(votes) ""
utimer $vote_config(elect_vote_time) "end_elect $nick $chan $victim"
}
proc impious:vote_kick { nick uhost hand chan arg } {
global vote_config botnick
if {$vote_config(chan) != $chan} {
return
}
set cit [check_cit $nick]
if {$cit == -1} {
return
} elseif {$cit == 0} {
# Citizen is pending, set what it should do when decided
set vote_config(${nick}_onverify) "impious:vote_kick \{$nick\} \{\} \{\} \{$chan\} \{$arg\}"
return
}
if {[expr [unixtime] - $vote_config(kick_last_time)] < $vote_config(throttle_kick)} {
set secs [expr $vote_config(throttle_kick) - ([unixtime] - $vote_config(kick_last_time))]
puthelp "PRIVMSG $chan :$vote_config(code1)Sorry... another kick vote will not be allowed for another $secs seconds"
return;
}
set victim [lindex $arg 0]
set reason ""
if {[llength $arg] == 1} {
puthelp "PRIVMSG $chan :$vote_config(code1)$nick has called for a vote to kick $vote_config(code2)$victim . $vote_config(code1)You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
} elseif {[llength $arg] > 1} {
set reason [lrange $arg 1 end]
puthelp "PRIVMSG $chan :$vote_config(code1)$nick has called for a vote to kick $vote_config(code2)$victim . $vote_config(code1)Stated reason: $vote_config(code2)$reason . $vote_config(code1)You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
}
bind msg - "yes" vote:yes
bind msg - "no" vote:no
set vote_config(voteyescount) 0
set vote_config(votenocount) 0
set vote_config(votes) ""
utimer $vote_config(kick_vote_time) "end_kick $nick $chan $victim"
}
proc impious:vote_ban { nick uhost hand chan arg } {
global vote_config botnick
if {$vote_config(chan) != $chan} {
return
}
set cit [check_cit $nick]
if {$cit == -1} {
return
} elseif {$cit == 0} {
# Citizen is pending, set what it should do when decided
set vote_config(${nick}_onverify) "impious:vote_ban \{$nick\} \{\} \{\} \{$chan\} \{$arg\}"
return
}
if {[expr [unixtime] - $vote_config(ban_last_time)] < $vote_config(throttle_ban)} {
set secs [expr $vote_config(throttle_ban) - ([unixtime] - $vote_config(ban_last_time))]
puthelp "PRIVMSG $chan :$vote_config(code1)Sorry... another ban vote will not be allowed for another $secs seconds"
return;
}
set vote_config(votes) ""
set victim [lindex $arg 0]
if {[llength $arg] == 1} {
set reason ""
puthelp "PRIVMSG $chan :$vote_config(code1)$nick has called for a vote to ban $vote_config(code2)$victim . $vote_config(code1)You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
} elseif {[llength $arg] > 1} {
set reason [lrange $arg 1 end]
puthelp "PRIVMSG $chan :$vote_config(code1)$nick has called for a vote to ban $vote_config(code2)$victim . $vote_config(code1)Stated reason: $vote_config(code2)$reason . $vote_config(code1)You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
}
bind msg - "yes" vote:yes
bind msg - "no" vote:no
set vote_config(voteyescount) 0
set vote_config(votenocount) 0
set vote_config(votes) ""
utimer $vote_config(ban_vote_time) "end_ban $nick $chan $victim"
}
proc impious:confirm { nick uhost hand chan arg } {
global vote_config
if {$vote_config(chan) != $chan} {
return
}
if {[llength $arg] > 0} {
set victim [lindex $arg 0]
} else {
set victim $nick
}
set cit [check_cit $victim]
if {$cit == -1} {
puthelp "PRIVMSG $chan :$vote_config(code1)$victim is not a registered citizen of this channel."
return
} elseif {$cit == 0} {
set vote_config(${victim}_onverify) "impious:confirm \{$victim\} \{\} \{\} \{$chan\} \{\}"
return
} else {
set vhost [lindex [split [getchanhost $victim $chan] "@"] 1]
puthelp "PRIVMSG $chan :$vote_config(code1)$victim $chan citizenship = $vote_config(code2)$victim addr: $vhost ip: 00.00.00.00 Votes: 1"
}
}
proc impious:verify_cit { from keyword text } {
global vote_config
set nick [lindex $text 1]
set vote_config(${nick}_auth) 1
eval "$vote_config(${nick}_onverify)"
}
proc check_cit { nick } {
global vote_config
if {[lsearch $vote_config(citizens) $nick] == -1} {
return -1;
}
if {![info exists vote_config(${nick}_auth)] || $vote_config(${nick}_auth) == 0} {
# Cit check pending
putserv "WHOIS $nick"
return 0;
} else {
# Definitely not a cit
if {$vote_config(${nick}_auth) == -1} {
return -1
}
return 1;
}
}
proc load_citizens { } {
global vote_config
set fd [open $vote_config(citizens_file) "r"]
set vote_config(citizens) [split [read $fd] "\n"]
close $fd
}
load_citizens