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.

Message Auto-Reply

Old posts that have not been replied to for several years.
Locked
w
wile

Message Auto-Reply

Post by wile »

bot will reply for a massage at the channel or nick
but i have an error which is

Tcl error [replychan]: wrong # args: should be "string option arg ?arg ...?"

here is the source problem
proc replychan {nick uhost hand chan rest} {
global botnick repchan
foreach targchan $repchan {if {[string match *[string tolower $targchan]* [string tolower $chan]]} {append reps "$chan $rest" ; replyuser $nick $uhost $hand $reps ; return 0}}
}
User avatar
Dereckson
Voice
Posts: 20
Joined: Thu May 30, 2002 8:00 pm
Location: Belgium
Contact:

Post by Dereckson »

Please give a example of sentence that causes an error.
Sébastien Santoro
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Place the *[string tolower $targchan]* in two "'s like: "*[string tolower $targchan]*" if you use *wildcards*
Once the game is over, the king and the pawn go back in the same box.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I don't think the error is in that proc. It's probably in your "replyuser" function.
w
wile

Post by wile »

hello mr. ceasar i tried your advice theres new error such as
[17:31] Tcl error [replychan]: wrong # args: should be "string match ?-nocase? pattern string"
:(
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Please do paste the code of the *replychan* proc.
Once the game is over, the king and the pawn go back in the same box.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I'm sure caesar meant the replyuser proc, because replychan is already posted :)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Uhmm. yes, mea culpa. Btw, that *string match* thing should have some " in it..
Once the game is over, the king and the pawn go back in the same box.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Re: Message Auto-Reply

Post by egghead »

wile wrote:bot will reply for a massage at the channel or nick
but i have an error which is

Tcl error [replychan]: wrong # args: should be "string option arg ?arg ...?"

here is the source problem
proc replychan {nick uhost hand chan rest} {
global botnick repchan
foreach targchan $repchan {if {[string match *[string tolower $targchan]* [string tolower $chan]]} {append reps "$chan $rest" ; replyuser $nick $uhost $hand $reps ; return 0}}
}
It feels like you are breaking the [string match] command across lines.
So, besides the comments/suggestions given above, make sure that you don't break the code across lines. Newlines, do matter.

WRONG:

Code: Select all

if { [string match *$targchan* \n
$chan]} { .... }
the \n indicates a newline

RIGHT:

Code: Select all

if { [string match *$targchan* $chan] } { \n
... }
Example of what may go wrong:

Code: Select all

if { [string match
hello world ]
} {
   puts "match"
} {
   puts "no match"
}
will result in:
wrong # args: should be "string match ?-nocase? pattern string"
while executing
"string match "
(file "test.tcl" line 1)
Another example

Code: Select all

if { [string 
match hello world ]
} {
   puts "match"
} {
   puts "no match"
}
will result in:
wrong # args: should be "string option arg ?arg ...?"
while executing
"string "
(file "test.tcl" line 1)
Last edited by egghead on Mon Jul 14, 2003 6:51 pm, edited 2 times in total.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

caesar wrote:Uhmm. yes, mea culpa. Btw, that *string match* thing should have some " in it..
tclsh8.3
% set targchan foo
foo
% set chan #foobar
#foobar
% string match *$targchan* $chan
1
% puts *$targchan*
*foo*
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

try with two words like: foo bar .. and you will see a notable difference. if is one word only then is working, else.. see for yourself.
Once the game is over, the king and the pawn go back in the same box.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

caesar wrote:try with two words like: foo bar .. and you will see a notable difference. if is one word only then is working, else.. see for yourself.
First, I would assume that a channel name is a single word. But, if you insist...
tclsh8.3
% set targchan "foo bar"
foo bar
% set chan #foobar
#foobar
% string match *$targchan* $chan
0
% puts *$targchan*
*foo bar*
Now that I did see it for myself (as you asked), I wonder what your point is?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

not like that silly.. like this: .tcl string match *foo* foo bar .. anyway, it realy dosen't matter.. I'm used to use the " to make the code look better and avoid any errors.
Once the game is over, the king and the pawn go back in the same box.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

caesar wrote:not like that silly.. like this: .tcl string match *foo* foo bar .. anyway, it realy dosen't matter.. I'm used to use the " to make the code look better and avoid any errors.
How would the code given by wile ever get to such a construction?

There are two string variables $targchan and $chan and they are compared to each other.

For sure, a command will fail if you don't use the proper syntax.
Locked