aboutsummaryrefslogtreecommitdiffstats
path: root/server_status/server_status.pl
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-09-04 12:25:58 +0000
committerterminaldweller <devi@terminaldweller.com>2023-09-04 12:25:58 +0000
commitdc69b76f99650b23256a5e9609c11465f6a6b90c (patch)
tree8515c799401abb48af841e5b3c3ab3cf4d82e2c4 /server_status/server_status.pl
parentadded a trivia script (diff)
downloadirssi-scripts-dc69b76f99650b23256a5e9609c11465f6a6b90c.tar.gz
irssi-scripts-dc69b76f99650b23256a5e9609c11465f6a6b90c.zip
added a new script server_status.pl
Diffstat (limited to '')
-rw-r--r--server_status/server_status.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/server_status/server_status.pl b/server_status/server_status.pl
new file mode 100644
index 0000000..0639991
--- /dev/null
+++ b/server_status/server_status.pl
@@ -0,0 +1,32 @@
+use Irssi;
+use strict;
+
+my $server_status_count = "";
+my $timeout;
+
+Irssi::settings_add_int('misc', 'server_status_count_freq', 100000);
+
+sub server_status {
+ Irssi::timeout_remove($timeout);
+ my $connected_count = 0;
+ my $unconnected_count = 0;
+
+ for my $server (Irssi::servers()) {
+ if ($server->{'connected'}) {
+ $connected_count++;
+ } else {
+ $unconnected_count++;
+ }
+ }
+
+ $server_status_count = $connected_count."/".$unconnected_count;
+
+ $timeout = Irssi::timeout_add_once(Irssi::settings_get_int('server_status_count_freq'), 'server_status' , undef);
+}
+
+Irssi::expando_create('server_status_count', sub {
+ return $server_status_count;
+}, {});
+
+$timeout = Irssi::timeout_add(Irssi::settings_get_int('server_status_count_freq'), 'server_status' , undef);
+server_status();