Last active
July 2, 2020 23:18
-
-
Save thatfunkymunki/b8028d4f2313612b36e2c1a44230809f to your computer and use it in GitHub Desktop.
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 LWP::UserAgent; | |
our $VERSION = '1.0'; | |
our %IRSSI = ( | |
authors => 'munki', | |
contact => '[email protected]', | |
name=> 'troll-as-a-service', | |
description=> 'spits out a string from my webapp', | |
license=>'MIT', | |
url=>'http://github.com/thatfunkymunki', | |
changed=>'05-23-2017 2005' | |
); | |
sub troll{ | |
my ($data, $server, $witem) = @_; | |
my $troll = get_troll (($data =~ /lower/ ? "1" : "0" ), ($data =~ /space/ ? "1" : "0" )); | |
my $lower = $data =~ /lower/; | |
my $space = $data =~ /space/; | |
$witem->command("MSG $witem->{name} $troll"); | |
} | |
sub get_troll { | |
my ($lower, $space) = @_; | |
my $ua = LWP::UserAgent->new; | |
$ua->agent("irssi/0.1"); | |
my $request = HTTP::Request->new(GET => "http://troll-as-a-service.herokuapp.com/troll?num=20".($lower ? "&downcase=true" : "").($space ? "&space=true" : "" )); | |
my $result = $ua->request($request); | |
return substr($result->content, 0, 400); | |
} | |
Irssi::command_bind ( troll => \&troll ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment