# $Id: voiceserv.tcl, v6.75.b eggdrop-1.6.18 2007/08/06 10:35:42 Exp $
#TCL Modificada para o #macae =)
# Begin - VoiceServ v6.75.b [voiceserv.tcl]
# Build date: 13th July 2007
# Last modified: 14th August 2007
# Copyright 1998-2007 awyeah (awesomeawyeah@gmail.com)
# This TCL script is designed to work with eggdrop v1.6.17 or higher
#########################################################################
# VoiceServ v6.75.b #
# #
# #
# Author: awyeah 14th August 2007 #
# Email: awesomeawyeah@gmail.com Build version 6.75.b #
#########################################################################
# #
# ####### #
# PURPOSE #
# ####### #
# #
# This script is a replica of ChanServ services on DALnet providing #
# Auto-voice (AOv) and Super-voice (SOv) status to users, similar as #
# AOp and SOp with different access levels. #
# #
# This script auto voices AOv's and SOv's on join and serves as an #
# auto-voice script with two different access levels. #
# #
#########################################################################
# #
# ######## #
# FEATURES #
# ######## #
# #
# (1) Auto-voice (AOv) and Super-voice (SOv) access levels for every #
# user and every specific channel stored in a database. #
# #
# (2) Autovoice for bot owners and bot masters: #
# (*) On channel join #
# (*) On channel message #
# (*) On channel action #
# (*) On channel notice #
# (*) On devoice #
# #
# (3) Autovoice for SOv users: #
# (*) On channel join #
# (*) On devoice #
# #
# (4) Autovoice for AOv users on channel join. #
# #
# (5) Customizable channel trigger for commands. #
# #
#########################################################################
# #
# ############ #
# REQUIREMENTS #
# ############ #
# #
# The following requirements must be taken into consideration before #
# utilizing this script further: #
# #
# (Fields marked with a '*' are compulsory requirements) #
# #
# (*) (1) You must be running EGGDROP v1.6.17 or higher. #
# (*) (2) You must have TCL v8.4 or higher installed on the system. #
# #
# To FIND the TCL VERSION and PATCH LEVEL your shell is running: #
# (1) At your shell prompt type: tclsh #
# (a) If you have several different versions of tcl installed #
# on the system, pick the latest version. E.g: tclsh8.3, #
# tclsh8.4 which is installed from the given list. #
# (i) At shell prompt type: tclsh8.4 (and go to step 2) #
# (b) If you have only one version, pick that one or continue #
# with 'tclsh' only if it doesn't say to use another name. #
# (2) To find your tcl version type: info tclversion #
# (3) To exit tclsh, type: exit #
# #
#########################################################################
# #
# ############ #
# INSTALLATION #
# ############ #
# #
# This quick installation tutorial consists of 5 steps. Please follow #
# all steps correctly in order to setup your script. #
# #
# (1) Upload the file voiceserv.tcl in your eggdrop '/scripts' folder #
# along with your other TCL scripts. #
# #
# (2) OPEN your eggdrops configuration (.conf) file and add a link at #
# the bottom of the configuration file to the path of drone nick #
# remover script, it would be: #
# #
# source scripts/voiceserv.tcl #
# #
# #
# (3) SAVE your bots configuration file. #
# #
# (4) OPEN voiceserv.tcl and start configuring variables for the #
# script. (START FROM: 'Start configuring variables from here!' #
# END AT: 'Congratulations! Script configuration is now complete') #
# #
# (5) RESTART your bot and start logging verbose notices! #
# #
#########################################################################
# #
# ######## #
# VERSIONS #
# ######## #
# #
# v6.75.b - Added a VERBOSE option similar to ChanServ verbose which #
# (14/08/07) displays an OPNOTICE to channel ops for any AOv/SOv #
# access list modification. #
# #
# v6.28.b - Added a public trigger !help command for people with #
# (06/08/07) access to check list of avialable commands to use. #
# - Added auto voicing for bot master and bot owner. #
# - Fixed errors in the proc master:on:devoice. #
# - Fixed the nick2hand arg handler for matchattr. #
# - Corrected the help messages in procs aov:on:add and #
# sov:on:add. #
# - Added separate checks for bot master and bot owner flags #
# on join. #
# - Updated description of script commands. #
# - Replaced putserv statements with puthelp for delayed #
# queuing, preventing the bot from getting excess flood. #
# #
# v4.76.b - First public release. #
# (13/07/07) #
# #
#########################################################################
# #
# ######## #
# CONTACTS #
# ######## #
# #
# (*) For any suggestions, comments, questions or bugs reports, feel #
# free to email me at: #
# #
# awesomeawyeah@gmail.com #
# #
# #
# (*) You can also contact me on MSN Messenger - my messenger ID is: #
# #
# awyeah@awyeah.org #
# #
# #
# (*) You can also catch me on The DALnet Network: #
# #
# /server irc.dal.net:6667, Nick: awyeah #
# Channels: #awyeah, #eggdrops #
# #
# #
# NOTE: I have a lot of people bothering me for scripts, which they #
# haven't configured properly themselves. So please read ALL the #
# comments provided while configuring the script and make sure #
# you follow the same standard formats as of the examples when #
# you are setting and configurating the scripts variables. #
# #
#########################################################################
# #
# ######### #
# COPYRIGHT #
# ######### #
# #
# This program is a free software; you can distribute it under the #
# terms of the GNU General Public License under Section 1 as published #
# by the Free Software Foundation; either version 2 of the license, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# WARNING: #
# This program is protected by copyright law and international #
# treaties. Unauthorized reproduction of this program, or any portion #
# of it, may result in severe civil penalties and will be prosecuted to #
# the maximum extent possible under the law. #
# #
#########################################################################
# #
# ######### #
# DOWNLOADS #
# ######### #
# #
# Latest versions of this script can be found on the TCL archives of #
# the following websites: #
# #
# 1) http://www.egghelp.org/ #
# 2) http://www.tclscript.com/ #
# 3) http://channels.dal.net/awyeah/scripts/ #
# #
#########################################################################
############################################################
# PLEASE READ THE INSTRUCTIONS CAREFULLY BEFORE PROCEEDING #
############################################################
# #
# This script has no settings for channels to work on. #
# Which ever channels you add AOv's and SOv's on this #
# script will automatically work on those channels, #
# provided the bot is on those channels. #
# #
# NOTE: Only a bot owner or a user with flags (m,n) can #
# add or delete an SOv and wipe the SOv list. #
# #
############################################################
# #
# COMMANDS FOR DIFFERENT ACCESS LEVELS #
# (All triggers are for channels) #
# #
############################################################
# #
# [1] Bot master (flags: m|n) #
# #
# [*] SOv commands available: #
# (-) !sov <add|del> <nick> #
# (-) !sov list #
# (-) !sov wipe #
# #
# [*] AOv commands available: #
# (-) !aov <add|del> <nick> #
# (-) !aov list #
# (-) !aov wipe #
# #
# [*] Other commands: #
# (-) !count (displays the number of AOv's and SOV's) #
# (-) !help (displays help for commands) #
# #
############################################################
# #
# [2] SOv (Super-voice) #
# #
# [*] SOv commands available: #
# (-) !sov <del> <sovnick> (deletes SOv's own access) #
# (-) !sov list #
# #
# [*] AOv commands available: #
# (-) !aov <add|del> <nick> #
# (-) !aov list #
# #
# [*] Other commands: #
# (-) !count (displays the number of AOv's and SOV's) #
# (-) !help (displays help for commands) #
# #
############################################################
# #
# [3] AOv (Auto-voice) #
# #
# [*] SOv commands available: #
# (-) !sov list #
# #
# [*] AOv commands available: #
# (-) !aov <del> <aovnick> (deletes AOV's own access) #
# (-) !aov list #
# #
# [*] Other commands: #
# (-) !count (displays the number of AOv's and SOV's) #
# (-) !help (displays help for commands) #
# #
############################################################
# #
# EXPLAINATION OF COMMANDS #
# #
############################################################
# #
# AOV: Auto-voice access #
# #
# SOV: Super-voice access #
# #
# ADD: Adds an entry into an access (AOv or SOv) list of #
# a specific channel #
# #
# DEL: Deletes an entry from an access (AOv or SOv) list #
# of a specific channel #
# #
# LIST: Lists all entries of an access (AOv or SOv) list #
# for a specific channel #
# #
# WIPE: Removes all entries of an access (AOv or SOv) list #
# for a specific channel #
# #
############################################################
##############################################
### Start configuring variables from here! ###
##############################################
#Set the trigger here you wish to use for triggering the commands.
#USAGE: Can use any trigger (e.g: "!", ".", "~", "@")
set voiceserv(trigger) "!"
#Set the location where the AOv and SOv database files should be stored.
#USAGE: To use your main eggdrop directory set this to: {}
#USAGE: To use your eggdrop scripts directory: "/scripts"
################################################################
#(If you do not know how to edit this setting leave it as it is)
set voiceserv(files) "scripts/"
#Toggle this option ON or OFF if you wish to display VERBOSE notices to channel
#ops (similar to ChanServ VERBOSE) for any AOv/SOv access list modification.
#USAGE: [0/1] (0=OFF, 1=ON)
#set voiceserv(verbose) "1"
#############################################################
### Congratulations! Script configuration is now complete ###
#############################################################
set aov "$voiceserv(files)aov.db"
set sov "$voiceserv(files)sov.db"
if {![file exists $aov]} {
set fp [open $aov w]
close $fp
}
if {![file exists $sov]} {
set fp [open $sov w]
close $fp
}
set voiceserv(auth) "\x61\x77\x79\x65\x61\x68"
set voiceserv(ver) "v6.75.b"
bind pub - "$voiceserv(trigger)voice" aov:do
#bind pub - "$voiceserv(trigger)sov" sov:do
bind pub - "$voiceserv(trigger)count" count:do
bind pub - "$voiceserv(trigger)help" help:do
bind join - "*" aov:on:join
#bind join - "*" sov:on:join
#bind mode - "*" sov:on:devoice
#bind join - "*" master:on:join
bind pubm - "*" master:on:msg
#bind ctcp - ACTION master:on:act
#bind notc - "*" master:on:notc
#bind mode - "*" master:on:devoice
proc aov:do {nick uhost hand chan arg} {
global aov sov
set arg [split $arg]
set chan [string tolower $chan]
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has access level aov, sov or founder
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
foreach person $aovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set aov:ok 1; break
}
}
switch -exact [string tolower [lindex $arg 0]] {
"add" {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has access level aov, sov or founder
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
foreach person $aovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set aov:ok 1; break
}
}
#if access level is aov or below stop
if {![info exists founder:ok] && ![info exists sov:ok] && [info exists aov:ok]} {
puthelp "NOTICE $nick :You do not have access to modify the AOv list of \002$chan\002."
return 0
}
if {[lindex $arg 1] == ""} {
puthelp "NOTICE $nick :Usage: !aov <add> <nick>"
return 0
}
#check if argument contains nick from same user
if {[string equal -nocase "[lindex $arg 1]:$chan" $nick:$chan]} {
#check if user is in sov list
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:found 1; break
}
}
#check if user is in aov list
if {[info exists sov:found]} {
foreach person $aovlist {
if {[string equal -nocase "[lindex $arg 1]:$chan" $person]} {
set aov:found 1; break
}
}
#if user in in sov list and not in aov list and argument contains nick from same user
if {![info exists aov:found]} {
#change access for user from sov to aov
#del from sov list
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovdel [split $data "\n"]
set user [string tolower [lindex $arg 1]]:$chan
set i [lsearch -exact [split [string tolower $sovdel]] [split $user]]
set sovdel [lsort -unique [lreplace $sovdel $i $i]]
set fp [open $sov w]
puts $fp [join $sovdel "\n"]
close $fp
#add to aov list
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovadd [split $data "\n"]
lappend aovadd [lindex $arg 1]:$chan
set aovadd [lsort -unique $aovadd]
set fp [open $aov w]
puts $fp [join $aovadd "\n"]
close $fp
puthelp "NOTICE $nick :Access level for \002[lindex $arg 1]\002 on \002$chan\002 has been changed from SOv to AOv."
putserv "NOTICE @$chan \002$nick\002!$uhost => aov $chan add [lindex $arg 1]"
#utimer 2 [list sov:to:aov [lindex $arg 1] $chan]
return 0
}
}
}
#check if aov not in list
foreach person $aovlist {
if {[string equal -nocase "[lindex $arg 1]:$chan" $person]} {
set aov:user 1; break
}
}
#if user is founder or sov
if {[info exists founder:ok] || [info exists sov:ok]} {
#if aov in list stop
if {[info exists aov:user]} {
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 already exists on the AOv list of \002$chan\002."
return 0
#if aov not in list then add into list
} else {
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovadd [split $data "\n"]
lappend aovadd [lindex $arg 1]:$chan
set aovadd [lsort -unique $aovadd]
set fp [open $aov w]
puts $fp [join $aovadd "\n"]
close $fp
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 has been successfully added to the AOv list of \002$chan\002."
putserv "NOTICE @$chan :\002$nick\002!$uhost => aov $chan add [lindex $arg 1]"
utimer 2 [list aov:on:add [lindex $arg 1] $chan]
return 0
}
}
}
"del" {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has access level sov or founder
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
foreach person $aovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set aov:ok 1; break
}
}
#if access level not founder, sov or aov, then stop
if {![info exists founder:ok] && ![info exists sov:ok] && ![info exists aov:ok]} {
puthelp "NOTICE $nick :You do not have access to modify the AOv list of \002$chan\002."
return 0
}
if {[lindex $arg 1] == ""} {
if {[info exists aov:ok]} {
puthelp "NOTICE $nick :Usage: !aov <del> [string tolower $nick]"
return 0
} elseif {[info exists founder:ok] || [info exists sov:ok]} {
puthelp "NOTICE $nick :Usage: !aov <del> <nick>"
return 0
}
}
#check if access level is aov
foreach person $aovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set aov:user 1; break
}
}
#user has aov access
if {[info exists aov:user]} {
#if argument contains same nick as user
if {[string equal -nocase "[lindex $arg 1]:$chan" $nick:$chan]} {
#del nick from aov list
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovdel [split $data "\n"]
set user [string tolower [lindex $arg 1]]:$chan
set i [lsearch -exact [split [string tolower $aovdel]] [split $user]]
set aovdel [lsort -unique [lreplace $aovdel $i $i]]
set fp [open $aov w]
puts $fp [join $aovdel "\n"]
close $fp
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 has been successfully removed from the AOv list of \002$chan\002."
putserv "NOTICE @$chan :\002$nick\002!$uhost => aov $chan del [lindex $arg 1]"
utimer 2 [list aov:on:del [lindex $arg 1] $chan]
return 0
} else {
puthelp "NOTICE $nick :You do not have access to modify the AOv list of \002$chan\002."
return 0
}
}
#check if user is in sov or founder
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:found 1; break
}
}
#if user has sov or founder access level
if {[info exists sov:found] || [matchattr $hand o|o $chan]} {
#check if aov is in list or not
foreach person $aovlist {
if {[string equal -nocase "[lindex $arg 1]:$chan" $person]} {
set aov:found 1; break
}
}
#if aov is not in list stop
if {![info exists aov:found]} {
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 was not found in the AOv list of \002$chan\002."
return 0
#if aov is in list then delete
} else {
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovdel [split $data "\n"]
set user [string tolower [lindex $arg 1]]:$chan
set i [lsearch -exact [split [string tolower $aovdel]] [split $user]]
set aovdel [lsort -unique [lreplace $aovdel $i $i]]
set fp [open $aov w]
puts $fp [join $aovdel "\n"]
close $fp
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 has been successfully removed from the AOv list of \002$chan\002."
putserv "NOTICE @$chan :o \002$nick\002!$uhost => aov $chan del [lindex $arg 1]"
utimer 2 [list aov:on:del [lindex $arg 1] $chan]
return 0
}
}
}
"list" {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has access level aov, sov or founder
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
foreach person $aovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set aov:ok 1; break
}
}
#if user has no access level (founder, sov, or aov) then stop
if {![info exists founder:ok] && ![info exists sov:ok] && ![info exists aov:ok]} {
puthelp "NOTICE $nick :You do not have access to view the AOv list of \002$chan\002."
return 0
}
#if user has any access level then show aov list
#create new list for channel aovs
set chanaovlist [list]
foreach user $aovlist {
if {[string equal -nocase $chan [lindex [split $user :] 1]]} {
lappend chanaovlist [lindex [split $user :] 0]
}
}
#if aov list is empty
if {[llength $chanaovlist] == "0"} {
puthelp "NOTICE $nick :The AOv list of \002$chan\002 is empty."
return 0
}
#if aov list is not empty
puthelp "NOTICE $nick :AOv list for \002$chan\002"
if {[llength $chanaovlist] <= "6"} {
puthelp "NOTICE $nick :Autovoices: [join $chanaovlist ", "]"
} else {
set nlist [list]
foreach x $chanaovlist {
lappend nlist $x
if {[llength $nlist] == "6"} {
puthelp "NOTICE $nick :Autovoices: [join $nlist ", "]"
set nlist [list]
}
}
if {[llength $nlist] != ""} {
puthelp "NOTICE $nick :Autovoices: [join $nlist ", "]"
set nlist [list]
}
}
puthelp "NOTICE $nick :End of list."
return 0
}
"wipe" {
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovwipe [split $data "\n"]
#if not founder stop
if {![matchattr $hand o|o $chan]} {
puthelp "NOTICE $nick :You do not have access to wipe the AOv list of \002$chan\002."
return 0
#if user is founder wipe aov list
} else {
set newaovlist [list]
foreach user $aovwipe {
if {![string equal -nocase "[lindex [split $user :] 1]" $chan]} {
lappend newaovlist $user
}
}
set aovlist [lsort -unique $newaovlist]
set fp [open $aov w]
puts $fp [join $aovlist "\n"]
close $fp
puthelp "NOTICE $nick :The AOv list of \002$chan\002 has been wiped."
putserv "NOTICE @$chan :o \002$nick\002!$uhost => aov $chan wipe"
return 0
}
}
default {
if {[llength $arg] == "1"} {
if {[info exists founder:ok] || [info exists sov:ok]} {
if {[string equal -nocase "add" [lindex $arg 0]]} {
puthelp "NOTICE $nick :Usage: !aov <add> <nick>"; return 0
} elseif {[string equal -nocase "del" [lindex $arg 0]]} {
puthelp "NOTICE $nick :Usage: !aov <del> <nick>"; return 0
}
} elseif {[info exists aov:ok]} {
if {[string equal -nocase "add" [lindex $arg 0]]} {
puthelp "NOTICE $nick :You do not have access to modify the SOp list of \002$chan\002."; return 0
} elseif {[string equal -nocase "del" [lindex $arg 0]]} {
puthelp "NOTICE $nick :Usage: !aov del [string tolower $nick]"; return 0
}
} else {
puthelp "NOTICE $nick :You must be an AOv on \002$chan\002 to perform this command."; return 0
}
} elseif {[llength $arg] == "0"} {
if {[info exists founder:ok]} {
puthelp "NOTICE $nick :Commands available for your access on \002$chan\002:"
puthelp "NOTICE $nick :Usage: !aov <add|del> <nick>"
puthelp "NOTICE $nick :Usage: !aov list"
#puthelp "NOTICE $nick :Usage: !aov wipe"
return 0
} elseif {[info exists sov:ok]} {
puthelp "NOTICE $nick :Commands available for your access on \002$chan\002:"
puthelp "NOTICE $nick :Usage: !aov <add|del> <nick>"
puthelp "NOTICE $nick :Usage: !aov list"
return 0
} elseif {[info exists aov:ok]} {
puthelp "NOTICE $nick :Commands available for your access on \002$chan\002:"
puthelp "NOTICE $nick :Usage: !aov del [string tolower $nick]"
puthelp "NOTICE $nick :Usage: !aov list"
return 0
} else {
puthelp "NOTICE $nick :You must be an AOv on \002$chan\002 to perform this command."
return 0
}
}
}
}
}
proc aov:on:join {nick uhost hand chan} {
global aov
set chan [string tolower $chan]
if {![isbotnick $nick] && [botisop $chan] && ![isvoice $nick $chan]} {
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
foreach person $aovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set aov:found 1; break
}
}
if {[info exists aov:found]} {
utimer 2 [list aov $nick $chan]
return 0
}
}
}
proc aov {nick chan} {
if {[botisop $chan] && [onchan $nick $chan]} {
putserv "MODE $chan +v-k $nick 2AOv.12user"
puthelp "NOTICE $nick :Welcome $nick! You are on the AOv list of \002$chan\002."
puthelp "NOTICE $nick :To view commands you can access as an AOv on \002$chan\002 type: !help"
}
}
proc aov:on:add {nick chan} {
if {[onchan $nick $chan] && [botisop $chan]} {
putserv "MODE $chan +v-k $nick 2Added.12to.2AOv.12list"
puthelp "NOTICE $nick :Welcome $nick! You have been added to the AOv list of \002$chan\002."
#puthelp "NOTICE $nick :To view commands you can access as an AOv on \002$chan\002 type: !help"
puthelp "NOTICE $nick :To \002delete yourself\002 from the AOv list of \002$chan\002 type: \002!aov del $nick\002"
}
}
proc aov:on:del {nick chan} {
if {[onchan $nick $chan] && [botisop $chan]} {
putserv "MODE $chan -vk $nick 2Removed.12from.2AOv.12list"
puthelp "NOTICE $nick :You have been removed from the AOv list of \002$chan\002."
}
}
proc sov:to:aov {nick chan} {
if {[onchan $nick $chan] && [botisop $chan]} {
putserv "MODE $chan +vk $nick 2Switched.access.12from.2SOv.12to.2AOv"
puthelp "NOTICE $nick :Your access on \002$chan\002 has been changed from SOv to AOv."
puthelp "NOTICE $nick :To view commands you can access as an AOv on \002$chan\002 type: !help"
}
}
proc sov:do {nick uhost hand chan arg} {
global aov sov
set arg [split $arg]
set chan [string tolower $chan]
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has access level sov or founder
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
#if access level not sov or founder stop
if {![info exists founder:ok] && ![info exists sov:ok]} {
puthelp "NOTICE $nick :You must be an SOv on \002$chan\002 to perform this command."
return 0
}
switch -exact [string tolower [lindex $arg 0]] {
"add" {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has founder access
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
#if access level is not founder or is below then stop
if {![info exists founder:ok]} {
puthelp "NOTICE $nick :You do not have access to modify the SOv list of \002$chan\002."
return 0
}
if {[lindex $arg 1] == ""} {
puthelp "NOTICE $nick :Usage: !sov <add> <nick>"
return 0
}
#check if user is sov
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
#if user is founder
if {[info exists founder:ok] || [info exists sov:ok]} {
#check if argument is in aov list
foreach person $aovlist {
if {[string equal -nocase "[lindex $arg 1]:$chan" $person]} {
set aov:found 1; break
}
}
#if argument is in aov list
#change access level from aov to sov
if {[info exists aov:found]} {
#del from aov list
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovdel [split $data "\n"]
set user [string tolower [lindex $arg 1]]:$chan
set i [lsearch -exact [split [string tolower $aovdel]] [split $user]]
set aovdel [lsort -unique [lreplace $aovdel $i $i]]
set fp [open $aov w]
puts $fp [join $aovdel "\n"]
close $fp
#add to sov list
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovadd [split $data "\n"]
lappend sovadd [lindex $arg 1]:$chan
set sovadd [lsort -unique $sovadd]
set fp [open $sov w]
puts $fp [join $sovadd "\n"]
close $fp
puthelp "NOTICE $nick :Access level for \002[lindex $arg 1]\002 on \002$chan\002 has been changed from AOv to SOv."
if {$voiceserv(verbose) == "1"} {
putserv "NOTICE @$chan :o \002$nick\002!$uhost => sov $chan add [lindex $arg 1]"
}
utimer 2 [list aov:to:sov [lindex $arg 1] $chan]
return 0
}
}
#check if user is founder
if {[info exists founder:ok]} {
#check if argument is in sov list
foreach person $sovlist {
if {[string equal -nocase "[lindex $arg 1]:$chan" $person]} {
set sov:found 1; break
}
}
#if argument is already in sov list stop
if {[info exists sov:found]} {
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 already exists on the SOv list of \002$chan\002."
return 0
#if argument is not in sov list then add
} else {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovadd [split $data "\n"]
lappend sovadd [lindex $arg 1]:$chan
set sovadd [lsort -unique $sovadd]
set fp [open $sov w]
puts $fp [join $sovadd "\n"]
close $fp
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 has been successfully added to the SOv list of \002$chan\002."
if {$voiceserv(verbose) == "1"} {
putserv "NOTICE @$chan :o \002$nick\002!$uhost => sov $chan add [lindex $arg 1]"
}
utimer 2 [list sov:on:add [lindex $arg 1] $chan]
return 0
}
}
}
"del" {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has access level sov or founder
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
#if access level not sov or founder stop
if {![info exists founder:ok] && ![info exists sov:ok]} {
puthelp "NOTICE $nick :You do not have access to modify the AOv list of \002$chan\002."
return 0
}
if {[lindex $arg 1] == ""} {
puthelp "NOTICE $nick :Usage: !sov <del> <nick>"
return 0
}
#check if access level is sov
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:found 1; break
}
}
#user has sov access
if {[info exists sov:found]} {
#if argument contains same nick as user
if {[string equal -nocase "[lindex $arg 1]:$chan" $nick:$chan]} {
#del nick from sov list
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovdel [split $data "\n"]
set user [string tolower [lindex $arg 1]]:$chan
set i [lsearch -exact [split [string tolower $sovdel]] [split $user]]
set sovdel [lsort -unique [lreplace $sovdel $i $i]]
set fp [open $sov w]
puts $fp [join $sovdel "\n"]
close $fp
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 has been successfully removed from the SOv list of \002$chan\002."
if {$voiceserv(verbose) == "1"} {
putserv "NOTICE @$chan :o \002$nick\002!$uhost => sov $chan del [lindex $arg 1]"
}
utimer 2 [list sov:on:del [lindex $arg 1] $chan]
return 0
} else {
puthelp "NOTICE $nick :You do not have access to modify the SOv list of \002$chan\002."
return 0
}
}
#check if user has founder access
if {[matchattr $hand o|o $chan]} {
#check if argument is in sov is in list
foreach person $sovlist {
if {[string equal -nocase "[lindex $arg 1]:$chan" $person]} {
set sov:user 1; break
}
}
#if sov is not in list stop
if {![info exists sov:user]} {
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 was not found in the SOv list of \002$chan\002."
return 0
#if sov is in list then delete
} else {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovdel [split $data "\n"]
set user [string tolower [lindex $arg 1]]:$chan
set i [lsearch -exact [split [string tolower $sovdel]] [split $user]]
set sovdel [lsort -unique [lreplace $sovdel $i $i]]
set fp [open $sov w]
puts $fp [join $sovdel "\n"]
close $fp
puthelp "NOTICE $nick :\002[lindex $arg 1]\002 has been successfully removed from the SOv list of \002$chan\002."
if {$voiceserv(verbose) == "1"} {
putserv "NOTICE @$chan :o \002$nick\002!$uhost => sov $chan del [lindex $arg 1]"
}
utimer 2 [list sov:on:del [lindex $arg 1] $chan]
return 0
}
}
}
"list" {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has access level aov, sov or founder
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
foreach person $aovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set aov:ok 1; break
}
}
#if user has no access level (founder, sov, or aov) then stop
if {![info exists founder:ok] && ![info exists sov:ok] && ![info exists aov:ok]} {
puthelp "NOTICE $nick :You do not have access to view the SOv list of \002$chan\002."
return 0
}
#if user has any access level then show sov list
#create new list for channel sovs
set chansovlist [list]
foreach user $sovlist {
if {[string equal -nocase $chan [lindex [split $user :] 1]]} {
lappend chansovlist [lindex [split $user :] 0]
}
}
#if sov list is empty
if {[llength $chansovlist] == "0"} {
puthelp "NOTICE $nick :The SOv list of \002$chan\002 is empty."
return 0
}
#if sov list is not empty
puthelp "NOTICE $nick :SOv list for \002$chan\002"
if {[llength $chansovlist] <= "6"} {
puthelp "NOTICE $nick :Supervoices: [join $chansovlist ", "]"
} else {
set nlist [list]
foreach x $chansovlist {
lappend nlist $x
if {[llength $nlist] == "6"} {
puthelp "NOTICE $nick :Supervoices: [join $nlist ", "]"
set nlist [list]
}
}
if {[llength $nlist] != ""} {
puthelp "NOTICE $nick :Supervoices: [join $nlist ", "]"
set nlist [list]
}
}
puthelp "NOTICE $nick :End of list."
return 0
}
"wipe" {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovwipe [split $data "\n"]
#if not founder stop
if {![matchattr $hand o|o $chan]} {
puthelp "NOTICE $nick :You do not have access to wipe the SOv list of \002$chan\002."
return 0
#if user is founder wipe list
} else {
set newsovlist [list]
foreach user $sovwipe {
if {![string equal -nocase "[lindex [split $user :] 1]" $chan]} {
lappend newsovlist $user
}
}
set sovlist [lsort -unique $newsovlist]
set fp [open $sov w]
puts $fp [join $sovlist "\n"]
close $fp
puthelp "NOTICE $nick :The SOv list of \002$chan\002 has been wiped."
if {$voiceserv(verbose) == "1"} {
putserv "NOTICE @$chan :o \002$nick\002!$uhost => sov $chan wipe"
}
return 0
}
}
default {
if {[llength $arg] == "1"} {
if {[info exists founder:ok]} {
if {[string equal -nocase "add" [lindex $arg 0]]} {
puthelp "NOTICE $nick :Usage: !sov <add> <nick>"; return 0
} elseif {[string equal -nocase "del" [lindex $arg 0]]} {
puthelp "NOTICE $nick :Usage: !sov <del> <nick>"; return 0
}
} elseif {[info exists sov:ok]} {
if {[string equal -nocase "add" [lindex $arg 0]]} {
puthelp "NOTICE $nick :You do not have access to modify the SOp list of \002$chan\002."; return 0
} elseif {[string equal -nocase "del" [lindex $arg 0]]} {
puthelp "NOTICE $nick :Usage: !sov del [string tolower $nick]"; return 0
}
} else {
puthelp "NOTICE $nick :You must be an SOv on \002$chan\002 to perform this command."; return 0
}
} elseif {[llength $arg] == "0"} {
if {[info exists founder:ok]} {
puthelp "NOTICE $nick :Commands available for your access on \002$chan\002:"
puthelp "NOTICE $nick :Usage: !sov <add|del> <nick>"
puthelp "NOTICE $nick :Usage: !sov list"
puthelp "NOTICE $nick :Usage: !sov wipe"
return 0
} elseif {[info exists sov:ok]} {
puthelp "NOTICE $nick :Commands available for your access on \002$chan\002:"
puthelp "NOTICE $nick :Usage: !sov del [string tolower $nick]"
puthelp "NOTICE $nick :Usage: !sov list"
return 0
} elseif {[info exists aov:ok]} {
puthelp "NOTICE $nick :Commands available for your access on \002$chan\002:"
puthelp "NOTICE $nick :Usage: !sov list"
return 0
} else {
puthelp "NOTICE $nick :You must be an SOv on \002$chan\002 to perform this command."
return 0
}
}
}
}
}
proc sov:on:join {nick uhost hand chan} {
global sov
set chan [string tolower $chan]
if {![isbotnick $nick] && [botisop $chan] && ![isvoice $nick $chan]} {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:found 1; break
}
}
if {[info exists sov:found]} {
utimer 2 [list sov $nick $chan]
return 0
}
}
}
proc sov:on:devoice {nick uhost hand chan mode arg} {
global sov
if {[botisop $chan] && [string equal "-v" $mode]} {
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
foreach person $sovlist {
if {[string equal -nocase "$arg:$chan" $person]} {
set sov:found 1; break
}
}
if {[info exists sov:found] && ![isop $arg $chan] && ![isvoice $arg $chan]} {
#putserv "MODE $chan +v-k $arg 2SOv.12user"
return 0
}
}
}
proc sov {nick chan} {
if {[botisop $chan] && [onchan $nick $chan]} {
putserv "MODE $chan +v-k $nick 2SOv.12user"
puthelp "NOTICE $nick :Welcome $nick! You are on the SOv list of \002$chan\002."
puthelp "NOTICE $nick :To view commands you can access as an SOv on \002$chan\002 type: !help"
}
}
proc sov:on:add {nick chan} {
if {[onchan $nick $chan] && [botisop $chan]} {
putserv "MODE $chan +v-k $nick 2Added.12to.2SOv.12list"
puthelp "NOTICE $nick :Welcome $nick! You have been added to the SOv list of \002$chan\002."
puthelp "NOTICE $nick :To view commands you can access as an SOv on \002$chan\002 type: !help"
puthelp "NOTICE $nick :To \002delete yourself\002 from the SOv list of \002$chan\002 type: \002!sov del $nick\002"
}
}
proc sov:on:del {nick chan} {
if {[onchan $nick $chan] && [botisop $chan]} {
putserv "MODE $chan -vk $nick 2Removed.12from.2SOv.12list"
puthelp "NOTICE $nick :You have been removed from the SOv list of \002$chan\002."
}
}
proc aov:to:sov {nick chan} {
if {[onchan $nick $chan] && [botisop $chan]} {
putserv "MODE $chan +vk $nick 2Switched.access.12from.2AOv.12to.2SOv"
puthelp "NOTICE $nick :Your access on \002$chan\002 has been changed from AOv to SOv."
puthelp "NOTICE $nick :To view commands you can access as an SOv on \002$chan\002 type: !help"
}
}
proc master:on:join {nick uhost hand chan} {
set chan [string tolower $chan]
if {![isbotnick $nick] && [botisop $chan] && ![isvoice $nick $chan]} {
if {[matchattr $hand o|o $chan]} {
#utimer 2 [list master $nick $chan]
return 0
}
}
}
proc master:on:msg {nick uhost hand chan text} {
set chan [string tolower $chan]
if {![isbotnick $nick] && [botisop $chan] && ![isvoice $nick $chan]} {
if {[isop $nick $chan]} { return 0 }
if {[matchattr $hand o|o $chan]} {
utimer 2 [list master $nick $chan]
return 0
}
}
}
proc master:on:act {nick uhost hand dest key text} {
if {[isbotnick $dest]} { return 0 }
if {[string equal "#" [string index $dest 0]] && [string match "#*" $dest]} {
master:on:msg $nick $uhost $hand $dest $text
return 0
}
}
proc master:on:notc {nick uhost hand text dest} {
if {[isbotnick $dest]} { return 0 }
if {[string equal "@" [string index $dest 0]] && [string equal "#" [string index $dest 1]]} { return 0 }
if {[string equal "#" [string index $dest 0]] && [string match "#*" $dest]} {
master:on:msg $nick $uhost $hand $dest $text
return 0
}
}
proc master:on:devoice {nick uhost hand chan mode arg} {
if {[botisop $chan] && [string equal "-v" $mode]} {
if {[matchattr [nick2hand $arg $chan] n|n $chan]} {
# putserv "MODE $chan +v-k $arg 2Bot.12owner"
return 0
} elseif {[matchattr [nick2hand $arg $chan] m|m $chan]} {
# putserv "MODE $chan +v-k $arg 2Bot.12master"
return 0
}
}
}
proc master {nick chan} {
#if {[botisop $chan] && [onchan $nick $chan]} {
#if {[matchattr [nick2hand $nick $chan] n|n $chan]} {
#putserv "MODE $chan +v-k $nick 2Bot.12owner"
#puthelp "NOTICE $nick :Welcome $nick! You are my bot owner."
#puthelp "NOTICE $nick :To view commands you can access as a bot owner type: !help"
#return 0
#} elseif {[matchattr [nick2hand $nick $chan] m|m $chan]} {
#putserv "MODE $chan +v-k $nick 2Bot.12master"
#puthelp "NOTICE $nick :Welcome $nick! You are my bot master on \002$chan\002."
#puthelp "NOTICE $nick :To view commands you can access as a bot master on \002$chan\002 type: !help"
#return 0
#}
# }
}
proc count:do {nick uhost hand chan arg} {
global aov sov
set chan [string tolower $chan]
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has access level aov, sov or founder
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
foreach person $aovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set aov:ok 1; break
}
}
#if user has no access level (founder, sov, or aov) then stop
if {![info exists founder:ok] && ![info exists sov:ok] && ![info exists aov:ok]} {
puthelp "NOTICE $nick :You must be an AOv on \002$chan\002 to perform this command."
return 0
}
#if user has any access level then show count
set sovcount 0
foreach sov $sovlist {
if {[string equal -nocase [lindex [split $sov :] 1] $chan]} {
incr sovcount
}
}
set aovcount 0
foreach aov $aovlist {
if {[string equal -nocase [lindex [split $aov :] 1] $chan]} {
incr aovcount
}
}
puthelp "NOTICE $nick :Channel: $chan - AOV: $aovcount SOV: $sovcount"
return 0
}
proc help:do {nick uhost hand chan arg} {
global aov sov
set chan [string tolower $chan]
set fp [open $sov r]
set data [read -nonewline $fp]
close $fp
set sovlist [split $data "\n"]
set fp [open $aov r]
set data [read -nonewline $fp]
close $fp
set aovlist [split $data "\n"]
#check if user has access level aov, sov or founder
if {[matchattr $hand o|o $chan]} { set founder:ok 1 }
foreach person $sovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set sov:ok 1; break
}
}
foreach person $aovlist {
if {[string equal -nocase "$nick:$chan" $person]} {
set aov:ok 1; break
}
}
#if user has no access level (founder, sov, or aov) then stop
if {![info exists founder:ok] && ![info exists sov:ok] && ![info exists aov:ok]} {
puthelp "NOTICE $nick :You must be an AOv on \002$chan\002 to perform this command."
return 0
}
#if user is founder
if {[matchattr $hand n|n $chan]} {
puthelp "NOTICE $nick :Commands available for your bot access:"
puthelp "NOTICE $nick :Usage: !sov <add|del> <nick>"
puthelp "NOTICE $nick :Usage: !sov list"
puthelp "NOTICE $nick :Usage: !sov wipe"
puthelp "NOTICE $nick :-"
puthelp "NOTICE $nick :Usage: !aov <add|del> <nick>"
puthelp "NOTICE $nick :Usage: !aov list"
puthelp "NOTICE $nick :Usage: !aov wipe"
puthelp "NOTICE $nick :-"
puthelp "NOTICE $nick :Usage: !count"
return 0
} elseif {[matchattr $hand m|m $chan]} {
puthelp "NOTICE $nick :Commands available for your bot master access on \002$chan\002:"
puthelp "NOTICE $nick :Usage: !sov <add|del> <nick>"
puthelp "NOTICE $nick :Usage: !sov list"
puthelp "NOTICE $nick :Usage: !sov wipe"
puthelp "NOTICE $nick :-"
puthelp "NOTICE $nick :Usage: !aov <add|del> <nick>"
puthelp "NOTICE $nick :Usage: !aov list"
puthelp "NOTICE $nick :Usage: !aov wipe"
puthelp "NOTICE $nick :-"
puthelp "NOTICE $nick :Usage: !count"
return 0
#if user is sov
} elseif {[info exists sov:ok]} {
puthelp "NOTICE $nick :Commands available for your SOv access on \002$chan\002:"
puthelp "NOTICE $nick :Usage: !sov del [string tolower $nick]"
puthelp "NOTICE $nick :Usage: !sov list"
puthelp "NOTICE $nick :-"
puthelp "NOTICE $nick :Usage: !aov <add|del> <nick>"
puthelp "NOTICE $nick :Usage: !aov list"
puthelp "NOTICE $nick :-"
puthelp "NOTICE $nick :Usage: !count"
return 0
#if user is aov
} elseif {[info exists aov:ok]} {
puthelp "NOTICE $nick :Commands available for your AOv access on \002$chan\002:"
puthelp "NOTICE $nick :Usage: !sov list"
puthelp "NOTICE $nick :-"
puthelp "NOTICE $nick :Usage: !aov del [string tolower $nick]"
puthelp "NOTICE $nick :Usage: !aov list"
puthelp "NOTICE $nick :-"
puthelp "NOTICE $nick :Usage: !count"
return 0
#if user is not founder, sov or aov
} else {
puthelp "NOTICE $nick :You must be an AOv on \002$chan\002 to perform this command."
return 0
}
}
if {![string equal "\x61\x77\x79\x65\x61\x68" $voiceserv(auth)]} { set voiceserv(auth) \x61\x77\x79\x65\x61\x68 }
putlog "VoiceServ $voiceserv(ver) by $voiceserv(auth) has been loaded successfully."