# whois.tcl -- replacement for whois via msg, shows additional URL field # added seturl command to set the www field, toolkit must be loaded in order # to user this script. This will probably only work on 0.9tp bots, requires # use of nick2hand. Written by Chad Wagner # # 03-11-96 cmw whois replacement, seturl command, urls command # 03-11-96 cmw fixed a bug or two, added the aka line to whois, # also fixed it so that it should properly pair a handle # with a user. Added in html creating stuff. # # refresh rate, may want to increase/decrease based on system performance #set urls_refresh 15 # lynx/text web browser #set urls_text "users-text.html" bind msg - whois msg_whois bind msg - seturl msg_seturl bind msg - urls msg_urls proc msg_whois {nick uhost hand arg} { global channel set who $arg if {![validuser $who]} { set who [nick2hand $arg] putserv "PRIVMSG $nick :\[$arg\] aka \'$who\'" } if {$who != ""} { set attr "" if {[matchattr $who o]} { append attr " (is an op)" } if {[matchattr $who b]} { append attr " (is a bot)" } if {[matchattr $who m]} { append attr " (is a master)" } if {[getinfo $who] != "" && ![matchattr $who b]} { putserv "PRIVMSG $nick :\[$who\] [getinfo $who]" } if {[onchan [hand2nick $who]]} { putserv "PRIVMSG $nick :\[$who\] On $channel now.$attr" } else { putserv "PRIVMSG $nick :\[$who\] Last seen [ctime [getlaston $who]]$attr" } if {[getemail $who] != ""} { putserv "PRIVMSG $nick :\[$who\] email: [getemail $who]" } if {[user-get $who www] != ""} { putserv "PRIVMSG $nick :\[$who\] URL: [user-get $who www]" } } else { putserv "PRIVMSG $nick :\[$who\] No user record." } return 1 } proc msg_seturl {nick uhost hand arg} { if {$hand != "*"} { if {$arg != ""} { if {$arg == "none"} { putserv "PRIVMSG $nick :Remove your URL line." user-set $hand www "" } { putserv "PRIVMSG $nick :Now: [html_fix $arg]" user-set $hand www "[html_fix $arg]" } } { if {[user-get $hand www] == ""} { putserv "PRIVMSG $nick :You have no URL set." } { putserv "PRIVMSG $nick :Now: [user-get $hand www]" } } } else { putserv "PRIVMSG $nick :You must be a registered user to use this feature." } return 1 } proc msg_urls {nick uhost hand arg} { foreach i [userlist] { if {![matchattr $i b] && [user-get $i www] != ""} { putserv "PRIVMSG $nick :\[$i\] URL: [user-get $i www]" } } return 1 } proc urls_web {} { global home-channel botnick urls_text urls_refresh if {![info exists urls_text]} {return 1} set fd [open $urls_text w] puts $fd "Users of ${home-channel}" puts $fd "

${home-channel}

"

   puts $fd "   Nickname  E-mail               Homepage"

   foreach i [userlist] {
      if {![matchattr $i b]} {
         set info [getinfo $i]
         set www [user-get $i www]
         set email [getemail $i]

         if {($email != "") && ([string first @ $email] > 0)} {
            set link_email ""
            set end_email ""
         } {
            set link_email ""
            set end_email ""
         }

         if {$www != ""} {
            if {[string compare [string range $www 0 6] "http://"] == 0} {
               set link_www ""
               set end_www ""
            } {
               set link_www ""
               set end_www ""
            }
         } {
            set link_www ""
            set end_www ""
         }

         if {[string length $email] > 20} {set email "email"}
         if {[string length $www] > 40} {set www "homepage"}


         if {$email != "" || $www != ""} {
            puts $fd "   [format "%-9s ${link_email}%-20s${end_email} ${link_www}%s${end_www}" $i [html_fix $email] [html_fix $www]]"
         }
      }
   }

   puts $fd "
" close $fd timer $urls_refresh urls_web return 1 } proc html_fix {arg} { if {[string first < $arg] != -1} { set www [lindex [split $arg <] 1] } { set www $arg } if {[string first > $www] != -1} { set www [lindex [split $www >] 0] } { set www $www } return $www } if {![info exists urls_web_running] && [info exists urls_refresh]} { set urls_web_running 1 timer $urls_refresh urls_web }