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.

whois info [SOLVED]

Help for those learning Tcl or writing their own scripts.
Post Reply
A
AskMe
Voice
Posts: 23
Joined: Wed Apr 11, 2007 4:22 pm
Location: Canada

whois info [SOLVED]

Post by AskMe »

in MIRC when i do a whois i reveice this info

Code: Select all

nick is "www.mysitecom/?u=1234" ~bla@myhost.com
how can i retreive the full name info "www.mysitecom/?u=1234" ???

i need this info to make a matchattr ;)

thanks
Last edited by AskMe on Tue Jun 12, 2007 1:25 pm, edited 1 time in total.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Raw 311, use the raw-bind to catch it.
A
AskMe
Voice
Posts: 23
Joined: Wed Apr 11, 2007 4:22 pm
Location: Canada

Post by AskMe »

i need a little help on that

Code: Select all

bind raw - 311 uw:RAW311
proc uw:RAW311 {from keyword args} {
  set args [lindex $args]
  putlog "TEST $args"
}
i receive this

Code: Select all

TEST {botnick nick ~bla myhost.com  * :www.mysitecom/?u=1234}
anyone can help me to just have this info please?

Code: Select all

www.mysitecom/?u=1234
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

First off, don't use "args" as a parameter name. It has some special mechanics that will cause problems if you are not aware of them.

Next, say we changed it to "text", first step would be to either locate the colon (:), or split the string into a list (using colon as separator character).
Easiest would probably be using split, although this might cause some problems in some cases, whereas locating the colon should always work.

Next step would depend on which method you have chosen, and you will either use lindex to retireve the proper list-item from the newly formed list, or "string range" to select a substring from the textstring.

The following example uses the substring method:

Code: Select all

set i [expr [string first " :" $text] + 1]
set info [string range $text $i end]
NML_375
A
AskMe
Voice
Posts: 23
Joined: Wed Apr 11, 2007 4:22 pm
Location: Canada

Post by AskMe »

ok its getting better now but not perfect ;)

Code: Select all

bind raw - 311 uw:RAW311
proc uw:RAW311 {from keyword text} {
  set i [expr [string first " :" $text] + 1]
  set info [string range $text $i end]
      putlog "TEST $info"	
}
and the result is

Code: Select all

TEST :www.mysitecom/?u=1234
now i need to remove the : at the begining of :www.mysitecom/?u=1234
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

May be try:

Code: Select all

[string trim [join [lrange $text $i end]] :]
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
A
AskMe
Voice
Posts: 23
Joined: Wed Apr 11, 2007 4:22 pm
Location: Canada

Post by AskMe »

Alchera wrote:May be try:

Code: Select all

[string trim [join [lrange $text $i end]] :]
not working...

result

Code: Select all

TEST
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

set info [string trimleft [string range $text $i end] :]
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

why not

Code: Select all

set i [expr {[string first ":" $text]+1}]
?
Have you ever read "The Manual"?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Actually, the flaw is that I added 1 and not 2 to the offset. (Forgot I matched 2 characters rather than 1) :oops:
Should work as intended

Code: Select all

set i [expr [string first " :" $text] + 2]
set info [string range $text $i end]
@Alchera: Why on earth would you use lrange and join on a string?
NML_375
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

nml375 wrote:@Alchera: Why on earth would you use lrange and join on a string?
Typo :P

I copied and pasted from an xchat script I use where everything has to be split etc to remove unwanted characters (an xchat quirk apparently).
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Think it's rather a matter of preference, if you prefer to work with list or strings. Either way works I suppose, as long as you don't mix them up :P

One problem with splitting on colon ( : ) however, is that it might screw up bigtime on IPv6 hosts (thats also the reason I'm searching for " :" and not ":").
NML_375
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

[22:26] * =============== _|nTe|_ whois response ===============
[22:26] * [_|nTe|_] (gUeSs@helper.phazenet.com): gUeSs
[22:26] * [_|nTe|_] is a registered nick
[22:26] * [_|nTe|_] #scriptingshack @#phazeschool &#phazechat @#HelpDesk +#Command &#Ballarat
[22:26] * [_|nTe|_] Pothole.US.Phazenet.Com :Finer Than A Frogs Hair
[22:26] * [_|nTe|_] is available for help.
[22:26] * =============== _|nTe|_ whois end ===============
I use XChat's Tcl plugin to format the above and without manipulation I'd have a series of brackets and braces amongst it all. I copied and pasted a line of code forgetting to fix it for eggdrop. :lol:

XChat snippet:

Code: Select all

# RPL_WHOISUSER
on 311 mywhois {
    set whodata [split $_rest " "]
    set servertab [findcontext [server]]
    .......
    complete EAT_ALL
}
PS: I've been "inspired" to revisit this script of mine. :lol:
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
A
AskMe
Voice
Posts: 23
Joined: Wed Apr 11, 2007 4:22 pm
Location: Canada

Post by AskMe »

Sir_Fz wrote:

Code: Select all

set info [string trimleft [string range $text $i end] :]
This works great
nml375 wrote:Actually, the flaw is that I added 1 and not 2 to the offset. (Forgot I matched 2 characters rather than 1) :oops:
Should work as intended

Code: Select all

set i [expr [string first " :" $text] + 2]
set info [string range $text $i end]
This one works great too
user wrote:why not

Code: Select all

set i [expr {[string first ":" $text]+1}]
?
didnt work.. they give me this result

Code: Select all

TEST 0
so if anyone need the info you can use

Code: Select all

bind raw - 311 uw:RAW311
proc uw:RAW311 {from keyword text} {
  set i [expr [string first " :" $text] + 2]
  set info [string range $text $i end]
	putlog "TEST $info"	
}
or

Code: Select all

bind raw - 311 uw:RAW311
proc uw:RAW311 {from keyword text} {
  set i [expr [string first " :" $text] + 1]
  set info [string trimleft [string range $text $i end] :]
	putlog "TEST $info"	
}
they both give me

Code: Select all

TEST www.mysitecom/?u=1234
thanks to all for your help ;)
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

AskMe: user's hint was based on what nml375 posted before it was fixed:

Code: Select all

set i [expr {[string first " :" $text]+2}]
It does indeed work correctly. :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Post Reply