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.

!args - mysql !command script

Help for those learning Tcl or writing their own scripts.
Post Reply
o
osiris
Voice
Posts: 2
Joined: Mon Nov 15, 2010 12:57 pm
Location: BE

!args - mysql !command script

Post by osiris »

Hi all.
I am currently making a mysql based !command script (!command nickname1 nickname2) for entertainment of my users.
There are only two things I don't know how to do although it might be quite simple.

#1:
how can I bind just "!" and take everything directly behind it as the first argument ?

#2:
is it possible to automatically replace (in output) %1 and %2 by $nick and $arg(s) (maybe regsub?)

Thanks ;)
t
thommey
Halfop
Posts: 76
Joined: Tue Apr 01, 2008 2:59 pm

Post by thommey »

#1: bind pubm - "% !*" dostuff
last argument to dostuff will be the full string "!test a b c"
bind pubm in the reference manual

#2: no "automation", but you can just string map it (regsub needs special treatment of special chars which is ugly)

Code: Select all

set output [string map [list %1 $nick %2 $arg] $output]
string map in the reference manual
o
osiris
Voice
Posts: 2
Joined: Mon Nov 15, 2010 12:57 pm
Location: BE

Post by osiris »

That seems to work indeed, except for the second argument which he doesn't read for some reason... (you can use !command, but not !command victim)

Thank you for your help :)
Post Reply