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.

help needed with mass-removing ignores

Help for those learning Tcl or writing their own scripts.
Post Reply
t
tigwis
Voice
Posts: 2
Joined: Thu Jul 28, 2011 1:53 pm

help needed with mass-removing ignores

Post by tigwis »

Dear friends of the TCL language.

I decided to write a script a few days ago for my sc2 clan, that
involves picking a challenger every day at a certain time.
Most of the script is done, but it seems i can not really
manage to do one proc: mass-removing bans.

Here is what I have thus far:

bind pub - !delignores delignores:pub
proc delignores:pub {vars} {
foreach ignore [ignorelist] { killignore 1 }
}

The error:
[17:52:19] Tcl error [delignores:pub]: wrong # args: should be "delignores:pub vars"


Could someone help me into the right direction?
I must admit that most of my procs are based on examples :(
Thank you.
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Re: help needed with mass-removing ignores

Post by willyw »

tigwis wrote:Dear friends of the TCL language.

I decided to write a script a few days ago for my sc2 clan, that
involves picking a challenger every day at a certain time.
Most of the script is done, but it seems i can not really
manage to do one proc: mass-removing bans.

bans?
or ignores?

Here is what I have thus far:

bind pub - !delignores delignores:pub
proc delignores:pub {vars} {
foreach ignore [ignorelist] { killignore 1 }
}

The error:
[17:52:19] Tcl error [delignores:pub]: wrong # args: should be "delignores:pub vars"


Could someone help me into the right direction?
I must admit that most of my procs are based on examples :(
Thank you.
Visit:
http://www.eggheads.org/support/egghtml ... mands.html

and scroll down to:
Bind types

Find:
4. PUB

bind pub <flags> <command> <proc>
procname <nick> <user@host> <handle> <channel> <text>
That is describing the way to use
bind pub
and the procedure called by bind pub.

See how there are five variables passed to the procedure?

It doesnt' matter what you name them, but something like this is typical:

Code: Select all

delignores:pub {nick uhost handle chan text}  {

# code to run within this proc goes here

 }
Not using the right number of variables is the cause of the error you are seeing. You had only one.


Further, while you are at:
http://www.eggheads.org/support/egghtml ... mands.html
find:
killignore <hostmask>

That's telling you that the killignore command does not want a numeral, like you are giving it. It wants the actual hostmask from the current list of ignores, that you wish to kill.

If you use the ignorelist command, you can get that list.
Then, you'd have to index into it, to get the hostmask from the first sublist returned.

Try this:

Code: Select all

foreach ig [ignorelist] {
  killignore [lindex $ig 0 ]
 }
#this is untested 
For information on using lindex , go here:
http://www.tcl.tk/man/tcl8.5/TclCmd/lindex.htm

For information on using foreach, go here:
http://www.tcl.tk/man/tcl8.5/TclCmd/foreach.htm

Main page is here:
http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm


I hope this helps.



edit:
fixed typo.
Was:
delignores:pub {nick uhost handle chan text} [
Last edited by willyw on Thu Jul 28, 2011 8:06 pm, edited 1 time in total.
t
tigwis
Voice
Posts: 2
Joined: Thu Jul 28, 2011 1:53 pm

Post by tigwis »

My sincere thanks for this great and helpfull post.
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

You're welcome. :)
Post Reply