; Alias to convert bytes to a human-readable format
alias filesize_pretty {
if (($1 !isnum) || ($1 < 0)) { return n/a }
if ($round($calc($1 / 1073741824),1) >= 1) { return $round($calc($1 / 1073741824),1) GB }
if ($round($calc($1 / 1048576),1) >= 1) { return $round($calc($1 / 1048576),1) MB }
if ($round($calc($1 / 1024),1) >= 1) { return $round($calc($1 / 1024),1) KB }
return $int($1) Bytes
}
on ^*:getfail:*: file_done getf
on ^*:filercvd:*: file_done get
on ^*:sendfail:*: file_done sendf
on ^*:filesent:*: file_done send
alias file_done {
if (get* iswm $1) {
; Variables
var %filename = $nopath($get(-1).file)
var %filesize = $get(-1).size
var %size_readable = $filesize_pretty(%filesize)
var %timestamp = $time(HH:nn:ss) - $date(DD/mm/yyyy)
var %filesreceived = $iif($hget(filesreceived, count),$hget(filesreceived, count),0)
; Incrementar el contador de archivos recibidos
inc %filesreceived
hadd -m filesreceived count %filesreceived
; Mensaje de agradecimiento con colores aleatorios
msg #TRAFFIC ␂File received␂:␃ $+ $rand(1,7) %filename ␃␂Size␂:␃ $+ $rand(1,7) %size_readable ␃␂Received␂:␃ $+ $rand(1,7) $time(HH:nn:ss) ␃␂Total files received␂:␃ $+ $rand(1,7) %filesreceived
}
}
; Mostrar el contador de archivos recibidos al usuario cuando se conecta
on *:CONNECT: {
var %filesreceived = $iif($hget(filesreceived, count),$hget(filesreceived, count),0)
echo -a Hasta ahora has recibido %filesreceived archivos.
}