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.

parsing messages

Old posts that have not been replied to for several years.
Locked
e
eiSi
Halfop
Posts: 70
Joined: Thu Mar 07, 2002 8:00 pm

parsing messages

Post by eiSi »

hi there!

a little question:

I message a channelservice:

msg blubb showmedatop5

and it returns:

Pos nick desc
1 @blub blubb0r
2 @asd asdasdasd
3 @asdasdasd adsdsasdasad
4 @adddd dddddd
5 @rwer werwerwer
6 @mmm mmmm

how to "check" if the the user rwer is in the first 5/6 returned lines?

can you please help me with this problem? thanks a lot!
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Use a msgm bind on *. Make sure the nick is "blubb". If the text says "Pos nick desc", set a flag to 1. Otherwise, make sure flag is 1 already (if not, return). Split the text, make sure the first item on the line is a number from 1-6. Check to see if the second item is @rwer. If it is, success! If the first item on the line is > 6, and flag is 1, then failure, and set flag to 0.

There's your logic, now you're 3/4 done!
e
eiSi
Halfop
Posts: 70
Joined: Thu Mar 07, 2002 8:00 pm

Post by eiSi »

thanks a lot!

this really helps me!

I'll try it today!
e
eiSi
Halfop
Posts: 70
Joined: Thu Mar 07, 2002 8:00 pm

Post by eiSi »

ok, getting more conrete:

|03:12| »» [Rbot] Msg to o: chanoplist #rtest
|03:12| »» [Rbot] [15:12] [O!operserv@operservice.mynet.org] Pos Score User/Last seen
|03:12| »» [Rbot] [15:12] [O!operserv@operservice.mynet.org] 1 1 tuxx tuxx@myhost.de tuxx
|03:12| »» [Rbot] [15:12] [O!operserv@operservice.mynet.org] 2 1 Last seen: Thu Apr 10 01:04:12 2003
|03:12| »» [Rbot] [15:12] [O!operserv@operservice.mynet.org] 3 1 Last seen: Thu Apr 10 01:04:12 2003
|03:12| »» [Rbot] [15:12] [O!operserv@operservice.mynet.org] 4 1 @rbot Rbot@myhost.de
|03:12| »» [Rbot] [15:12] [O!operserv@operservice.mynet.org] --- End of list - 4 listed ---

so, my current proc is like this:

Code: Select all

bind msgm - * handlemsg
set isO 0
set currLine 0
set home "#mychan"
proc handlemsg {nick uhost hand chan args} {
	global isO currLine home
	if {$nick != "O"} {
		return
	} else {
		set response [split $args " "]
		if {[lindex $response 0] != "Pos"} {
			return
		} else {
			msg $home "debug"			
			incr currLine
			if {$currLine < 6} {
				foreach i [split $misc2 ""] {
					notice "tuxX" "test"
				}
			} else {
				return
			}
		}
	}
}
It should send "debug" to the channel, but it doesn't. any suggestions?

thanks! :)
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Where is the 'msg' proc defined? Try replacing msg with putlog, and just watch on the partyline for it to appear.

putlog "debug"
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Replace from:

Code: Select all

msg $home "debug"
to:

Code: Select all

putserv "PRIVMSG $home :debug"
and you will see an debug thing, or try the putlog as stdragon sugested you.
Once the game is over, the king and the pawn go back in the same box.
e
eiSi
Halfop
Posts: 70
Joined: Thu Mar 07, 2002 8:00 pm

Post by eiSi »

thx, but the msg proc looks like this:

Code: Select all

proc msg {a b} {putserv "privmsg $a :$b"}
and if I place the debug thing after the first else bracket, it works fine.

could it be a problem of speed?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If you use this "msg" in more than one proc or somethinglike this and you don't want to have to many lines, yes, but this will slow it down a bit, because he calls another proc while is in one, after he finishes it he returns to it's original one and continues with it till the end of it.
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It may be that another script it overwritting the msg proc.

Try creating a unique name for it, and use it in your scripts to make sure this isn't the problem.
e
eiSi
Halfop
Posts: 70
Joined: Thu Mar 07, 2002 8:00 pm

Post by eiSi »

okay!

thanks again!

@ppslim: I don't think so, because I tried to put the debug think just right at the beginning, there it works...
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

THat will teach me to make assumptions.

Your error is likely your use of the $args variable.

Args has a special meaning when used in a Tcl procedure definition.

Where each other variable will contain a string of text, for that portion passed, args contains a list of arguments.

This allows you to create unlimited length variable lists, without having to specificaly delare them.

As $args is allready a list, there is no need to split it. Aditionaly, the split command with split using " " by default (so iliminating this part of the command will save trouble).

Spliting a list causes all sorts of problems, leaving junk characters from the original list, when obtaining an index.

The quickest method of resolving this, is to use arg rather than args. The split command can remain (including the " " if so wanted), and then all should work.
e
eiSi
Halfop
Posts: 70
Joined: Thu Mar 07, 2002 8:00 pm

Post by eiSi »

all right! I'll try it asap!

update:

it says:
|12:28| »» [Rbot] [12:28] Tcl error [handlemsg]: wrong # args: should be "handlemsg nick uhost hand chan arg"
and the code:

Code: Select all

bind msgm - * handlemsg

proc handlemsg {nick uhost hand chan arg} {
	global isO currLine home
	if {$nick != "O"} {
		return
	} else {
		set response [split $arg " "]
		if {[lindex $response 0] != "Pos"} {
			return
		} else {
			msg $home "debug"			
			incr currLine
			if {$currLine < 6} {
				foreach i [split $misc2 ""] {
					notice "tuxX" "test"
				}
			} else {
				return
			}
		}
	}
}
any suggestions?

thanks again!
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

-error- didnt watch correct....where's the delete post button ?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It should be neither.

You are using a bind type of MSGM. This means private messages sent to the bot.

In your script, you are using "nick uh hand chan arg".

There is no channel in a private message.
e
eiSi
Halfop
Posts: 70
Joined: Thu Mar 07, 2002 8:00 pm

Post by eiSi »

thanks!

now all works fine!
Locked