Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 24.82 KB | None | 0 0
  1. # This is the voting module duplicated from Impious
  2. #
  3.  
  4. ## basic Configuration
  5.  
  6. # Command prefixes
  7. set vote_config(cmd_prefix) "@"
  8.  
  9. # Which channel should this run in
  10. set vote_config(channel) "#subreddit"
  11.  
  12. # Who should this bot send votes to?
  13. # Separate nicks with a , no spaces
  14. set vote_config(notify) "poutine"
  15.  
  16. # Path to the citizens file
  17. set vote_config(citizens_file) "text/freecitizens.txt"
  18.  
  19. # Path to log file
  20. set vote_config(log_file) "text/vote-log.txt"
  21.  
  22. # Integrate trivia ?
  23. set vote_config(regulate_trivia) 0
  24.  
  25. ## vote throttling
  26.  
  27. # Throttling mode 0 = off, 1 = user, 2 = channel
  28. set vote_config(throttle_mode) 2
  29.  
  30. # How long in seconds to wait until a user/channel can call for
  31. # another kick vote
  32. # 10 minutes = 600 seconds
  33. set vote_config(throttle_kick) 0
  34.  
  35. # How long in seconds to wait until a user/channel can call for
  36. # another ban vote
  37. # 10 minutes = 600 seconds
  38. set vote_config(throttle_ban) 0
  39.  
  40. # How long in seconds to wait until a user/channel can call for
  41. # another elect vote
  42. # 10 minutes = 600 seconds
  43. set vote_config(throttle_elect) 600
  44.  
  45. # How long in seconds to wait until a user/channel can call for
  46. # another impeach vote
  47. # 10 minutes = 600 seconds
  48. set vote_config(throttle_impeach) 600
  49.  
  50. # How long in seconds to wait until a user/channel can call for
  51. # another topic vote
  52. # 10 minutes = 600 seconds
  53. set vote_config(throttle_topic) 100
  54.  
  55. # How long in seconds to wait until a user/channel can call for
  56. # another ban vote
  57. # 10 minutes = 600 seconds
  58. set vote_config(throttle_ban) 600
  59.  
  60. # How long in seconds to wait until a user/channel can call for
  61. # another kick vote
  62. # 10 minutes = 600 seconds
  63. set vote_config(throttle_kick) 600
  64.  
  65. # How long in seconds to wait until a user/channel can call for
  66. # another invite vote
  67. # 10 minutes = 600 seconds
  68. set vote_config(throttle_invite) 600
  69.  
  70. # How long in seconds to wait until a user/channel can call for
  71. # another censure vote
  72. # 10 minutes = 600 seconds
  73. set vote_config(throttle_censure) 600
  74.  
  75. # How long in seconds to wait until a user/channel can call for
  76. # another trivia on/off vote
  77. # 10 minutes = 600 seconds
  78. set vote_config(throttle_trivia) 600
  79.  
  80. # How long in seconds to wait until a user/channel can call for
  81. # another frenzy on/off vote
  82. # 10 minutes = 600 seconds
  83. set vote_config(throttle_frenzy) 600
  84.  
  85.  
  86. ## Crap settings
  87.  
  88. # Allow invalid targets to be elected?
  89. set vote_config(allow_absent_election) 1
  90.  
  91. ## Advanced Bans
  92.  
  93. # Advanced bans
  94. # NON-FUNCTIONAL
  95. # Advanced bans are bans for a specified amount of time
  96. # its inclusion in the !ban trigger is optional
  97. # You need to setup times for bans, and a default ban time
  98. # You can ignore this if disabled. set this to 0 to disable.
  99. set vote_config(advanced_bans) 0
  100.  
  101. # Time limits in seconds for bans
  102. # 10 minutes, 30 minutes, 1 hour, 6 hours, 1 day
  103. set vote_config(advanced_ban_times) "600 1800 3600 21600 86400"
  104.  
  105. set vote_config(advanced_ban_vote_start) 3
  106.  
  107. set vote_config(advanced_ban_vote_increment) 1
  108.  
  109. set vote_config(advanced_ban_default_time) "600"
  110.  
  111.  
  112. ## Basic Vote Counts
  113.  
  114. # Each setting is self explanatory, vote counts for each punishment
  115.  
  116. set vote_config(count_impeach) 6
  117. set vote_config(count_elect) 3
  118. set vote_config(cit_count_ban) 4
  119. set vote_config(count_ban) 3
  120. set vote_config(count_topic) 2
  121. set vote_config(count_trivia) 3
  122.  
  123. set vote_config(cit_count_kick) 3
  124. set vote_config(count_kick) 2
  125. set vote_config(count_invite) 3
  126.  
  127. set vote_config(cit_count_invite) 3
  128. set vote_config(cit_count_topic) 3
  129. set vote_config(cit_count_censure) 3
  130. set vote_config(cit_count_trivia) 3
  131. set vote_config(cit_count_frenzy) 3
  132. set vote_config(cit_count_trivia) 3
  133.  
  134. set vote_config(topic_vote_time) 60
  135. set vote_config(invite_vote_time) 60
  136. set vote_config(elect_vote_time) 60
  137. set vote_config(ban_vote_time) 60
  138. set vote_config(kick_vote_time) 60
  139. set vote_config(impeach_vote_time) 60
  140. set vote_config(trivia_vote_time) 60
  141.  
  142. ## COLOR/CONTROL CODES
  143. set vote_config(code1) "\0035"
  144. set vote_config(code2) "\00314"
  145.  
  146.  
  147. #### INITIALIZATION ####
  148.  
  149. # This shouldn't be messed with
  150.  
  151. set vote_config(impeach_last_time) 0
  152. set vote_config(ban_last_time) 0
  153. set vote_config(elect_last_time) 0
  154. set vote_config(kick_last_time) 0
  155. set vote_config(topic_last_time) 0
  156. set vote_config(trivia_last_time) 0
  157. set vote_config(invite_last_time) 0
  158.  
  159. set vote_config(voteyescount) 0
  160. set vote_config(votenocount)  0
  161.  
  162. # pending votes
  163. set vote_config(pvoteyescount) 0
  164. set vote_config(pvotenocount) 0
  165.  
  166. # pending votes waiting for results
  167. set vote_config(pvotewait) 0
  168.  
  169. set vote_config(invote) 0
  170.  
  171. set vote_config(vote_type) "ban"
  172. set vote_config(vote_victim) "poutine"
  173. set vote_config(vote_victim_mask) ""
  174. set vote_config(vote_text) ""
  175. set vote_config(vote_timer) 0
  176.  
  177. set vote_config(votes) ""  
  178.  
  179.  
  180. bind pub - "$vote_config(cmd_prefix)confirm" impious:confirm
  181. bind pub - "$vote_config(cmd_prefix)ban"     impious:vote_ban
  182. bind pub - "$vote_config(cmd_prefix)invite"     impious:vote_invite
  183. bind pub - "$vote_config(cmd_prefix)crucify" impious:vote_ban
  184. bind pub - "$vote_config(cmd_prefix)elect"   impious:vote_elect
  185. bind pub - "$vote_config(cmd_prefix)impeach" impious:vote_impeach
  186. bind pub - "$vote_config(cmd_prefix)kick"    impious:vote_kick
  187. #bind pub - "$vote_config(cmd_prefix)voice"   impious:vote_voice
  188. #bind pub - "$vote_config(cmd_prefix)devoice" impious:vote_devoice
  189. #bind pub - "$vote_config(cmd_prefix)censure" impious:vote_devoice
  190. bind pub - "$vote_config(cmd_prefix)citizens" impious:citizens
  191. bind pub I "$vote_config(cmd_prefix)addcit" impious:addcit
  192. bind pub - "$vote_config(cmd_prefix)topic" impious:vote_topic
  193. bind pub - "$vote_config(cmd_prefix)trivia" impious:vote_trivia
  194.  
  195.  
  196. bind join - "$vote_config(channel) *" impious:deauth_join
  197. bind nick - "$vote_config(channel) *" impious:deauth_nick
  198.  
  199. #bind mode - "-v" impious:no_bitch
  200. #bind mode - "+v" impious:no_bitch
  201.  
  202. # >> :calvino.freenode.net 330 poutine tswift tswift :is logged in as */
  203. bind raw - "311"      impious:start_whois
  204. #bind raw - "307"      impious:verify_cit
  205. bind raw - "318"            impious:not_identified
  206. bind raw - "330"            impious:freenode_identified_alias
  207.  
  208. proc impious:vote_invite { nick uhost hand channel arg } {
  209.     impious:start_vote "invite" $nick [lindex $arg 0] [lrange $arg 1 end]
  210. }
  211.  
  212.  
  213. proc impious:vote_impeach { nick uhost hand channel arg } {
  214.     impious:start_vote "impeach" $nick [lindex $arg 0] [lrange $arg 1 end]
  215. }
  216.  
  217. proc impious:vote_elect { nick uhost hand channel arg } {
  218.     impious:start_vote "elect" $nick [lindex $arg 0] [lrange $arg 1 end]
  219. }
  220.  
  221. proc impious:vote_trivia { nick uhost hand channel arg } {
  222.     impious:start_vote "trivia" $nick "null" $arg
  223. }
  224.  
  225. proc impious:vote_topic { nick uhost hand channel arg } {
  226.     impious:start_vote "topic" $nick "null" $arg
  227. }
  228.  
  229. proc impious:vote_kick { nick uhost hand channel arg } {
  230.     global botnick
  231.  
  232.     if {[lindex $arg 0] == $botnick} {
  233.         puthelp "PRIVMSG $channel :Homey don't play that"
  234.         return 
  235.     }
  236.     impious:start_vote "kick" $nick [lindex $arg 0] [lrange $arg 1 end]
  237. }
  238.  
  239. proc impious:vote_ban { nick uhost hand channel arg } {
  240.     impious:start_vote "ban" $nick [lindex $arg 0] [lrange $arg 1 end]
  241. }
  242.  
  243.  
  244. proc impious:no_bitch { nick uhost hand channel change target } {
  245.     global vote_config botnick
  246.  
  247.     if {$nick == $botnick} {
  248.         return
  249.     }
  250.  
  251.     check_cit [string tolower $target]
  252. }
  253.  
  254. proc impious:quickaddcit { victim } {
  255.     global vote_config
  256.     set victim [string tolower [lindex $victim 0]]
  257.  
  258.     lappend vote_config(citizens) $victim
  259.     save_citizens
  260. }
  261.  
  262. proc impious:addcit { nick uhost hand channel arg } {
  263.     global vote_config
  264.  
  265.     set victim [string tolower [lindex $arg 0]]
  266.  
  267.     if {$vote_config(allow_absent_election) != 1} {
  268.         if {![onchan $victim $channel]} {
  269.             puthelp "PRIVMSG $channel :$vote_config(code2)${victim} $vote_config(code1)is not on this channel."
  270.             return
  271.         }
  272.     }
  273.  
  274.     lappend vote_config(citizens) $victim
  275.     save_citizens
  276.  
  277.     puthelp "PRIVMSG $channel :$vote_config(code2)${victim} $vote_config(code1)has been added to the citizens list."
  278. }
  279.  
  280.  
  281. proc impious:citizens { nick uhost hand channel arg } {
  282.     global vote_config outlist
  283.  
  284.     set outlist ""
  285.  
  286.     foreach {citizen} $vote_config(citizens) {
  287.         if {[onchan $citizen $channel]} {
  288.             lappend outlist $citizen
  289.         }
  290.     }
  291.  
  292.     set noncit ""
  293.  
  294.     foreach {person} [chanlist $channel] {
  295.         if {[lsearch $vote_config(citizens) [string tolower $person]] == -1} {
  296.             lappend noncit $person
  297.         }
  298.     }
  299.  
  300.     set citizen_count [llength $outlist]
  301.     set noncitizen_count [llength $noncit]
  302.  
  303.     puthelp "PRIVMSG $channel :$vote_config(code1) Citizens $vote_config(code2) $citizen_count $vote_config(code1) Noncitizens $vote_config(code2) $noncitizen_count $vote_config(code1) ( $noncit )"
  304.  
  305. }
  306.  
  307. proc impious:deauth_join { nick uhost hand channel } {
  308.   global vote_config
  309.  
  310.   set vote_config(${nick}_auth) 0
  311.  
  312.   putserv "whois $nick"
  313. }
  314.  
  315. proc impious:deauth_nick { nick uhost hand channel newnick } {
  316.   global vote_config
  317.  
  318.   set vote_config(${newnick}_auth) 0
  319.  
  320.   putserv "whois $nick"
  321. }
  322.  
  323. proc vote:pubyes { nick uhost hand channel arg } {
  324.   global vote_config
  325.  
  326.   set cit [check_cit $nick]
  327.  
  328.   if {$cit == -1} {
  329.         puthelp "PRIVMSG $nick :You're not a citizen. If you believe this to be an error, make sure you're identified to your nickname."
  330.     return
  331.   } elseif {$cit == 0} {
  332.     # Citizen is pending, set what it should do when decided
  333.     set vote_config(${nick}_onverify) "vote:pubyes \{$nick\} \{\} \{\} \{$vote_config(channel)\} \{\}"
  334.     return
  335.   }
  336.  
  337.   if {[lsearch $vote_config(votes) "$nick*"] == -1} {
  338.     lappend vote_config(votes) "$nick 1"
  339.     incr vote_config(voteyescount)
  340.         puthelp "PRIVMSG $channel :$nick, You have successfully voted YES."
  341. #    puthelp "PRIVMSG $channel :$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."
  342.   }
  343. }
  344.  
  345. proc vote:pubno { nick uhost hand channel arg } {
  346.   global vote_config
  347.  
  348.   set cit [check_cit $nick]
  349.  
  350.   if {$cit == -1} {
  351.         puthelp "PRIVMSG $nick :You're not a citizen. If you believe this to be an error, make sure you're identified to your nickname."
  352.     return
  353.   } elseif {$cit == 0} {
  354.     # Citizen is pending, set what it should do when decided
  355.     set vote_config(${nick}_onverify) "vote:pubno \{$nick\} \{\} \{\} \{$channel\} \{\}"
  356.     return
  357.   }
  358.  
  359.   if {[lsearch $vote_config(votes) "$nick*"] == -1} {
  360.     lappend vote_config(votes) "$nick 0"
  361.     incr vote_config(votenocount)
  362.     puthelp "PRIVMSG $channel :$nick, You have successfully voted NO."
  363.   }
  364.  
  365. }
  366.  
  367.  
  368.  
  369.  
  370. proc vote:yes { nick uhost hand arg } {
  371.   global vote_config
  372.  
  373.     if {![onchan $nick $vote_config(channel)]} {
  374.         puthelp "PRIVMSG $nick :Fixed this bug, nice try though"
  375.         return
  376.     }
  377.  
  378.   set cit [check_cit $nick]
  379.  
  380.   if {$cit == -1} {
  381.         puthelp "PRIVMSG $nick :You're not a citizen. If you believe this to be an error, make sure you're identified to your nickname."
  382.     return
  383.   } elseif {$cit == 0} {
  384.     # Citizen is pending, set what it should do when decided
  385.     set vote_config(${nick}_onverify) "vote:yes \{$nick\} \{\} \{\} \{$vote_config(channel)\} \{\}"
  386.     return
  387.   }
  388.  
  389.   if {[lsearch $vote_config(votes) "$nick*"] == -1} {
  390.     lappend vote_config(votes) "$nick 1"
  391.     incr vote_config(voteyescount)
  392.     puthelp "PRIVMSG $nick :You have successfully voted YES."
  393.   }
  394. }
  395.  
  396. proc vote:no { nick uhost hand arg } {
  397.   global vote_config
  398.  
  399.     if {![onchan $nick $vote_config(channel)]} {
  400.         puthelp "PRIVMSG $nick :Fixed this bug, nice try though"
  401.         return
  402.     }
  403.  
  404.   set cit [check_cit $nick]
  405.  
  406.   if {$cit == -1} {
  407.         puthelp "PRIVMSG $nick :You're not a citizen. If you believe this to be an error, make sure you're identified to your nickname."
  408.     return
  409.   } elseif {$cit == 0} {
  410.     # Citizen is pending, set what it should do when decided
  411.     set vote_config(${nick}_onverify) "vote:no \{$nick\} \{\} \{\} \{$channel\} \{\}"
  412.     return
  413.   }
  414.  
  415.   if {[lsearch $vote_config(votes) "$nick*"] == -1} {
  416.     lappend vote_config(votes) "$nick 0"
  417.     incr vote_config(votenocount)
  418.     puthelp "PRIVMSG $nick :You have successfully voted NO."
  419.   }
  420.  
  421. }
  422.  
  423. # Boilerplate shit
  424. #
  425. proc impious:gen_std_fail_notify_msg { initiator type target passed vote_req } {
  426.     global vote_config botnick
  427.  
  428.     set notifymsg "$vote_config(code1)The vote to $type $vote_config(code2)$target $vote_config(code1) has FAILED. ($vote_config(voteyescount) Yes votes, $vote_config(votenocount) No votes. $vote_req Yes votes required)."
  429.  
  430.     return $notifymsg
  431. }
  432.  
  433. proc impious:gen_std_success_notify_msg { initiator type target passed vote_req } {
  434.     global vote_config botnick
  435.  
  436.     set notifymsg "$vote_config(code1)The vote to $type $vote_config(code2)$target $vote_config(code1) has PASSED. ($vote_config(voteyescount) Yes votes, $vote_config(votenocount) No votes. $vote_req Yes votes required)."
  437.  
  438.     return $notifymsg
  439. }
  440.  
  441.  
  442.  
  443. proc impious:gen_std_notify_msg { type initiator target arg } {
  444.     global vote_config botnick
  445.  
  446.     if {[string length $target] == 0} {
  447.     set notifymsg "$vote_config(code1)$initiator has called for a vote to turn on $type. You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
  448.     } elseif {[llength $target] > 0 && [string length $target] > 0} {
  449.     set notifymsg "$vote_config(code1)$initiator has called for a vote to $type $target. Stated reason: $vote_config(code2)$arg . $vote_config(code1)You have one minute to vote by messaging $botnick with a $vote_config(code2)YES or NO."
  450.     }
  451.  
  452.     return $notifymsg
  453. }
  454.  
  455. # This function determines whether a target is a person, hostmask, or nick
  456. proc impious:determine_target_host { target } {
  457.     global vote_config botnick
  458.  
  459.     if {[onchan $target $vote_config(channel)]} {
  460.         return [maskhost [getchanhost $target $vote_config(channel)]]
  461.     } elseif {[string first "@" $target] == -1} {
  462.         return "$target!*@*"
  463.     } else {
  464.         return $target
  465.     }
  466. }
  467.  
  468. proc impious:end_vote { initiator type target targethost arg } {
  469.     global vote_config botnick
  470.  
  471.     unbind pub - "yes" vote:pubyes
  472.     unbind pub - "no"  vote:pubno
  473.   unbind msg - "yes" vote:yes
  474.   unbind msg - "no"  vote:no
  475.  
  476.     set vote_config(invote) 0
  477.  
  478.     # Check vote count
  479.     set vote_req $vote_config(count_${type})
  480.  
  481.     set passed "no"
  482.  
  483.     # Check vote is above count
  484.     if {$vote_config(voteyescount) >= $vote_req} {
  485.         # Check yes > no
  486.         if {$vote_config(votenocount) < $vote_config(voteyescount)} {
  487.             set passed "yes"
  488.         }
  489.     }
  490.  
  491.     # Announce Message
  492.     if {$passed == "no"} {
  493.         switch $type {
  494.             "ban" {
  495.                 set notifymsg [impious:gen_std_fail_notify_msg $initiator $type $target $passed $vote_req]
  496.             }
  497.             "unban" {
  498.                 set notifymsg [impious:gen_std_fail_notify_msg $initiator $type $target $passed $vote_req]
  499.             }
  500.             "invite" {
  501.                 set notifymsg [impious:gen_std_fail_notify_msg $initiator $type $target $passed $vote_req]
  502.             }
  503.             "elect" {
  504.                 set notifymsg [impious:gen_std_fail_notify_msg $initiator $type $target $passed $vote_req]
  505.             }
  506.             "impeach" {
  507.                 set notifymsg [impious:gen_std_fail_notify_msg $initiator $type $target $passed $vote_req]
  508.             }
  509.             "trivia" {
  510.                 set notifymsg [impious:gen_std_fail_feature_msg $initiator $type $target $passed $vote_req]
  511.             }
  512.             "kick" {
  513.                 set notifymsg [impious:gen_std_fail_notify_msg $initiator $type $target $passed $vote_req]
  514.             }
  515.             "topic" {
  516.                 set notifymsg "Yo this shitbrain $initiator called for a vote to set the topic to ($arg). And that shit done failed, required $vote_req and done got $vote_config(voteyescount) Yes votes, $vote_config(votenocount) No votes). Fuck y'all."
  517.             }
  518.         }
  519.  
  520.         puthelp "PRIVMSG $vote_config(channel) :$notifymsg"
  521.         return;
  522.     }
  523.  
  524.     # Perform action
  525.     if {$passed == "yes"} {
  526.         switch $type {
  527.             "ban" {
  528.                 set notifymsg [impious:gen_std_success_notify_msg $initiator $type $target $passed $vote_req]
  529. #               newchanban $vote_config(channel) $targethost $botnick $arg 3600
  530.                 puthelp "mode $vote_config(channel) +b $targethost";
  531.                 timer 3600 "puthelp \"MODE $vote_config(channel) -b $targethost\""
  532.             }
  533.             "unban" {
  534.                 set notifymsg [impious:gen_std_success_notify_msg $initiator $type $target $passed $vote_req]
  535.                 puthelp "mode $vote_config(channel) -b $targethost";
  536.                 #killchanban $vote_config(channel) $targethost 
  537.             }
  538.             "invite" {
  539.                  newchaninvite $vote_config(channel) $target $botnick "$initiator"
  540.             }
  541.             "elect" {
  542.                 set notifymsg [impious:gen_std_success_notify_msg $initiator $type $target $passed $vote_req]
  543.                 impious:quickaddcit $target
  544.             }
  545.             "impeach" {
  546.                 set notifymsg [impious:gen_std_success_notify_msg $initiator $type $target $passed $vote_req]
  547.             }
  548.             "trivia" {
  549.                 set notifymsg [impious:gen_std_success_notify_msg $initiator $type $target $passed $vote_req]
  550.             }
  551.             "kick" {
  552.                 set notifymsg [impious:gen_std_success_notify_msg $initiator $type $target $passed $vote_req]
  553.                 puthelp "mode $vote_config(channel) +b $targethost";
  554.                 utimer 1 "puthelp \"MODE $vote_config(channel) -b $targethost\""
  555.  
  556.                 #newchanban $vote_config(channel) $targethost $botnick $arg 1
  557.                 #utimer 3 "killchanban $vote_config(channel) $targethost"
  558.             }
  559.             "topic" {
  560.                 set notifymsg "that shit done passed"
  561.                 puthelp "TOPIC $vote_config(channel) :$arg \[$initiator\]"
  562.             }
  563.         }
  564.         puthelp "PRIVMSG $vote_config(channel) :$notifymsg"
  565.         return;
  566.  
  567.     }  
  568.  
  569. }
  570.  
  571. proc impious:start_vote { type initiator target arg } {
  572.     global vote_config botnick
  573.  
  574.  
  575.     if {$vote_config(invote) == 1} {
  576.         puthelp "PRIVMSG $vote_config(channel) :we're already in a vote dumbass"
  577.         return
  578.     }
  579.  
  580.     set vote_config(invote) 1
  581.     set initiator [string tolower $initiator]
  582.  
  583.     # Check if this person is a citizen, may need to defer call until later
  584.     set cit [check_cit $initiator]
  585.  
  586.     # -1 == Definitely not a citizen
  587.     if {$cit == -1} {  
  588.     return
  589.   } elseif {$cit == 0} {
  590.     # Citizen check is pending, set what it should do when decided
  591.     set vote_config(${initiator}_onverify) "impious:start_vote \{$type\} \{$initiator\} \{$target\} \{$arg\}"
  592.     return
  593.   }
  594.  
  595.     # If we're at this point, they're definitely a citizen, check secondary requirements
  596.     # Building of notification message
  597.     set notifymsg ""
  598.     set targethost ""
  599.  
  600.     switch $type {
  601.         "ban" {
  602.             set notifymsg [impious:gen_std_notify_msg $type $initiator $target $arg]
  603.             set targethost [impious:determine_target_host $target]
  604.         }
  605.         "invite" {
  606.             set notifymsg [impious:gen_std_notify_msg $type $initiator $target $arg]
  607.         }
  608.         "unban" {
  609.             set notifymsg [impious:gen_std_notify_msg $type $initiator $target $arg]
  610.             set targethost [impious:determine_target_host $target]
  611.         }
  612.         "elect" {
  613.             set notifymsg [impious:gen_std_notify_msg $type $initiator $target $arg]
  614.         }
  615.         "impeach" {
  616.             set notifymsg [impious:gen_std_notify_msg $type $initiator $target $arg]
  617.         }
  618.         "trivia" {
  619.             set notifymsg [impious:gen_std_feature_msg $type $initiator $target $arg]
  620.         }
  621.         "kick" {
  622.             set notifymsg [impious:gen_std_notify_msg $type $initiator $target $arg]
  623.             set targethost [impious:determine_target_host $target]
  624.         }
  625.         "topic" {
  626.             set notifymsg "Yo this shitbrain $initiator called for a vote to set the topic to ($arg) message me YES or NO to agree or disagree with that shit respectively, yo."
  627.         }
  628.     }
  629.  
  630.     # Throttling
  631.  
  632.     # If throttling is turned on
  633.     if {$vote_config(throttle_mode) > 0} {
  634.         # If the channel has a throttle time defined
  635.         if {[info exists vote_config(throttle_${type})]} {
  636.             if {![info exists vote_config(${type}_last_time)]} { set vote_config(${type}_last_time) 0 }
  637.  
  638.             if {[expr [unixtime] - $vote_config(${type}_last_time)] < $vote_config(throttle_${type})} {
  639.                 set secs [expr $vote_config(throttle_${type}) - ([unixtime] - $vote_config(${type}_last_time))]
  640.                 puthelp "PRIVMSG $vote_config(channel) :$vote_config(code1)Sorry... another $type vote will not be allowed for another $secs seconds"
  641.                 return;
  642.             }
  643.         }
  644.  
  645.         # Set the last time so we know when to base next throttling check from
  646.         set vote_config(${type}_last_time) [expr [unixtime] + $vote_config(${type}_vote_time)]
  647.     }
  648.  
  649.     # Notify the channel
  650.     puthelp "PRIVMSG $vote_config(channel) :$notifymsg"
  651.  
  652.     # Admin Notification
  653.     foreach admin [split $vote_config(notify) ","] {
  654.         puthelp "PRIVMSG $admin :VOTE CALLED - Initiator: $initiator Type: $type Target: $target Args: $arg"
  655.     }
  656.  
  657.     # Logging
  658.     set fp [open "text/votelog.txt" "a+"]
  659.     puts $fp "VOTE CALLED - Initiator: $initiator Type: $type Target: $target Args: $arg"
  660.     close $fp
  661.  
  662.     # Bind yes/no for voting, also reset all vote counts
  663.   bind msg - "yes" vote:yes
  664.   bind msg - "no" vote:no
  665.     bind pub - "yes" vote:pubyes
  666.     bind pub - "no" vote:pubno
  667.  
  668.   set vote_config(voteyescount) 0
  669.   set vote_config(votenocount) 0
  670.   set vote_config(votes) ""
  671.  
  672.     # Setting of end timer
  673.   utimer $vote_config(${type}_vote_time) "impious:end_vote \{$initiator\} \{$type\} \{$target\} \{$targethost\} \{$arg\}"
  674. }
  675.  
  676. proc impious:confirm { nick uhost hand channel arg } {
  677.   global vote_config
  678.  
  679.   if {$vote_config(channel) != $channel} {
  680.     return
  681.   }
  682.  
  683.   if {[llength $arg] > 0} {
  684.     set victim [string tolower [lindex $arg 0]]
  685.   } else {
  686.     set victim [string tolower $nick]
  687.   }
  688.  
  689.   set cit [check_cit $victim]
  690.  
  691.   if {$cit == -1} {
  692.     puthelp "PRIVMSG $channel :$vote_config(code1)$victim is not a registered citizen of this channel."
  693.     return
  694.   } elseif {$cit == 0} {
  695.     set vote_config(${victim}_onverify) "impious:confirm \{$victim\} \{\} \{\} \{$channel\} \{\}"
  696.     return
  697.   } else {
  698.     set vhost [lindex [split [getchanhost $victim $channel] "@"] 1]
  699.     puthelp "PRIVMSG $channel :$vote_config(code1)$victim $channel citizenship = $vote_config(code2)$victim addr: $vhost Votes: 1"
  700.   }
  701. }
  702.  
  703. proc impious:start_whois { from keyword text } {
  704.     global vote_config
  705.  
  706.     set nick [string tolower [lindex $text 1]]
  707.  
  708.     set vote_config(${nick}_whois_auth) 0
  709. }
  710.  
  711.  
  712. proc impious:not_identified { from keyword text } {
  713.     global vote_config
  714.  
  715.     set nick [string tolower [lindex $text 1]]
  716.  
  717.     # Check to see if they had a successful ident previously
  718.     if {[info exists vote_config(${nick}_whois_auth)]} {
  719.         if {$vote_config(${nick}_whois_auth) == 1} {
  720.             return
  721.         }
  722.     }
  723.  
  724.     set key $nick
  725.     append key "_auth"
  726.  
  727.     set vote_config($key) -1
  728.  
  729.     if {[info exists vote_config(${nick}_onverify)]} {
  730.       eval "$vote_config(${nick}_onverify)"
  731.         unset vote_config(${nick}_onverify)
  732.     }
  733.  
  734. }
  735.  
  736. # >> :calvino.freenode.net 330 poutine tswift tswift :is logged in as */
  737.  
  738. proc impious:freenode_identified_alias { from keyword text } {
  739.   global vote_config
  740.  
  741.   set nick [string tolower [lindex $text 1]]
  742.     set altnick [string tolower [lindex $text 2]]
  743.  
  744.     putlog "altnick is $altnick"
  745.  
  746.     # Check citizens list
  747.   if {[lsearch $vote_config(citizens) $altnick] != -1 || [lsearch $vote_config(citizens) $nick] != -1} {
  748.         set vote_config(${nick}_auth) 1
  749.         set vote_config(${nick}_whois_auth) 1
  750.  
  751.         if {[info exists vote_config(${nick}_onverify)]} {
  752.             eval "$vote_config(${nick}_onverify)"
  753.             unset vote_config(${nick}_onverify)
  754.         }
  755.            
  756.         return
  757.     }
  758. }
  759.  
  760. proc impious:verify_cit { from keyword text } {
  761.   global vote_config
  762.  
  763.   set nick [string tolower [lindex $text 1]]
  764.  
  765.   set vote_config(${nick}_auth) 1
  766.     set vote_config(${nick}_whois_auth) 1
  767.  
  768.     if {[info exists vote_config(${nick}_onverify)]} {
  769.       eval "$vote_config(${nick}_onverify)"
  770.         unset vote_config(${nick}_onverify)
  771.     }
  772. }
  773.  
  774. proc impious:recheck { $victim } {
  775.     global vote_config
  776.    
  777.     unset vote_config(${victim}_timer)
  778.  
  779.     set vote_config(${victim}_auth) 0
  780. }
  781.  
  782. proc check_cit { nick } {
  783.   global vote_config
  784.  
  785.     set victim [string tolower $nick]
  786.  
  787.     # But they
  788. #  if {[lsearch $vote_config(citizens) $victim] == -1} {
  789. #       if {[isvoice $victim $vote_config(channel)]} {
  790. #           putserv "MODE $vote_config(channel) -v $victim"
  791. #       }
  792. #
  793. #    return -1;
  794. #  }
  795. #
  796.   if {![info exists vote_config(${victim}_auth)] || $vote_config(${victim}_auth) == 0} {
  797.     # Cit check pending
  798.     puthelp "WHOIS $victim"
  799.     return 0;
  800.   } else {
  801.     # Definitely not a cit
  802.     if {$vote_config(${victim}_auth) == -1} {
  803.             if {![info exists vote_config(${victim}_timer)]} {
  804.                 timer 1 "set vote_config(${victim}_auth) 0"
  805.             }
  806.  
  807.       return -1
  808.     }
  809.  
  810.         if {[isvoice $victim $vote_config(channel)] == 0 && [isop $victim $vote_config(channel)] == 0} {
  811.                 puthelp "MODE $vote_config(channel) +v $victim"
  812.         }
  813.  
  814.     return 1;
  815.   }
  816. }
  817.  
  818. proc save_citizens { } {
  819.     global vote_config
  820.  
  821.     set fd [open $vote_config(citizens_file) "w"]
  822.  
  823.     foreach {loser} $vote_config(citizens) {
  824.         if {[string length $loser] > 0} {
  825.             puts $fd $loser
  826.         }
  827.     }
  828.  
  829.     flush $fd
  830.     close $fd
  831.  
  832.     #puthelp "PRIVMSG $vote_config(channel) :$vote_config(code1)Citizens' file saved"
  833. }
  834.  
  835. proc load_citizens { } {
  836.   global vote_config
  837.  
  838.   set fd [open $vote_config(citizens_file) "r"]
  839.   set vote_config(citizens) [split [read $fd] "\n"]
  840.   close $fd
  841.  
  842.     #puthelp "PRIVMSG $vote_config(channel) :$vote_config(code2)Citizens' file loaded"
  843. }
  844.  
  845. proc check_all_cits { } {
  846.     global vote_config
  847.  
  848.     if {![botonchan $vote_config(channel)]} {
  849.         return
  850.     }
  851.  
  852.     foreach {loser} $vote_config(citizens) {
  853.         if {[onchan $loser $vote_config(channel)]} {
  854.             check_cit $loser
  855.         }
  856.     }
  857.  
  858.     timer 1 check_all_cits
  859. }
  860.  
  861.  
  862. load_citizens
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement