Created
February 25, 2016 10:27
-
-
Save OniDaito/44426eb24eb852396eba to your computer and use it in GitHub Desktop.
Cheeky IRSSI Level Bar Graph Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use Irssi; | |
use Irssi::Irc; | |
use vars qw($VERSION %IRSSI); | |
use POSIX; | |
sub grapher { | |
my($level, $server, $dest) = @_; | |
if (!$server || !$server->{connected}) { | |
Irssi::print("Not connected to server"); | |
return; | |
} | |
return unless $dest; | |
if ($level < 0){ | |
$level = 0; | |
} | |
if ($level > 100) { | |
$level = 100; | |
} | |
my $graph_width = 10; | |
my $block_level = floor($level / 100 * $graph_width); | |
my $i = 0; | |
my $msg = ""; | |
for ($i = 0; $i < $block_level; $i += 1){ | |
$msg = $msg . "▓"; | |
} | |
for ($i = $block_level; $i < $graph_width; $i +=1 ){ | |
$msg = $msg . "░"; | |
} | |
my $suffix =" %"; | |
$msg = $msg . " " . $level . $suffix; | |
if ($dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY") { | |
$dest->command("/msg " . $dest->{name} . " " . $msg); | |
} | |
} | |
Irssi::command_bind grapher => \&grapher; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment