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.

nick check

Old posts that have not been replied to for several years.
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

Hi

The purpose of my question wasnt primarily anything to do with accessing the userlist of the bot, but as a secondary function it would be useful.

The checking whether a nick is online script i was trying to write is to provide information about a particular user. So someone can type:

/msg bot userinfo nick

and the bot would give them basic details like nick, uhost etc. I wanted to make a check so that if there was no such nick, an error message would be noticed back to the person who requested the info.

egghead's idea did actually work and i now have this script working properly.

On the other note, in my bot no user hostmasks are permanently stored in the userfile. When a user comes online they issue a:

/msg bot login handle password

command which adds there whole hostmask temporatily to there record. If they dont join a channel which the bot is in within a certain amount of time the user is logged out and this hostmask is removed from the userfile. Otherwise either leaving a channel or manually logging out will do the same thing. Because im using a temporary but full hostmask i can use the nick2hand function securely to give the user access to the bots functions, but only after they have logged in. This method seems more secure than automatically recognising users via a hostmask.

---

ok, now i have that working i was wondering if it was possible to expand this a little.

If i were to want to display information from more than one raw command. Such as gathering whether the nick is online and displaying

nick: nickname

then gathering information from a /whois on the user to display there ip address, or which server theyre on etc. So it would show:

info on nick:
nick: nickname
address: hostmask
server: irc.blah.net

etc

is this possible?

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

Post by stdragon »

Yes it's completely possible. Look up the whois command and it will tell you the numeric replies and what they mean. Or simply telnet to an irc server and look at the output for yourself.. that is usually easier.
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

ok yes i know the specific numeric replies, what i mean is, at present im telling the bind to catch raw 303, if i wanted to catch more than one bind numeric, and output the results as one list inside one proc, how can it be done?

Simon
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

simonbell wrote:ok yes i know the specific numeric replies, what i mean is, at present im telling the bind to catch raw 303, if i wanted to catch more than one bind numeric, and output the results as one list inside one proc, how can it be done?

Simon
An example of how it can be done.

Upon sending the WHOIS request create an global array "information($nick)" with the time in it when the WHOIS request was send out and the name of the requester.

Upon receiving each of the associated numeric replies: check if a request is pending for the $nick mentioned in the numeric reply, if so add the response the global array "information($nick)". Upon receiving the terminating numeric, e.g. 318 RPL_ENDOFWHOIS, return the information stored in the array for $nick.
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

ok this is as far as ive gotten and i think ive probably completely mucked up here somewhere because i dont even get an error message when i try running the script but here it is:

proc msg_userinfo {nick uhost hand arg} {
set nick_requested [lindex $arg 0]
putserv "ISON $nick $nick_requested"
}

proc rawnickinfo {from keyw arg} {
set reqwithcolon [lindex $arg 1]
set reqnick [lindex $arg 2]
set req [string range $reqwithcolon 1 end]
if { $reqnick == "" } {
putnotc $req "Error: User with that nick is offline"
return 0
}
putserv "WHOIS $reqnick"
set userinfoarray("$reqnick") "[unixtime] $req"
}

proc rawwhoisuser {from keyw arg} {
global userinfoarray
set whoisusernick [lindex $arg 1]
if { [array exists $whoisusernick] == 1 } {
set whoisuseruser [lindex $arg 2]
set whoisuserhost [lindex $arg 3]
set whoisuseruhost "$whoisuseruser@$whoisuserhost"
set whoisuserhand [finduser $whoisusernick!$whoisuseruser@$whoisuserhost]
set userinfoarray($whoisusernick) "Nick: $whoisusernick"
set userinfoarray($whoisusernick) "Address: $whoisuseruhost"
if { $whoisuserhand != "*" } {
set whoisuserinfo [getuser $whoisuserhand INFO]
if { ($whoisuserinfo != "") || ($whoisuserinfo != "*") } {
set userinfoarray($whoisusernick) "Info: $whoisuserinfo"
}
}
}
}

proc rawmodes {from keyw arg} {
global userinfoarray
set rawmodenick [lindex $arg 1]
if { [array exists $rawmodenick] == 1 } {
set rawmodemode [lindex $arg 5]
set userinfoarray($rawmodenick) "Modes: $rawmodemoe"
}
}

proc rawwhoisserver {from keyw arg} {
global userinfoarray
set rawservernick [lindex $arg 1]
if { [array exists $rawservernick] == 1 } {
set rawserverserver [lindex $arg 2]
set userinfoarray($rawservernick) "Server: $rawserverserver"
}
}

proc rawwhoischans {from keyw arg} {
global userinfoarray
set rawchannick [lindex $arg 1]
if { [array exists $rawchannick] == 1 } {
set rawchanchans [lrange $arg 2 end]
set userinfoarray($rawchannick) "Channels: $rawchanchans"
}
}

proc rawendofwhois {from keyw arg} {
global userinfoarray
set rawendnick [lindex $arg 1]
if { [array exists $rawendnick] == 1 } {
putlog "$userinfoarray($rawendnick)"
}
}
# End of userinfo

any advise appreciated thanks.

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

Post by stdragon »

If you don't see an error message, then you need to add debugging statements to find out where the flaw is.

Add putlogs to the part where the request is formed and where the server response is received. That's a start.
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

egghead: what exactly did you mean by 'check if a request is pending'? cant say i know how to do that.

I have found the first problem. If i use a putlog, i can output the names of the array after i have set it using the
array names arrayname
command, and this does output the names in the array. However, if i try this in the next part of the script, it does not do anything, but i know its reaching this part of the script by putting a putlog "test" just above the command to retrieve the array.

So as far as i can see, this part of the script is working:
proc rawnickinfo {from keyw arg} {
set reqwithcolon [lindex $arg 1]
set reqnick [lindex $arg 2]
set req [string range $reqwithcolon 1 end]
if { $reqnick == "" } {
putnotc $req "Error: User with that nick is offline"
return 0
}
putserv "WHOIS $reqnick"
set userinfoarray("$reqnick") "[unixtime] $req"
}
and this part is not:
proc rawwhoisuser {from keyw arg} {
global userinfoarray
set whoisusernick [lindex $arg 1]
if { [array exists $whoisusernick] == 1 } {
etc
i think that when i set the array in the first proc is isnt becoming global, or when i do "global userinfoarray" in the 2nd proc, ive done something wrong. As far as i can see when looking at the SUNiNET tcl tutorials ive done it correctly so im at a bit of a dead end.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You have to use 'global' in the first proc as well, otherwise the array will be created locally.
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

ok that worked thanks. Now is it possible to use arrays in the form of

set arrayname(bob) "info"
set arrayname(bob) "other info"

which would store 2 items in (bob) or would i have to do it a different way?

~ Simon
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

That will just overwrite it. You could either make 2 entries arrayname(bob,1) arrayname(bob,2) or use a list, like set arrayname(bob)
  • .

    Commas are good for the multiple entries because nicks can't contain commas.
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

one last problem. I have the script working now. However, when it comes to listing channels using this part of the script:
foreach chanout $chanremrbrak {
putnotc $userreqnick "Listing channels that $rawendnick is on:"
putnotc $userreqnick "$chanout"
putnotc $userreqnick "End of user info"
}
i get the following output:
-H4- Listing channels that bob is on:
-H4- @#MillsNet
-H4- End of user info
-H4- *#TheLight
So, the question is, how can i get the bot to wait for the last channel to be listed before outputting "End of user info"

~ Simon
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

ive also noticed another small problem. If the person that the whois is on is in a channel, the script executes ok. However, if the person is not on any channels, nothing happens. Ive narrowed this down to the endofwhois raw bind using:
bind raw - 319 rawendofwhois
proc rawendofwhois {from keyw arg} {
putlog "test"
}
When the person is not in a channel, the bind is not triggered at all. Is there a different raw numeric when doing a whois on someone who is not in a channel or something?

~ Simon
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

simonbell wrote:... another small problem... Ive narrowed this down to the endofwhois raw bind using:

Code: Select all

bind raw - 319 rawendofwhois
proc rawendofwhois {from keyw arg} {
 putlog "test"
}
You will need to check RFC 1459 for the numerics. 319 is a different reply from 318 :)
Locked