Updates:

Mata al pato \_O< en el canal #Traffic-Games

Peak

Iniciado por TerraChat, Oct 03, 2023, 09:24 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

TerraChat

bind join - * join:peak
proc join:peak {nick host hand chan} {
   set curnum [llength [chanlist $chan]]
   set peak [getpeak $chan]
   set lastmax [lindex $peak 0]
   if {$curnum > $lastmax} {
        if {$lastmax && ([expr $curnum % 10] == 0)} { puthelp "PRIVMSG $chan  :Novo recorde de usuarios: \002$curnum\002." }
      return [setpeak $chan $curnum [unixtime]]
   }
}

proc getpeak {chan} { global peak
   set chan [string tolower $chan]
   if {[info exists peak($chan)]} {
      set lastmax [lindex $peak($chan) 0]
      set lastdate [lindex $peak($chan) 1]
   } else {
      set fid [open "Clientes/nome/peak.$chan.txt" "RDONLY CREAT"]
      set lastmax "[gets $fid]"
      if {$lastmax == ""} { set lastmax 0 }
      set lastdate "[gets $fid]"
      if {$lastdate == ""} { set lastdate [unixtime] }
      set peak($chan) "$lastmax $lastdate"
      close $fid
   }
   return "$lastmax $lastdate"
}

# Sets peak data to file:
proc setpeak {chan curnum unixtime} { global peak
   set chan [string tolower $chan]
   set peak($chan) "$curnum $unixtime"
   set fid [open "Clientes/nome/peak.$chan.txt" "WRONLY CREAT"]
   puts $fid $curnum
   puts $fid $unixtime
   close $fid
}

# provides the !peak public command:
bind pub - !recorde pub:peak
proc pub:peak {nick host hand chan arg} { set peak [getpeak $chan]
   putcmdlog "<$nick@$chan> !$hand! peak"
   puthelp "privmsg $chan :␃2,0O recorde de usuários ao mesmo tempo nesse canal é de: ␃2,0␟[lindex $peak 0]␟ ␃2,0pessoas! O último recorde era  [timeago [lindex $peak 1]] atraz."
}

proc timeago {lasttime} {
  set totalyear [expr [unixtime] - $lasttime]
  if {$totalyear >= 31536000} {
    set yearsfull [expr $totalyear/31536000]
    set years [expr int($yearsfull)]
    set yearssub [expr 31536000*$years]
    set totalday [expr $totalyear - $yearssub]
  }
  if {$totalyear < 31536000} {
    set totalday $totalyear
    set years 0
  }
  if {$totalday >= 86400} {
    set daysfull [expr $totalday/86400]
    set days [expr int($daysfull)]
    set dayssub [expr 86400*$days]
    set totalhour 0
  }
  if {$totalday < 86400} {
    set totalhour $totalday
    set days 0
  }
  if {$totalhour >= 3600} {
    set hoursfull [expr $totalhour/3600]
    set hours [expr int($hoursfull)]
    set hourssub [expr 3600*$hours]
    set totalmin [expr $totalhour - $hourssub]
     if {$totalhour >= 14400} { set totalmin 0 }
   }
  if {$totalhour < 3600} {
    set totalmin $totalhour
    set hours 0
  }
  if {$totalmin > 60} {
    set minsfull [expr $totalmin/60]
    set mins [expr int($minsfull)]
    set minssub [expr 60*$mins]
    set secs 0
  }
  if {$totalmin < 60} {
    set secs $totalmin
    set mins 0
  }
  if {$years < 1} {set yearstext ""} elseif {$years == 1} {set yearstext "$years ano, "} {set yearstext "$years anos, "}
  if {$days < 1} {set daystext ""} elseif {$days == 1} {set daystext "$days dia, "} {set daystext "$days dias, "}
  if {$hours < 1} {set hourstext ""} elseif {$hours == 1} {set hourstext "$hours hora, "} {set hourstext "$hours horas, "}
  if {$mins < 1} {set minstext ""} elseif {$mins == 1} {set minstext "$mins minuto"} {set minstext "$mins minutos"}
  if {$secs < 1} {set secstext ""} elseif {$secs == 1} {set secstext "$secs segundo"} {set secstext "$secs segundos"}
  set output $yearstext$daystext$hourstext$minstext$secstext
  set output [string trimright $output ", "]
  return $output
}

putlog "␃14Recorde no canal ␂Carregado␂ ␃4By ␂LD_tRuNkSnEt"