summaryrefslogtreecommitdiffstats
path: root/scripts/mldonkey_bandwidth.pl
diff options
context:
space:
mode:
authorAlexander Færøy2014-05-31 13:10:46 +0200
committerAlexander Færøy2014-05-31 13:10:46 +0200
commit2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 (patch)
tree1c5e6d817c88e67b46e216a50e0aef5428bf63df /scripts/mldonkey_bandwidth.pl
parent2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff)
downloadscripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/mldonkey_bandwidth.pl')
-rw-r--r--scripts/mldonkey_bandwidth.pl44
1 files changed, 44 insertions, 0 deletions
diff --git a/scripts/mldonkey_bandwidth.pl b/scripts/mldonkey_bandwidth.pl
new file mode 100644
index 0000000..80138bc
--- /dev/null
+++ b/scripts/mldonkey_bandwidth.pl
@@ -0,0 +1,44 @@
+require LWP::UserAgent;
+use Irssi;
+use HTTP::Request::Common;
+use strict;
+use vars qw($VERSION %IRSSI);
+######################
+my $ip = "127.0.0.1";
+#enter mldonkey's IP here and make sure you are allowed to connect!
+######################
+$VERSION = "20030712";
+%IRSSI = (
+ authors => "Carsten Otto",
+ contact => "c-otto\@gmx.de",
+ name => "mldonkey bandwidth script",
+ description => "Shows your mldonkey's current down- and upload rate",
+ license => "GPLv2",
+ url => "http://www.c-otto.de",
+ changed => "$VERSION",
+ commands => "mlbw"
+);
+sub cmd_mlbw
+{
+ my ($args, $server, $target) = @_;
+ my $ua = LWP::UserAgent->new(timeout => 5);
+ my $req = GET "http://$ip:4080/submit?q=bw_stats";
+ my $resp = $ua->request($req);
+ my $output = $resp->content();
+ my $down = $output;
+ my $up = $output;
+ $down =~ s/.*Down: ([0-9]*\.*[0-9]) KB.*/$1/s;
+ $up =~ s/.*Up: ([0-9]*\.*[0-9]) KB.*/$1/s;
+ if ($down eq "") { $down = "(off)"; }
+ if ($up eq "") { $up = $down; }
+ $output = "-MLdonkey bandwidth stats- Down: $down - Up: $up";
+ if (!$server || !$server->{connected} || !$target)
+ {
+ Irssi::print $output;
+ } else
+ {
+ Irssi::active_win() -> command('say ' . $output);
+ }
+}
+
+Irssi::command_bind('mlbw', 'cmd_mlbw');