This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Random Topic at Given time

Help for those learning Tcl or writing their own scripts.
Post Reply
R
Romeyo
Voice
Posts: 12
Joined: Tue Nov 01, 2005 10:56 am

Random Topic at Given time

Post by Romeyo »

Hi,
I have written a tcl for setting random topic from a given time ... But its not changing the topic at all... My code is,

Code: Select all

#set the time to change topic in minutes (ex: for 8 hours = 8hours x 60mins = 480 mins)
set topic-at- 5

#set the channels to set the topic on delimited with commas (ex: #chan1,chan2)
set chan #channel-1,#channel-2


#set the topics u wanna use within double quots
set adtext {
     "Best file compression around: 'DEL *.*' = 100% compression"
     "If debugging is the process of removing bugs, then programming must be the process of putting them in."
     "Doctor : A Person Who Kills Your Ills By Pills, And Kills You With His Bills."
}
	set notnick "$botnick" 
	set notnick [string tolower ${nick}]
	if {![info exists {ald}]} {
  	global notnick chan topic-at- adtext
  	set ald 1
  	timer ${topic-at-} printing
	}

	proc printing {} {
  	global notnick chan topic-at- adtext
  	set printochan [lindex $adtext [rand [llength $adtext]]]
      putquick "TOPIC $chan :$printochan"
  	timer ${topic-at-} printing
	}
Thanks...
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Your code has a lot of bogus stuff, try this:

Code: Select all

#set the time to change topic in minutes (ex: for 8 hours = 8hours x 60mins = 480 mins)
set topictime 5

#set the channels to set the topic on delimited with commas (ex: #chan1,chan2)
set topicchans "#channel-1 #channel-2"

#set the topics u wanna use within double quots
set topictext {
     "Best file compression around: 'DEL *.*' = 100% compression"
     "If debugging is the process of removing bugs, then programming must be the process of putting them in."
     "Doctor : A Person Who Kills Your Ills By Pills, And Kills You With His Bills."
}

if {[timerexists settopic] == ""} {
 timer $topictime settopic
}

proc settopic {} {
 global topictime topicchans topictext
 set topic [lindex $topictext [rand [llength $topictext]]]
 foreach chan $topicchans {
  if {[botonchan $chan] && [botisop $chan]} {
   putquick "TOPIC $chan :$topic"
  }
 }
 timer $topictime settopic
}
PS: alltools.tcl should be loaded for the [timerexists] command to work.
Post Reply