Last active
August 29, 2015 14:11
-
-
Save bigbosst/7f0a8ef8809cb10e70e5 to your computer and use it in GitHub Desktop.
irssi memes function
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
# memes.pl | |
use strict; | |
use warnings; | |
use LWP::Simple; | |
use Irssi; | |
our $VERSION = '1.0'; | |
our %IRSSI = ( | |
author => 'Troy Germain', | |
contact => 'troy.germain@gmail.com', | |
name => 'memes', | |
description => 'grabs gif from memes.bz', | |
license => 'GPL', | |
); | |
Irssi::command_bind( memes => sub { | |
my ($msg, $server, $win) = @_; | |
my $url; | |
if ($url = get "http://memes.bz/search/$msg") { | |
if ($win && ($win->{type} eq 'CHANNEL' || $win->{type} eq 'QUERY')) { | |
$win->command("MSG $win->{name} $url"); | |
} | |
else { | |
print CLIENTCRAP "meme: $url"; | |
}; | |
} | |
else { | |
print CLIENTCRAP 'Error connecting to memes.bz'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment