On topic

From Scriptwiki
Jump to: navigation, search

The on TOPIC event triggers when a user changes a channel topic.

on <level>:TOPIC:<#[,#]>:<commands>

The $1- parameter holds the new topic.


on *:TOPIC:#: {
 echo $chan $nick just changed topic on $chan to: $1-

This would echo whenever a new topic is set in a channel you are. The target is the channel where topic was changed.

The next, more complex example, would undo every topic change of a "not knows" user. Note that you should set a standardtopic at first (by using /set %topic <topic>). You additionally need to change #yourchan to your channel (e.g. #help.script).

on *:TOPIC:#yourchan: {
 ; if the one who has set the new topic has a userlevel lower than 2
 if ($level($nick) < 2) { 
  ; if we have a topic saved (in %topic), we reset the topic
  if (%topic) { topic #help.script %topic } 
  ; if not, we take the new topic as standard
  else { set %topic $1- }
 ; if the level is above 2, the user is allowed to change the topic
 else {
  ; take the new topic as standard
  set %topic $1-

Note that this example is for one channel only. If you want to have it for more than one channel, you need to choose variables depeding on the channelname (e.g. %topic. [ $+ [ $chan ] ])