egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

whois info [SOLVED]

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
AskMe
Voice


Joined: 11 Apr 2007
Posts: 23
Location: Canada

PostPosted: Mon Jun 11, 2007 4:53 pm    Post subject: whois info [SOLVED] Reply with quote

in MIRC when i do a whois i reveice this info
Code:

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 Wink

thanks


Last edited by AskMe on Tue Jun 12, 2007 1:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jun 11, 2007 6:31 pm    Post subject: Reply with quote

Raw 311, use the raw-bind to catch it.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
AskMe
Voice


Joined: 11 Apr 2007
Posts: 23
Location: Canada

PostPosted: Mon Jun 11, 2007 9:38 pm    Post subject: Reply with quote

i need a little help on that

Code:

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


i receive this
Code:

TEST {botnick nick ~bla myhost.com  * :www.mysitecom/?u=1234}


anyone can help me to just have this info please?
Code:

www.mysitecom/?u=1234
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Jun 11, 2007 9:59 pm    Post subject: Reply with quote

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:
set i [expr [string first " :" $text] + 1]
set info [string range $text $i end]

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
AskMe
Voice


Joined: 11 Apr 2007
Posts: 23
Location: Canada

PostPosted: Mon Jun 11, 2007 10:34 pm    Post subject: Reply with quote

ok its getting better now but not perfect Wink

Code:

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:

TEST :www.mysitecom/?u=1234


now i need to remove the : at the begining of :www.mysitecom/?u=1234
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Jun 12, 2007 12:32 am    Post subject: Reply with quote

May be try:
Code:
[string trim [join [lrange $text $i end]] :]

_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
AskMe
Voice


Joined: 11 Apr 2007
Posts: 23
Location: Canada

PostPosted: Tue Jun 12, 2007 12:59 am    Post subject: Reply with quote

Alchera wrote:
May be try:
Code:
[string trim [join [lrange $text $i end]] :]


not working...

result
Code:

TEST
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Jun 12, 2007 5:08 am    Post subject: Reply with quote

Code:
set info [string trimleft [string range $text $i end] :]

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Tue Jun 12, 2007 7:10 am    Post subject: Reply with quote

why not
Code:
set i [expr {[string first ":" $text]+1}]
?
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jun 12, 2007 8:41 am    Post subject: Reply with quote

Actually, the flaw is that I added 1 and not 2 to the offset. (Forgot I matched 2 characters rather than 1) Embarassed
Should work as intended
Code:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Jun 12, 2007 8:53 am    Post subject: Reply with quote

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

Typo Razz

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
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jun 12, 2007 9:15 am    Post subject: Reply with quote

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 Razz

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Jun 12, 2007 9:32 am    Post subject: Reply with quote

Quote:
[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. Laughing

XChat snippet:
Code:
# 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. Laughing
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
AskMe
Voice


Joined: 11 Apr 2007
Posts: 23
Location: Canada

PostPosted: Tue Jun 12, 2007 1:20 pm    Post subject: Reply with quote

Sir_Fz wrote:
Code:
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) Embarassed
Should work as intended
Code:
set i [expr [string first " :" $text] + 2]
set info [string range $text $i end]


This one works great too

user wrote:
why not
Code:
set i [expr {[string first ":" $text]+1}]
?

didnt work.. they give me this result
Code:
TEST 0


so if anyone need the info you can use
Code:
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:
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:
TEST www.mysitecom/?u=1234


thanks to all for your help Wink
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Jun 12, 2007 7:44 pm    Post subject: Reply with quote

AskMe: user's hint was based on what nml375 posted before it was fixed:
Code:
set i [expr {[string first " :" $text]+2}]

It does indeed work correctly. Smile
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber