-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathupsidedown.pl
68 lines (54 loc) · 1.6 KB
/
upsidedown.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/perl
#
# Irssi plugin to place text upside down
# V0.1 - Initial script - Ivo Schooneman, 08-11-2012
# V0.2 - usay/ume - Ivo Schooneman, 08-11-2012
# V0.3 - decode args 30-01-2019
#
use strict;
use utf8;
use Text::UpsideDown;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "0.3";
%IRSSI = (
authors => "Ivo Schooneman",
contact => "ivo\@schooneman.net",
name => "upsidedown",
description => "Plugin to place text upsidedown",
license => "GNU GPLv2",
url => "https://github.com/Ivo-tje/Irssi-plugin-upsidedown",
);
sub ume {
my ($text, $server, $dest) = @_;
utf8::decode($text);
# Check if connected to server
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
return unless $dest;
if ($dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY") {
$dest->command("me " . upside_down($text));
}
}
sub usay {
my ($text, $server, $dest) = @_;
utf8::decode($text);
# Check if connected to server
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
return unless $dest;
if ($dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY") {
$dest->command("msg " . $dest->{name} . " " . upside_down($text));
}
}
Irssi::command_bind('usay', 'usay');
Irssi::command_bind('ume', 'ume');
if (Irssi::settings_get_str("term_charset") !~ m/utf/i ) {
Irssi::print("%RWarning%n %9$IRSSI{name}:%n no utf8 Terminal (".
Irssi::settings_get_str("term_charset").")",MSGLEVEL_CLIENTCRAP);
}
# vim:set sw=4 ts=8: