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.

Quick Linking Again // Other Method This Time

Help for those learning Tcl or writing their own scripts.
Post Reply
d
dokueki
Voice
Posts: 31
Joined: Sat Apr 28, 2007 8:42 am
Location: Bat Yam, Israel
Contact:

Quick Linking Again // Other Method This Time

Post by dokueki »

Well, the other script was giving me trouble if I tried multiplying it for several links, so I thought I'd just stop going the SDK way and make the script for myself, as no one will need it from me anyways. So the scripts is as such:

Code: Select all

bind pub - "!xpro" spidey:xpro_link

proc spidey:xpro_link { nick host hand chan args } {

   set params [split $args]
   set action [lindex $params 0]
   set sa [lindex $params 1]

   putserv "NOTICE $nick :1. $action 2. $sa"
	 if { $action == "" } {
      putserv "PRIVMSG $chan :http://xpro.zeeblo.com (Requested by $nick)"
   } elseif { $action != "" && $sa == "" } {
      putserv "NOTICE $nick :Not enough parameters."
   } elseif { $action == "topic"} {
      putserv "PRIVMSG $chan :http://xpro.zeeblo.com/index.php?topic=$sa (Requested by $nick)"
   } elseif { $action == "forum"} {
      putserv "PRIVMSG $chan :http://xpro.zeeblo.com/index.php?board=$sa (Requested by $nick)"
   } elseif { $action == "user"} {
      putserv "PRIVMSG $chan :http://xpro.zeeblo.com/index.php?action=profile;u=$sa (Requested by $nick)"
   } elseif { $action == "action"} {
      putserv "PRIVMSG $chan :http://xpro.zeeblo.com/index.php?$sa (Requested by $nick)"
   }
   return 0
}

putlog "xproDesigns Links 1.0 by Hen Asraf: Loaded"
When outputting the notice at start to debug what was going on with the arguments, I noticed the first argument begins with { and the second ends with } so it outputted "1. {foo 2. bar}". Is there a way to stop this from happening and return everything without the braces?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Yes, don't use "args" as a parameter name (anything else will do, just not "args")
NML_375
d
dokueki
Voice
Posts: 31
Joined: Sat Apr 28, 2007 8:42 am
Location: Bat Yam, Israel
Contact:

Post by dokueki »

I tried that. When I did, it would give me this error:

Code: Select all

[04:53:40 pm] <Venom> [11:53] Tcl error [spidey:xpro_link]: wrong # args: should be "spidey:xpro_link nick host hand chan action sa"
And even if I fixed that, would it work if I put less parameters than necessary?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Why on earth would you replace "args" with multiple arguments ("action" and "sa")? The number of arguments in your proc-definition must match the number of arguments used when the binding triggers (with pub-bindings, this would be <nickname> <host> <handle> <channel> <text>).

The text ppl write in the channel will always use one argument with pub-bindings, it is up to you as a coder to gather the desired data from it...
NML_375
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

He told you to rename 'args' to anything else (1 word) and you replaced it with 'action sa' ... How about just 'text'?
d
dokueki
Voice
Posts: 31
Joined: Sat Apr 28, 2007 8:42 am
Location: Bat Yam, Israel
Contact:

Post by dokueki »

Thanks, I replaced "args" with "text" and it worked. Sorry for all the trouble!
Post Reply