setudef flag mytopic
bind msg v|v topic cmd:topic
proc cmd:topic {nick uhost hand arg} {
set chan [lindex [split $arg] 0]
set text [join [lrange [split $arg] 1 end]]
if {[string match *[string index $chan 0]* "#&"]} {
if {[validchan $chan] && [botison $chan]} {
if {[botisop $chan]} {
if {[channel get $chan mytopic]} {
if {[onchan $nick $chan]} {
putserv "TOPIC $chan :$text"
} else {
putserv "NOTICE $nick :You need to be in the channel to witness the topic change. Nice try. :P"
}
} else {
putserv "NOTICE $nick :You CANNOT change topic of $chan. Nice try."
}
} else {
putserv "NOTICE $nick :I'm not op of $chan so no topic change for you. :P"
}
} else {
putserv "NOTICE $nick :I'm not on $chan. How do you expect me to change topic?!"
}
} else {
putserv "NOTICE $nick :What is $chan? That doesn't look like any IRC channel I've ever seen. :P"
}
}
Here's the same script with some extra checks to make sure users aren't causing your bot to send garbage to the IRCD.
To get it to work in #yourchan: .chanset #yourchan +mytopic
After that, it will work for users with voice in #yourchan. Other users cannot manipulate your bot without being in it's presence.