egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

View current Channeltopic (with !topic)

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
SignZ
Voice


Joined: 17 Jun 2010
Posts: 18

PostPosted: Thu Jun 17, 2010 4:00 pm    Post subject: View current Channeltopic (with !topic) Reply with quote

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:
bind pub - !topic currenttopic


proc currenttopic {topic nick uhost hand chan text } {
  set curtop[topic $chan]
  putserv "privmsg $chan :$curtop"
}

.set errorInfo gives me >
Quote:
[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?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Jun 17, 2010 4:26 pm    Post subject: Reply with quote

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:
  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:
putserv "PRIVMSG $chan :[topic $chan]"

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
SignZ
Voice


Joined: 17 Jun 2010
Posts: 18

PostPosted: Thu Jun 17, 2010 8:07 pm    Post subject: Reply with quote

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:

# 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. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber