Code: Select all
# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
#
# if you want to use this script on your chan, type in eggdrop console (via telnet or DCC chat)                 
# .chanset #channel_name +vote
# and later .save   
# ban after X yes votes
set vote_limit 5
# dir with users data
set users_dir "/home/borg/eggdrop"
# kick msg
set kick_msg "You have been Rule8'ed, Now eat [censored]"
###############################################################################################
bind pub -|- !rule8 vote_proc
setudef flag vote
if {![file exists $users_dir]} {                                                                             
   file mkdir $users_dir
}
proc put_host { user_host voter_host chan } {
   global users_dir
   set put_vote [open $users_dir/$chan/$user_host a]
   puts $put_vote $voter_host
   close $put_vote
}
proc get_hosts { user_host chan } {
   global users_dir
   set get_hosts [open $users_dir/$chan/$user_host r]
   set get_all [split [read $get_hosts] "\n"]
   close $get_hosts
   return $get_all
}
proc del_host { user_host voter_host chan } {
   global users_dir
   set old_votes [get_hosts $user_host $chan]
   set new_votes [open $users_dir/$chan/$user_host w]
   foreach host $old_votes {
      if {$host != ""} {
         if {$host != $voter_host} {
            puts $new_votes $host
         }
      }
   }
   close $new_votes
}
proc check_host { user_host voter_host chan } {
   set host_exists 0
   foreach host [get_hosts $user_host $chan] {
      if {$host != ""} {
         if {$host == $voter_host} {
            set host_exists 1
            break
         }
      }
   }
   return $host_exists
}
proc vote_proc { nick uhost hand chan arg } {
   global users_dir vote_limit botnick kick_msg
   set args [split $arg]
   set user [lindex $args 0]
   set yes_or_no [lindex $args 1]
   if {![channel get $chan vote]} {
      return                                                                                         
   } 
   if {[isbotnick $user]} {
      return
   }
   
   if {[file exists $users_dir/$chan/$uhost]} {
      return
   }
   if {![file exists $users_dir/$chan]} {
      file mkdir $users_dir/$chan
   }
   if {$user != ""} {
      if {($yes_or_no == "yes") || ($yes_or_no == "no")} {
         if {[onchan $user $chan]} {
            set user_host [getchanhost $user $chan]
            if {$yes_or_no == "yes"} {
               if {![file exists $users_dir/$chan/$user_host]} {
                  set touch_user [open $users_dir/$chan/$user_host w]
                  close $touch_user
               }
               set user_host_counter [llength [get_hosts $user_host $chan]]
               if {$user_host_counter < $vote_limit} {
                  if {[check_host $user_host [getchanhost $nick $chan] $chan] == 0} {
                     put_host $user_host [getchanhost $nick $chan] $chan
                     if {$user_host_counter == 0} {            
                        putquick "PRIVMSG $chan :$nick voted $user Yes. (1) Votes."
                     } {
                        putquick "PRIVMSG $chan :$nick voted $user Yes. ($user_host_counter) Votes."
                     }
                  } {
                     putquick "PRIVMSG $nick :sorry, you can't vote yes twice on the same user"
                  }
               } {
                  putquick "PRIVMSG $chan :$nick voted $user Yes. ($vote_limit) Votes
                  putquick "PRIVMSG X :ban $chan *!*$user_host $kick_msg
                  file delete $users_dir/$chan/$user_host
               }
            }
            if {$yes_or_no == "no"} {
               if {![file exists $users_dir/$chan/$user_host]} {
                  putquick "PRIVMSG $nick :sorry, no one voted on this user before"
               }
               set user_host_counter [llength [get_hosts $user_host $chan]]
               
               if {$user_host_counter > 0} {
                  set user_host_counter [expr $user_host_counter - 1]
               }
               if {$user_host_counter == 1} {
                  putquick "PRIVMSG $chan :$nick voted $user No. (0) Votes."
                  file delete $users_dir/$chan/$user_host
               } {
                  if {[check_host $user_host [getchanhost $nick $chan] $chan] == 1} {
                     del_host $user_host [getchanhost $nick $chan] $chan
                     putquick "PRIVMSG $chan :$nick voted $user No. ([expr $user_host_counter - 1]) Votes."
                  } {
                     putquick "PRIVMSG $nick :sorry, you didn't vote for this user"
                  }
               }
            }
         } {
            putquick "PRIVMSG $nick :wrong user name"
         }
      } {
         putquick "PRIVMSG $nick :use: !rule8 <user> <yes/no>"
      }
   } {
      putquick "PRIVMSG $nick :use: !rule8 <user> <yes/no>"
   }
}
I modified your script to that, to have X bans, the script is having a few errors.
<Hawk-> !vote Hawk- yes
<Goodbad> hey argentio
* keeperr (~keeper@189.107.5.147) has left #usa
<@Flubber> Hawk- voted Hawk- Yes. (1) Votes.
* @Enkeli faints
<@SmuGGler> fire fireee!!!!!!
<@iJump> evening
<@SmuGGler> fire in the holeeeeeeeeee!
<@SmuGGler> LOL
<Goodbad> hope there is in Argentino no carnivals
<Goodbad> like in Brazil
<@Enkeli> !vote Hawk- yes
<@Flubber> Enkeli voted Hawk- Yes. (2) Votes.
<@agent^> !vote Hawk- yes
<@Flubber> agent^ voted Hawk- Yes. (3) Votes.
<@agent^> !vote Cute^Kitten yes
<Goodbad> or yes?
<@Flubber> agent^ voted Cute^Kitten Yes. (1) Votes.
<@SmuGGler> !kote Hawk- No 

* moul7out (~ASAD-ATLA@41.248.227.123) has joined #usa
<@Enkeli> !vote Enkeli Yes
<@SmuGGler> what this vote for? :p
<@agent^> !vote Enkeli -yes
<Hawk-> lol
<Hawk-> this is for ban
<@SmuGGler> !vote Cute^Kitten Yes
<@SmuGGler> !vote Cute^Kitten Yes
<Hawk-> 

<@SmuGGler> 

~
<Hawk-> !vote Hawk- yes
<@SmuGGler> what ban? O_O
<@Enkeli> !vote Enkeli Yes
There it's only responding to the first votes to Hawk- nick, and wasn't responding to the voting of the other users, also when the limit of the voting reaches to 5, it shows this message in DCC  <(Flubber> [19:39:43] Tcl error [vote_proc]: extra characters after close-quote
<BallotBox> !vote Hawk- yes
<@Flubber> BallotBox voted Hawk- Yes. (1) Votes.
<Ompahpah> !vote hawk- yes
<@Flubber> Ompahpah voted hawk- Yes. (2) Votes.
<@Hawk-> !vote Hawk- yes
<@Hawk-> !vote Hawk- no
-> [luggage] CHAT
* Luggage (
XI@little.baby.can.you.say-owned.us) has joined #Islamabad
* X sets mode: +l 24
<Luggage> !vote Hawk- yes
<@Flubber> Luggage voted Hawk- Yes. (3) Votes.
-> [Area88] CHAT
* AREA88 (
usa@Hawk24.users.undernet.org) has joined #Islamabad
* X sets mode: +o AREA88
* AREA88 sets mode: +b *!*@190.166.24.*
<@AREA88> !vote Hawk- yes
* X sets mode: +l 26
<@AREA88> !vote Hawk- no
<Luggage> !vote Hawk- no
<@Flubber> Luggage voted Hawk- No. (2) Votes.
Luggage in there voted 2 times, 1 for yes and 1 for no, I want it so that a person can only do yes or no.
Goodness, that's a good one, I'll need a few modifications there, 1. It doesn't work on ops if some one tries to yes that vote on a person who is @ status on the channel, it should give reply on the user's private, You can't rule8 an operator, and the kick messages should be a random like set kick_msg "message 1" "message 2" I would want to have up to 10 random kick messages. please. Thanks for your help. really appreciated. [/quote]