Last active
July 21, 2017 18:35
-
-
Save jbarrett/4186498 to your computer and use it in GitHub Desktop.
Shizzle text script for irssi. Was going to be a bot (bizzle) output mode, but had trouble getting other scripts to emit the right signals
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
# vim: filetype=perl | |
use strict; | |
use warnings; | |
use Irssi; | |
use WWW::Mechanize; | |
=encoding utf8 | |
=head1 NAME | |
shizzle.pl - Gizoogle shizzle for your IRC bizzle | |
=head1 SYNOPSIS | |
/script load shizzle.pl | |
=head1 DESCRIPTION | |
shizzle.pl intercepts all text to be outputted and runs it through the gizoogle | |
textilizer at http://www.gizoogle.net/textilizer.php | |
This will slow things down a little, though the HTTP timeout is low, so there | |
should be little or no hanging / blocking. | |
=head1 INSTALL | |
Place this script in F<~/.irssi/scripts>. | |
To load the script on startup, ln or cp it to F<~/.irssi/scripts/autorun> | |
=head1 DEPENDENCIES | |
Requires Perl modules Irssi and WWW::Mechanize | |
=head1 AUTHOR | |
John Barrett <johna.barrett@gmail.com> | |
=cut | |
use vars qw($VERSION %IRSSI); | |
our $VERSION = '0.01'; | |
%IRSSI = ( | |
authors => 'John Barrett', | |
contact => 'johna.barrett@gmail.com', | |
name => 'shizzle', | |
description => 'Gizoogle shizzle for your IRC bizzle', | |
license => 'GPLv3+', | |
url => 'https://github.com/jbarrett/irssi-scripts', | |
changed => '2012-12-01', | |
version => $VERSION | |
); | |
sub shizzle_da_mizzle { | |
my ($msg, $server, @rizzle) = @_; | |
my $mech = WWW::Mechanize->new( timeout => 1 ); | |
$mech->get("http://www.gizoogle.net/textilizer.php"); | |
my $response = $mech->submit_form( fields => { translatetext => $msg }); | |
if ($mech->success) { | |
$mech->update_html( $response->{_content} ); | |
my @text = $mech->find_all_inputs( type => 'textarea' ); | |
$msg = $text[0]->{'value'} | |
} | |
Irssi::signal_continue($msg, $server, @rizzle); | |
} | |
Irssi::signal_add_first( 'send text', 'shizzle_da_mizzle' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment