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.

View current Channeltopic (with !topic)

Help for those learning Tcl or writing their own scripts.
Post Reply
S
SignZ
Voice
Posts: 18
Joined: Thu Jun 17, 2010 3:52 pm

View current Channeltopic (with !topic)

Post by SignZ »

Yoyoyo, been here looking for some scripts a while, but now I really need your help.

What I wanna do is, that if I or somebody else (doesn't matter who) types !topic in a channel, the Bot "says" the current topic.

Like:
[@SignZ] !topic
[@FlameHaze] Welcome to #SignZ. Need help? Just ask < (which would be the channeltopic)

I tried it with following "script", but..

Code: Select all

bind pub - !topic currenttopic


proc currenttopic {topic nick uhost hand chan text } {
  set curtop[topic $chan]
  putserv "privmsg $chan :$curtop"
}
.set errorInfo gives me >
[21:54:05] <SignZ> .set errorInfo
[21:54:05] [FlameHaze] [21:53] tcl: builtin dcc call: *dcc:set SignZ 7 errorInfo
[21:54:05] [FlameHaze] Currently: wrong # args: should be "currenttopic topic nick uhost hand chan text"
[21:54:06] [FlameHaze] Currently: while executing
[21:54:06] [FlameHaze] Currently: "currenttopic $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
So, can anbody help me with this (maybe easier than I think) script?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Step 1: (re)read the docs about the pub binding (from doc/tcl-commands.doc).

Step 2: Modify your currenttopic proc accordingly (Hint: you've got one argument too plenty, remove the excessive one).

Step 3: Fix this line, or remove it completely:

Code: Select all

  set curtop[topic $chan]
There should be a speace between the variable name, and the value you'd like to assign it. That said, you could just as well insert the command substitution directly into the putserv command:

Code: Select all

putserv "PRIVMSG $chan :[topic $chan]"
NML_375
S
SignZ
Voice
Posts: 18
Joined: Thu Jun 17, 2010 3:52 pm

Post by SignZ »

Well, I did re-read the docs and thought the script could be better (besides getting fixed, which was the fault of another script)

Code: Select all

# SignZ ownz you

setudef flag topicspew

variable topicwait 30

bind pub -|- !topic topic:spew

proc topic:spew {nick uhost hand chan text} {
	if {![channel get $chan topicspew]} {
		return
	} elseif {[topic:throttle $hand,$chan $::topicwait]} {
		putserv "privmsg $chan :$nick, you need to wait for [expr {$::topicthrottle($hand,$chan) - [clock seconds]}] more seconds please..."
	} else {
		putserv "privmsg $chan :$nick, $chan's topic is: [topic $chan]"
	}
}

# Throttle Proc - Thanks to user
# see this post: http://forum.egghelp.org/viewtopic.php?t=9009&start=3
proc topic:throttle {id seconds} {
	global topicthrottle
	if {[info exists topicthrottle($id)]&&$topicthrottle($id)>[clock seconds]} {
		set id 1
	} {
		set topicthrottle($id) [expr {[clock seconds]+$seconds}]
		set id 0
	}
}
# delete expired entries every 10 minutes
bind time - ?0* topic:throttledCleanup
proc topic:throttledCleanup args {
	global topicthrottle
	set now [clock seconds]
	foreach {id time} [array get topicthrottle] {
		if {$time<=$now} {unset topicthrottle($id)}
	}
}
The docs are really helpfull. :D
Post Reply