home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz KrOnIcKLeZ 3 / HaCKeRz_KrOnIcKLeZ.iso / scriptz / floyd_se.tcl < prev    next >
Text File  |  1996-04-23  |  9KB  |  287 lines

  1. #
  2. # simple implementation of the 'seen' command for eggdrop
  3. # by Robey, 19mar95
  4. # v2  4may95
  5. # v3 eden 29sep95 - won't show seen if tandem-bot is on channel to do it
  6. # v4 cmwagner@gate.net 25jan96 - msg/dcc interface instead of public,
  7. #                                tandem-nick removed, since it is now a
  8. #                                private interface, instead of public
  9. # v4.1 cmwagner@gate.net 26mar96 - modified for eggdrop1.0
  10. # v4.2 cmwagner@gate.net 26mar96 - ok, actually works now, I think.  <grin>
  11. # v4.3 floydman@netaxs.com 29mar96 - added public access to seen.
  12. # v4.4 floydman@netaxs.com 7apr96 - Changed the format of the reply from
  13. #                                   the bot...to give No. of years, days,
  14. #                                   hours, and minutes since somebody was
  15. #                                   last on.
  16.  
  17. bind pub - !seen pub_seen
  18. bind msg - seen msg_seen
  19. bind dcc - seen cmd_seen
  20.  
  21. proc pub_seen {nick uhost hand channel args} {
  22.   global botnick
  23.   set who [string trim [lindex $args 0] ?]
  24.   if {[string compare [string tolower $botnick] [string tolower $who]] == 0} {
  25.     putchan $channel "$nick :Yeah, whenever I look in a mirror..."
  26.    return 1
  27.   }
  28.   if {[string compare [string tolower $nick] [string tolower $who]] == 0} {
  29.     putchan $channel "$nick :Trying to find yourself, eh?"
  30.     return 1
  31.   }
  32.   foreach j [channels] {
  33.     if {[onchansplit $who $j]} {
  34.       putchan $channel "$nick :$who was just on $j, but got netsplit"
  35.       return 1
  36.     }
  37.     if {[onchan $who $j]} {
  38.       putchan $channel "$nick :$who is on $j right now"
  39.       return 1
  40.     }
  41.     foreach i [chanlist $j] {
  42.       set hand [finduser $i![getchanhost $i $j]]
  43.       if {($hand != "*") && ([string compare [string tolower $hand] [string tolower $who]] == 0)} {
  44.         if {[onchansplit $i $j]} {
  45.           putchan $channel "$nick :$i is $who, and $i was just on $j but got net-split"
  46.         } {
  47.           if {[onchan $i $j]} {
  48.             putchan $channel "$nick :$i is $who, and $i is on $j right now!"
  49.           }
  50.         }
  51.         return 1
  52.       }
  53.     }
  54.   }
  55.   if {[validuser $who]} {
  56.     set lasttime [getlaston $who]
  57.     if {$lasttime == 0} {
  58.       putchan $channel "$nick :$who has never been here."
  59.       return 1
  60.     }
  61.     set totalyear [expr [unixtime] - $lasttime]
  62.     if {$totalyear > 31536000} {
  63.       set yearsfull [expr $totalyear/31536000]
  64.       set years [expr int($yearsfull)]
  65.       set yearssub [expr 31536000*$years]
  66.       set totalday [expr $totalyear - $yearssub] 
  67.     }
  68.     if {$totalyear < 31536000} {
  69.       set totalday $totalyear
  70.       set years 0
  71.     }
  72.     if {$totalday > 86400} {
  73.       set daysfull [expr $totalday/86400]
  74.       set days [expr int($daysfull)]
  75.       set dayssub [expr 86400*$days]
  76.       set totalhour [expr $totalday - $dayssub] 
  77.     }
  78.     if {$totalday < 86400} {
  79.       set totalhour $totalday
  80.       set days 0
  81.     }
  82.     if {$totalhour > 3600} {
  83.       set hoursfull [expr $totalhour/3600]
  84.       set hours [expr int($hoursfull)]
  85.       set hourssub [expr 3600*$hours]
  86.       set totalmin [expr $totalhour - $hourssub] 
  87.     }
  88.     if {$totalhour < 3600} {
  89.       set totalmin $totalhour
  90.       set hours 0
  91.     }
  92.     if {$totalmin > 60} {
  93.       set minsfull [expr $totalmin/60]
  94.       set mins [expr int($minsfull)]
  95.     }
  96.     if {$totalmin < 60} {
  97.       putchan $channel "$nick :$who left $channel less then a minute ago."
  98.       return 1
  99.     }
  100.     if {$years < 1} then {set yearstext ""} else {set yearstext "$years years, "}
  101.     if {$days < 1} then {set daystext ""} else {set daystext "$days days, "}
  102.     if {$hours < 1} then {set hourstext ""} else {set hourstext "$hours hours, "}
  103.     putchan $channel "$nick :$who was last here $yearstext$daystext$hourstext$mins minutes ago"
  104.     return 1
  105.   }
  106.   putchan $channel "$nick :I don't know who $who is."
  107. }
  108.  
  109. proc msg_seen {nick uhost hand args} {
  110.   global botnick
  111.  
  112.   set who [string trim [lindex $args 0] ?]
  113.   if {[string compare [string tolower $botnick] [string tolower $who]] == 0} {
  114.     putserv "PRIVMSG $nick :Yeah, whenever I look in a mirror..."
  115.     return 1
  116.   }
  117.   if {[string compare [string tolower $nick] [string tolower $who]] == 0} {
  118.     putserv "PRIVMSG $nick :Trying to find yourself, eh?"
  119.     return 1
  120.   }
  121.   foreach j [channels] {
  122.     if {[onchansplit $who $j]} {
  123.       putserv "PRIVMSG $nick :$who was just on $j, but got netsplit"
  124.       return 1
  125.     }
  126.     if {[onchan $who $j]} {
  127.       putserv "PRIVMSG $nick :$who is on $j right now!"
  128.       return 1
  129.     }
  130.     foreach i [chanlist $j] {
  131.       set hand [finduser $i![getchanhost $i $j]]
  132.       if {($hand != "*") && ([string compare [string tolower $hand] [string tolower $who]] == 0)} {
  133.         if {[onchansplit $i $j]} {
  134.           putserv "PRIVMSG $nick :$i is $who, and $i was just on $j but got net-split"
  135.         } {
  136.           if {[onchan $i $j]} {
  137.             putserv "PRIVMSG $nick :$i is $who, and $i is on $j right now!"
  138.           }
  139.         }
  140.         return 1
  141.       }
  142.     }
  143.   }
  144.   if {[validuser $who]} {
  145.     set lasttime [getlaston $who]
  146.     if {$lasttime == 0} {
  147.       putserv "PRIVMSG $nick :$who has never been here."
  148.       return 1
  149.     }
  150.     set totalyear [expr [unixtime] - $lasttime]
  151.     if {$totalyear > 31536000} {
  152.       set yearsfull [expr $totalyear/31536000]
  153.       set years [expr int($yearsfull)]
  154.       set yearssub [expr 31536000*$years]
  155.       set totalday [expr $totalyear - $yearssub]
  156.     }
  157.     if {$totalyear < 31536000} {
  158.       set totalday $totalyear
  159.       set years 0
  160.     }
  161.     if {$totalday > 86400} {
  162.       set daysfull [expr $totalday/86400]
  163.       set days [expr int($daysfull)]
  164.       set dayssub [expr 86400*$days]
  165.       set totalhour [expr $totalday - $dayssub]
  166.     }
  167.     if {$totalday < 86400} {
  168.       set totalhour $totalday
  169.       set days 0
  170.     }
  171.     if {$totalhour > 3600} {
  172.       set hoursfull [expr $totalhour/3600]
  173.       set hours [expr int($hoursfull)]
  174.       set hourssub [expr 3600*$hours]
  175.       set totalmin [expr $totalhour - $hourssub]
  176.     }
  177.     if {$totalhour < 3600} {
  178.       set totalmin $totalhour
  179.       set hours 0
  180.     }
  181.     if {$totalmin > 60} {
  182.       set minsfull [expr $totalmin/60]
  183.       set mins [expr int($minsfull)]
  184.     }
  185.     if {$totalmin < 60} {
  186.       putchan $channel "$nick :$who left $channel less then a minute ago."
  187.       return 1
  188.     }
  189.     if {$years < 1} then {set yearstext ""} else {set yearstext "$years years, "}
  190.     if {$days < 1} then {set daystext ""} else {set daystext "$days days, "}
  191.     if {$hours < 1} then {set hourstext ""} else {set hourstext "$hours hours, "}
  192.     putserv "PRIVMSG $nick :$who was last here $yearstext$daystext$hourstext$mins minutes ago"
  193.  
  194.     return 1
  195.   }
  196.   putserv "PRIVMSG $nick :I don't know who $who is."
  197. }
  198.  
  199. proc cmd_seen {hand idx args} {
  200.   global botnick
  201.  
  202.   set who [string trim [lindex $args 0] ?]
  203.   if {[string compare [string tolower $botnick] [string tolower $who]] == 0} {
  204.     putdcc $idx "Yeah, whenever I look in a mirror..."
  205.     return 1
  206.   }
  207. #  if {[string compare [string tolower [idx2hand $idx]] [string tolower $who]] == 0} {
  208. #    putdcc $idx "Trying to find yourself, eh?"
  209. #    return 1
  210. #  }
  211.   foreach j [channels] {
  212.     if {[onchansplit $who $j]} {
  213.       putdcc $idx "$who was just on $j, but got netsplit"
  214.       return 1
  215.     }
  216.     if {[onchan $who $j]} {
  217.       putdcc $idx "$who is on $j right now!"
  218.       return 1
  219.     }
  220.     foreach i [chanlist $j] {
  221.       set hand [finduser $i![getchanhost $i $j]]
  222.       if {($hand != "*") && ([string compare [string tolower $hand] [string tolower $who]] == 0)} {
  223.         if {[onchansplit $i $j]} {
  224.           putdcc $idx "$i is $who, and $i was just on $j but got net-split"
  225.         } {
  226.           if {[onchan $i $j]} {
  227.             putdcc $idx "$i is $who, and $i is on $j right now!"
  228.           }
  229.         }
  230.         return 1
  231.       }
  232.     }
  233.   }
  234.   if {[validuser $who]} {
  235.     set lasttime [getlaston $who]
  236.     if {$lasttime == 0} {
  237.       putdcc $idx "$who has never been here."
  238.       return 1
  239.     }
  240.     set totalyear [expr [unixtime] - $lasttime]
  241.     if {$totalyear > 31536000} {
  242.       set yearsfull [expr $totalyear/31536000]
  243.       set years [expr int($yearsfull)]
  244.       set yearssub [expr 31536000*$years]
  245.       set totalday [expr $totalyear - $yearssub]
  246.     }
  247.     if {$totalyear < 31536000} {
  248.       set totalday $totalyear
  249.       set years 0
  250.     }
  251.     if {$totalday > 86400} {
  252.       set daysfull [expr $totalday/86400]
  253.       set days [expr int($daysfull)]
  254.       set dayssub [expr 86400*$days]
  255.       set totalhour [expr $totalday - $dayssub]
  256.     }
  257.     if {$totalday < 86400} {
  258.       set totalhour $totalday
  259.       set days 0
  260.     }
  261.     if {$totalhour > 3600} {
  262.       set hoursfull [expr $totalhour/3600]
  263.       set hours [expr int($hoursfull)]
  264.       set hourssub [expr 3600*$hours]
  265.       set totalmin [expr $totalhour - $hourssub]
  266.     }
  267.     if {$totalhour < 3600} {
  268.       set totalmin $totalhour
  269.       set hours 0
  270.     }
  271.     if {$totalmin > 60} {
  272.       set minsfull [expr $totalmin/60]
  273.       set mins [expr int($minsfull)]
  274.     }
  275.     if {$totalmin < 60} {
  276.       putdcc $idx "$who left $channel less then a minute ago."
  277.       return 1
  278.     }
  279.     if {$years < 1} then {set yearstext ""} else {set yearstext "$years years, "}
  280.     if {$days < 1} then {set daystext ""} else {set daystext "$days days, "}
  281.     if {$hours < 1} then {set hourstext ""} else {set hourstext "$hours hours, "}
  282.     putdcc $idx "$who was last here $yearstext$daystext$hourstext$mins minutes ago"
  283.     return 1
  284.   }
  285.   putdcc $idx "I don't know who $who is."
  286. }
  287.