]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
[mldonkey_bandwidth] new setting "mldonkey_bandwidth_host"
authorbw1 <redacted>
Tue, 23 Jan 2018 13:20:51 +0000 (14:20 +0100)
committerbw1 <redacted>
Tue, 23 Jan 2018 13:20:51 +0000 (14:20 +0100)
scripts/mldonkey_bandwidth.pl

index 80138bc859d6e613d9a822b6d243014eb8f66d50..c3823950c9ee348807d2ad20c88cc7fc00181325 100644 (file)
@@ -1,13 +1,10 @@
+use strict;
 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";
+
+$VERSION = "20180123";
 %IRSSI = (
        authors         => "Carsten Otto",
        contact         => "c-otto\@gmx.de",
@@ -18,11 +15,15 @@ $VERSION = "20030712";
        changed         => "$VERSION",
        commands        => "mlbw"
 );
+
+Irssi::settings_add_str('mldonkey_bandwidth', 'mldonkey_bandwidth_host' ,'127.0.0.1:4080');
+my $host = Irssi::settings_get_str('mldonkey_bandwidth_host');
+
 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 $req = GET "http://$host/submit?q=bw_stats";
        my $resp = $ua->request($req);
        my $output = $resp->content();
        my $down = $output;
@@ -41,4 +42,10 @@ sub cmd_mlbw
        }
 }
 
+sub cmd_changed
+{
+       $host = Irssi::settings_get_str('mldonkey_bandwidth_host');
+}
+
 Irssi::command_bind('mlbw', 'cmd_mlbw');
+Irssi::signal_add('setup changed', 'cmd_changed'); 
git clone https://git.99rst.org/PROJECT