summaryrefslogtreecommitdiffstats
path: root/scripts/tinyurl.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
commit03929dac2a29664878d2c971648a4fe1fb698462 (patch)
tree02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/tinyurl.pl
parentInitial commit. (diff)
downloadirssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.tar.xz
irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.zip
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/tinyurl.pl')
-rw-r--r--scripts/tinyurl.pl47
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/tinyurl.pl b/scripts/tinyurl.pl
new file mode 100644
index 0000000..30e4b5b
--- /dev/null
+++ b/scripts/tinyurl.pl
@@ -0,0 +1,47 @@
+#
+# by Atoms
+
+use strict;
+use WWW::Shorten::TinyURL;
+use WWW::Shorten 'TinyURL';
+
+use vars qw($VERSION %IRSSI);
+
+use Irssi qw(command_bind active_win);
+$VERSION = '1.1';
+%IRSSI = (
+ authors => 'Atoms',
+ contact => 'atoms@tups.lv',
+ patch => 'spowers@dimins.com',
+ name => 'tinyurl',
+ description => 'create a tinyurl from a long one',
+ license => 'GPL',
+);
+
+command_bind(
+ tinyurl => sub {
+ my ($msg, $server, $witem) = @_;
+ my $answer = tinyurl($msg);
+
+ if ($answer) {
+ print CLIENTCRAP "$answer";
+
+ if ($witem && ($witem->{type} eq 'CHANNEL' || $witem->{type} eq 'QUERY')) {
+ $witem->command("MSG " . $witem->{name} ." ". $answer);
+ }
+ }
+ }
+);
+
+sub tinyurl {
+ my $url = shift;
+
+ my $res = makeashorterlink($url);
+
+ if (defined $res) {
+ return $res;
+ } else {
+ print CLIENTCRAP "ERROR: tinyurl: tinyurl is down or not pingable";
+ return "";
+ }
+}