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.

WHO help

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

WHO help

Post by iamdeath »

Hi, I was trying to assist a user here, while working on his request I am stuck at the middle, WHO mechanism is taken from caesars script it helped me to find out how it works. but for somereasons it's not working fine ;/

Code: Select all

# binds #
bind pub - "!matchip" proc:match
bind raw - 352 who:check

proc proc:match {nick uhost handle channel text} {
global matchip
set matchip $text
putserv "WHO $channel"
}
# who check #
proc who:check {from key arg} {
global matchip
  set chan [lindex $arg 1]
  set nick [lindex $arg 5]
  set uhost *!*@[lindex [split $arg] 3]
  set realname [lrange [lindex [split $arg ":"] 1] 1 end]
  if {[strlwr $matchip] == [strlwr $uhost]} {
  puthelp "PRIVMSG $chan :Found $nick matching your request."
  }
unset matchip
}
The error I am getting is:

Code: Select all

[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:02] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:03] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:03] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:03] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:03] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:03] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
[16:03] <Cricket`-> [14:38] Tcl error [who:check]: can't read "matchip": no such variable
Thanks
iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

could try something like

Code: Select all

set match(ip) ""

proc pub:match {nick host handle channel text} {
global match
 if {$text == ""} {return 0}
  set match(ip) "$text"
   puthelp "WHO $channel"
    return 1
}

proc raw:match {from key text} {
global match
 set chan [lindex $text 1]
  set nick [lindex $text 5]
   set host "*!*@[lindex $text 3]"
    set geos [lrange [lindex [split $text ":"] 1] 1 end]
     if {[strlwr $match(ip)] == [strlwr $host]} {
      puthelp "PRIVMSG $chan :Found $nick matching your request."
     }; set match(ip) ""; return
}

bind pub - !matchip pub:match
bind raw - 352 raw:match

putlog "loaded who.tcl"
return
btw, what ircd is this please?
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Thanks for the reply, it's for Undernet version u2.10.12.12.

Ok the tcl works fine for the first entry but then it halts with no responce, prolly it's not killing set match(ip) properly.

Code: Select all

[23:21] <iamdeath> !matchip *!*@iamdeath.users.undernet.org
[23:21] <Cricket`-> Found iamdeath matching your request.
[23:21] <iamdeath> !matchip *!*@cricket.users.undernet.org
[23:22] <iamdeath> !matchip *!*@cricketbot.users.undernet.org

Thanks
iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Thats gd :oops: wasn't expecting it to work. Since i didn't test it. Thanks for the information on ircd type. use to unrealircd. Try changing

Code: Select all

     }; set match(ip) ""; return 
to

Code: Select all

     }; return 
:) Also, it could be worth removing the return, since that way it would possible just return as many matches as it gets from the /who #channel output.

Code: Select all

     }; 
Like the foreach loop would. using return would brake the loop from the /who #channel

edit; fixed typeo. should of been loop not look.
Last edited by TCL_no_TK on Wed Dec 26, 2007 2:11 am, edited 1 time in total.
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

works fine like this :D

Code: Select all

 }; return 
So far works fine, dont know about the future :P

Thanks alot ;)
iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

no worries. :D glad it worked out.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

You do know that eggdrops already keep a host cached for every chanuser right? :roll:

Code: Select all

bind pub - !matchip pub:match

proc pub:match {nick host handle channel text} {
    if {$text == ""} {
        return;
    }

    foreach user [chanlist $channel] {
        if {[string match -nocase [getchanhost $user] $text]} {
            putserv "PRIVMSG $channel :$user matches $text."
        }
    }
        
}
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Thanks metroid, that was really easy :P.. I never thought of doing that.. thanks alot :)

iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Yeah. Thats a good tip, but i dont relay on it as it only last for as long as wait-split is set for. which for me isn't verry long :?
Post Reply