The source: http://www.egghelp.org/cgi-bin/tcl_arch ... ad&id=1107
Thank you
- Code: Select all
# Author : Infernius
# Contact-
# IRC : #infernius on Quakenet
# Email : infernius@gmail.com
# More scripts: http://v1per.servicez.org
set chanlev(author) "infernius"
set chanlev(version) "3.0"
# Description
# This script will handle your channels' user flags.
# You can add, remove and view flags.
# Usage
# $chanlev - Returns the chanlev stats -
# <bot> Chanlev stats for #infernius
# <bot> Total: 9 (max 30 users) (owner: 2, master: 5, op: 2, voice: 0).
# $chanlev <user|#authname> - Will return that person's flags for that channel.
# fx: Infernius has +amo on #v1per.
# $chanlev <user|#authname> <flags> - This will set those flags on that person.
# The owner flag has been left out due to possible abuse which can lead to takeovers :)
# Configuration
# Your trigger!
set chanlev(trigger) "$"
# Lock out the owner flag for this script?
# 1 = yes, 0 = no
set chanlev(lockout) "1"
# Future plans
# Make 1 big proc to hande all responses.
# The only reason i made it like this is because i started out with a simple adding script,
# Later on, i added chanflags support and chanlev stats/chanlev viewer of flags support.
# Bind
bind PUB n|n ${chanlev(trigger)}chanlev pub:chanlev
bind PUB n|n ${chanlev(trigger)}chanflags pub:chanflags
# Procs. Don't touch these :)
proc pub:chanlev { nickname hostname handle channel arguments } {
global chanlev
set target [lindex [split $arguments] 0]
if {$target == ""} {
set chanserv [cserve $channel]
set chanlev(channel) $channel
if {$chanserv == "L"} {
bind notc -|- * chanlev:l:stats
putquick "PRIVMSG $chanserv :chanlev $channel"
} elseif {$chanserv == "Q"} {
bind notc -|- * chanlev:q:stats
putquick "PRIVMSG $chanserv :chanlev $channel"
} else {
putquick "NOTICE $nickname :There is no channel service on this channel."
return 0
}
} else {
set flags [lindex [split $arguments] 1]
if {$flags == ""} {
set chanserv [cserve $channel]
set chanlev(channel) $channel
if {$chanserv == "L"} {
bind notc -|- * l:reaction
putquick "PRIVMSG $chanserv :chanlev $channel $target"
}
if {$chanserv == "Q"} {
bind notc -|- * q:reaction
putquick "PRIVMSG $chanserv :chanlev $channel $target"
}
} else {
if {$chanlev(lockout) == "1" && [string match -nocase *n* $flags]} {
putquick "NOTICE $nickname :Sorry, Can't add the ownerflag due to safety protocols."
return 0
}
set chanserv [cserve $channel]
set chanlev(target) $target ; set chanlev(flags) $flags ; set chanlev(nick) $nickname ; set chanlev(channel) $channel ; set chanlev(chanserv) $chanserv
putquick "PRIVMSG $chanserv :chanlev $channel $target $flags"
bind notc -|- * chanlev:reaction
}
}
}
proc pub:chanflags { nickname hostname handle channel arguments } {
global chanflag
set flags [lindex [split $arguments] 0]
if {$flags == ""} {
if {![onchan Q $channel]} {
putquick "PRIVMSG $channel :Sorry but there is no Q bot here. Cannot proceed."
return 0
}
set chanflag(chan) $channel ; set chanflag(nick) $channel
bind NOTC -|- * chanflags:q:reaction
putquick "PRIVMSG Q :chanflags $channel"
} else {
set chanflag(chan) $channel ; set chanflag(nick) $nickname ; set chanflag(flag) $flags
bind NOTC -|- * chanflags:q:error
putquick "PRIVMSG Q :chanflags $channel $flags"
}
}
proc chanflags:q:error { nickname hostname handle arguments **** } {
global chanflag
set from "${nickname}!${hostname}"
if {[regexp -nocase -- {^(Q!TheQBot@CServe.quakenet.org)$} $from]} {
if {[regexp -nocase -- {^You have to be owner or master to change the CHANFLAGS} $arguments]} {
putquick "PRIVMSG $chanflag(chan) :I do not have master or owner access on Q"
unbind NOTC -|- * chanflags:q:error
return 0
}
if {[regexp -nocase -- {^Done.} $arguments]} {
putquick "PRIVMSG $chanflag(chan) :Done."
putquick "NOTICE $chanflag(nick) :$chanflag(flag) has been set on $chanflag(chan)"
unbind NOTC -|- * chanflags:q:error
return 0
}
}
}
proc chanflags:q:reaction { nickname hostname handle arguments **** } {
global chanflag
set from "${nickname}!${hostname}"
if {[regexp -nocase -- {^(Q!TheQBot@CServe.quakenet.org)$} $from]} {
if {[regexp -nocase -- {^Current channel flags are: (.*)} $arguments tmp flags]} {
putquick "PRIVMSG $chanflag(chan) :Current channel flags are: $flags"
unbind NOTC -|- * q:reaction
return 0
}
}
}
proc chanlev:q:stats { nickname hostname handle arguments **** } {
global chanlev
set from "${nickname}!${hostname}"
if {[regexp -nocase -- {^(Q!TheQBot@CServe.quakenet.org)$} $from]} {
if {[regexp -nocase -- {^You are not known or banned on this channel and can't dump the userlist!} $arguments]} {
putquick "PRIVMSG $chanlev(channel) :I don't have any flags on Q"
unbind notc -|- * chanlev:q:stats
return 0
}
if {[regexp -nocase -- {^Total:\s(\d+)\s\(owner:\s(\d+),\smaster:\s(\d+),\sop:\s(\d+),\svoice:\s(\d+)(,\sban:\s(\d+))?\)\.$} $arguments tmp total owner master op voice tmp ban]} {
putquick "PRIVMSG $chanlev(channel) :Chanlev stats for $chanlev(channel)"
putquick "PRIVMSG $chanlev(channel) :Total: $total (owner: ${owner}, master: ${master}, op: ${op}, voice: ${voice}, ban: ${ban})."
unbind notc -|- * chanlev:q:stats
return 0
}
}
}
proc chanlev:l:stats { nickname hostname handle arguments **** } {
global chanlev
set from "${nickname}!${hostname}"
if {[regexp -nocase -- {^(L!TheLBot@lightweight.quakenet.org)$} $from]} {
putlog "Getting a message from L!"
if {[regexp -nocase -- {^Sorry, you do not have permission to view/change user flags on (.*).} $arguments tmp channel]} {
putquick "PRIVMSG $chanlev(channel) :I don't have any flags on L"
unbind notc -|- * chanlev:l:stats
return 0
}
if {[regexp {^.*Total: (.*?) \(max 30 users\) \(owner: (.*?), master: (.*?), op: (.*?), voice: (.*?)\).*} $arguments tmp total owner master op voice]} {
putquick "PRIVMSG $chanlev(channel) :Chanlev stats for $chanlev(channel)"
putquick "PRIVMSG $chanlev(channel) :Total: $total (owner: ${owner}, master: ${master}, op: ${op}, voice: ${voice})."
unbind notc -|- * chanlev:l:stats
return 0
}
}
}
proc q:reaction { nickname hostname handle arguments **** } {
global chanlev
set from "${nickname}!${hostname}"
if {[regexp -nocase -- {^(Q!TheQBot@CServe.quakenet.org)$} $from]} {
if {[regexp -nocase -- {^You are not known or banned on this channel and can't dump the userlist!} $arguments]} {
putquick "PRIVMSG $chanlev(channel) :I don't have any flags on Q"
unbind notc -|- * q:reaction
return 0
}
if {[regexp -nocase -- {^Can't find that nickname. If the user isn't logged on, but is known by Q} $arguments]} {
putquick "PRIVMSG $chanlev(channel) :I'm afraid that user isn't authed."
unbind notc -|- * q:reaction
return 0
}
if {[regexp -nocase -- {^(.*) modes on channel (.*): (.*)} $arguments tmp auth channel modes]} {
putquick "PRIVMSG $chanlev(channel) :$auth has $modes on $channel."
unbind notc -|- * q:reaction
return 0
} else {
putquick "PRIVMSG $chanlev(channel) :User is not known on $chanlev(channel)."
unbind notc -|- * q:reaction
return 0
}
}
}
proc l:reaction { nickname hostname handle arguments **** } {
global chanlev
set from "${nickname}!${hostname}"
if {[regexp -nocase -- {^(L!TheLBot@lightweight.quakenet.org)$} $from]} {
if {[regexp -nocase -- {^Sorry, you do not have permission to view/change user flags on (.*)} $arguments tmp channel]} {
putquick "PRIVMSG $chanlev(channel) :I don't have any flags on L"
unbind notc -|- * l:reaction
return 0
}
if {[regexp -nocase -- {^(.*) is not known on (.*).} $arguments tmp auth channel]} {
putquick "PRIVMSG $chanlev(channel) :$auth is not known on $channel"
unbind notc -|- * l:reaction
return 0
}
if {[regexp -nocase -- {^Unknown user (.*)} $arguments tmp auth]} {
putquick "PRIVMSG $chanlev(channel) :Unknown user $auth"
unbind notc -|- * l:reaction
return 0
}
if {[llength $arguments] == 2} {
if {[regexp -nocase -- {^([^ ]*) *(.*)} $arguments tmp auth modes]} {
putquick "PRIVMSG $chanlev(channel) :$auth has $modes on $chanlev(channel)."
unbind notc -|- * l:reaction
}
}
}
}
proc chanlev:reaction {nickname hostname handle arguments ****} {
global chanlev
set from "${nickname}!${hostname}"
if {[regexp -nocase -- {^(Q!TheQBot@CServe.quakenet.org|L!TheLBot@lightweight.quakenet.org)$} $from]} {
if {[regexp -nocase -- {You do not have sufficient access|you do not have permission|You are not known or banned} $arguments]} {
putquick "PRIVMSG $chanlev(channel) :I have no access to $chanlev(chanserv) on this channel."
unbind notc - * chanlev:reaction
return 0
}
if {[regexp -nocase -- {You have to be master to change|You're not the owner or a master|Only owners can add or remove the master flag.} $arguments]} {
putquick "PRIVMSG $chanlev(channel) :I do not have the master flag for $chanlev(channel)"
unbind notc - * chanlev:reaction
return 0
}
if {[regexp -nocase -- {You have to be owner to change|Only owners can change|Only owners can add or remove} $arguments]} {
putquick "PRIVMSG $chanlev(channel) :I do not have the owner flag for $chanlev(channel)"
unbind notc - * chanlev:reaction
return 0
}
if {[regexp -nocase -- {Done.} $arguments]} {
putquick "PRIVMSG $chanlev(channel) :Done."
putquick "NOTICE $chanlev(nick) :$chanlev(target)'s flags were changed to $chanlev(flags) on $chanlev(channel)"
unbind notc - * chanlev:reaction
return 0
}
unbind notc - * chanlev:reaction
}
}
proc cserve {channel} {
if {[onchan Q $channel]} {return "Q"} elseif {[onchan L $channel]} {return "L"} else {return ""}
}
putlog "Chanlev $chanlev(version) loaded! Made by $chanlev(author)"