Ive recently got my hands on this tcl from the egghelp tcl archive.
Its very nice, but im wondering if its possible to get it to work with more topicmasks for each channel and assign each one with a number or wildcard.
Lemme give you an example;
.topicmask set #channel "1" Welcome to #chan - news:
.topicmask set #channel "rules" Welcome to #chan - rules:
And then to use it like:
!tm 1 Sign up on the new website!
!tm rules READ THE NEW RULES!
Get it?
Code: Select all
# topicmask tcl
# 12:39 PM 12/10/2007
########################
# AUTHOR INFORMATION
########################
# Author: vigilant
# Contact: admin@anserq.com for bugs, suggestions and all that.
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
########################
# PURPOSE
########################
# Lets you add a * to your topic and then, replace the * with anything using a public command.
#
########################
#
# EXAMPLE
########################
# .chanset #channel +topicmask
#
# .chanset #channel tmtopic welcome to #channel - news: *
# OR
# .topicmask set #channel welcome to #channel - news: *
#
# Then in channel, !tm Sign up on the website!
# and the channel topic would be: welcome to #channel - news: Sign up on the website!
#
# To disable topicmask on a channel, .chanset #channel -topicmask
# So this is the handy capability of this script.
set tm(version) "0.1"
# EDIT BELOW
# The public channel command character to use for changing topic.
set tm(cmdchar) "!"
# The minimum flag needed to use public command
# format, global|channel
set tm(pub) "m|m"
# The minimum flag to set/clear topicmasks
# format, global|channel
set tm(dcc) "m|m"
# END OF EDITTING
# vars
setudef flag topicmask
setudef str tmtopic
# binds
bind dcc -|- topicmask tm_dcc
bind pub -|- [string trim $tm(cmdchar)]tm tm_pub
# code starts here...
set tm(commands) "set help clear"
proc tm_dcc { h i t } {
global tm
set cmd [lindex $t 0]
switch -glob -- $cmd {
set {
if {![matchattr $h $tm(dcc) [lindex $t 1]]} {
putdcc $i "You do not have enough access to use this command"
return 1
}
if {![validchan [lindex $t 1]]} {
putdcc $i "This channel does not exist"
return 1
}
if {![channel get [lindex $t 1] topicmask]} {
putdcc $i "This channel does not have topicmask enabled"
return 1
}
if {[validchan [lindex $t 1]] && [channel get [lindex $t 1] topicmask] && [lindex $t 2] == ""} {
putdcc $i "Please enter a valid topic"
putdcc $i "Such as: Welcome to #channel, news: *"
putdcc $i "\002Make sure to enter the *\002"
return 1
}
if {![string match {*\**} [lrange $t 2 end]]} {
putdcc $i "Make sure to enter a * for topicmask"
} else {
set topicreq [lrange $t 2 end]
set newtopic [channel set [lindex $t 1] tmtopic $topicreq]
putdcc $i "New topic for [lindex $t 1] is [channel get [lindex $t 1] tmtopic]"
putquick "TOPIC [lindex $t 1] :$topicreq"
return 0
} }
clear {
if {[matchattr $h $tm(dcc) [lindex $t 1]] == 0} {
putdcc $i "You do not have enough access to use this command"
return 1
}
if {![validchan [lindex $t 1]]} {
putdcc $i "Please enter a valid channel"
return 1
} else {
set empty ""
channel set [lindex $t 1] tmtopic $empty
putdcc $i "Cleared the topicmask for [lindex $t 1]"
return 0
}
}
help {
set tm(helpcmds) "set clear"
if {[lindex $t 1] == ""} {
putdcc $i "Get help with what? Available commands: \002$tm(helpcmds)"
}
if {[lindex $t 1] == "set"} {
putdcc $i "\002set\002"
putdcc $i "To set a topicmask for a channel simply type: .topicmask set #channel topicmask topic here"
putdcc $i "Include the * in this topicmask, then in the channel, !tm topic here"
}
if {[lindex $t 1] == "clear"} {
putdcc $i "\002clear\002"
putdcc $i "To clear a topicmask of a channel, type: .topicmask clear #channel"
}
}
default {
putdcc $i "Enter a command: \002$tm(commands)"
}
}
}
# The public command to use topicmask'ed topic
proc tm_pub { n u h c a } {
global tm
set gettopic [channel get $c tmtopic]
if {![matchattr $h $tm(pub) $c]} {
putnotc $n "You don't have enough access to use this command"
return 1
} elseif {![channel get $c topicmask]} {
putnotc $n "This channel does not have topicmask setting enabled"
return 1
} elseif {![string match {*\**} $gettopic]} {
putnotc $n "This channel does not have a setup topicmask"
return 1
} elseif {[string match {*\**} $gettopic] && [lindex $a 0] == ""} {
putnotc $n "Cannot enter an empty topic."
return 1
} else {
set newtopic [lreplace $gettopic [lsearch -glob $gettopic {*\**}] [lsearch -glob $gettopic {*\**}] $a]
putquick "TOPIC $c :[join $newtopic]"
return 0
}
}
putlog "Topicmask version: $tm(version) by vigilant initialized"
Thanks in advance!