Описание
Показывает входищий и исходящий трафик через бота. + Возможность вывести всё через менюшки
Скрипт
on *:START: { $iif(!$hget(traffic),hmake traffic 1) | $iif($exists(channels\traffic.txt),hload traffic channels\traffic.txt) | traffic }
on *:TEXT:*:*: {
if $1 == !traffic { traffic | msg $chan $traffic().info }
}menu menubar,channel,query {
-
Traffic
.View:traffic | echo 10 -a *** $traffic().info
.Say:traffic | msg $active $traffic().info
.-
.!traffic $iif($hget(traffic,trigger),ON,OFF):hadd traffic trigger $iif($hget(traffic,trigger),0,1)
.-
.Clear:hdel traffic in | hdel traffic out | echo 12 -a *** Статистика трафика обнулена
}
alias traffic {
if $prop == info {
hadd traffic msgin $hget(traffic,in) | hadd traffic msginsize байт | hadd traffic msgout $hget(traffic,out) | hadd traffic msgoutsize байт
if $hget(traffic,msgin) > 1024 { hadd traffic msgin $calc($hget(traffic,msgin) / 1024) | hadd traffic msginsize КБ }
if $hget(traffic,msgin) > 1024 { hadd traffic msgin $calc($hget(traffic,msgin) / 1024) | hadd traffic msginsize МБ }
if $hget(traffic,msgout) > 1024 { hadd traffic msgout $calc($hget(traffic,msgout) / 1024) | hadd traffic msgoutsize КБ }
if $hget(traffic,msgout) > 1024 { hadd traffic msgout $calc($hget(traffic,msgout) / 1024) | hadd traffic msgoutsize МБ }
return Входящий трафик: $iif($round($hget(traffic,msgin),2),$ifmatch,0) $+ $hget(traffic,msginsize) $+ ; исходящий трафик: $iif($round($hget(traffic,msgout),2),$ifmatch,0) $+ $hget(traffic,msgoutsize) $+ . Подключен: $uptime(server,1)
}
else {
if !$window(@traffic) { debug -n @traffic | window -h @traffic }
if $line(@traffic,0) {
var %i = 1
while %i <= $line(@traffic,0) {
if $left($line(@traffic,%i),2) == -> { hinc traffic out $len($line(@traffic,%i)) }
elseif $left($line(@traffic,%i),2) == <- { hinc traffic in $len($line(@traffic,%i)) }
inc %i
}
}
close -@ @traffic | debug -n @traffic | window -h @traffic
}
}
on *:DISCONNECT: { traffic | hsave traffic channels\traffic.txt }