(Back to Slithering Perl Horrors)

Nyees, the Horrors shall Slither Once More!

This script is more or less of a clone of my Everything2 support for sirc script, to be used with Irssi IRC client...

It has similiar functionality: /gonode will go to last-mentioned node (said in public place with [brackets] around it), and /gonode nodename will go to that node.

Bugs and restrictions in 1.0:

  • Doesn't allow pipelink abuse =)
  • Doesn't seem to read the stuff from actions (/mes and such)...
  • No theming.
  • Settings are not used. (See comments for pathetic explanations...) To use another web browser (and not gnome-moz-remote), you need to edit the script.

This ought to be published on my web page, but until then, this is the only place where you can get it...


#!/usr/bin/perl -w
#######################################################################
# Everything2 support for Irssi IRC client
# Written by Weyfour WWWWolf (Urpo Lankinen)
#
# E-mail:    <wwwwolf@iki.fi>
# Home page: <http://www.iki.fi/wwwwolf/>
# Home node: <http://www.everything2.com/?node=WWWWolf&type=user>
#
# $Id: irssi-e2.pl,v 1.0 2001/03/22 16:41:04 wwwwolf Exp $
#
# Distributed under the Artistic Lisence. No warranty, dammit.
#######################################################################

use strict;
use Irssi;
use URI;

#######################################################################

# Commented out - this give BIG red warning and stuff. Appanently
# checking if settings *exist* aren't supported. Deal with it.
# Want to change? Edit the script.

## Web browser setting
#if(!defined Irssi::settings_get_str("web_browser")) {
#  Irssi::settings_set_str("misc","web_browser",
#                         'gnome-moz-remote --newwin #URL#');
#}
#my $web_browser = Irssi::settings_get_str("web_browser");

my $web_browser = 'gnome-moz-remote --newwin #URL#';


# The last seen node is stored here
my $currnode = "my dog it has three corners";

#######################################################################

# This was going to be themed, but it just won't work...
sub parse_message {
  # get the information, as advertised in the manual.
  my $message = @_[1];

  # Intercept [bracket]ed text.
  $message =~ /\[([^\]]+)\]/g;
  $currnode = $1;
}

#Irssi::signal_add_last("print text stripped", "parse_message");

Irssi::signal_add_last("message public", "parse_message");
Irssi::signal_add_last("message private", "parse_message");
Irssi::signal_add_last("message own_public", "parse_message");
Irssi::signal_add_last("message own_private", "parse_message");

# Go to specified URL

sub go_url ($) {

  my $url = shift;
  my $browser = $web_browser;

  $browser =~ s/\#URL\#/$url/gi;
  system($browser);
}

# The actual command to go to the node.
sub cmd_gonode {

  my $args = shift || undef;

  my $node;

  if(defined $args) { # Has arguments
    $node = $args;
  } else { # No arguments, go to the last node mentioned.
    $node = $currnode;
  }

  my $url = URI->new("http://www.everything2.com/?node="
                     . $node)->canonical->as_string;

  # Print the URL. Need to handle the % signs in URL (otherwise interpreted
  # as color codes).
  my $printurl = $url; $printurl =~ s!%!%%!g;
  Irssi::active_win()->print("Going to URL \cb".
                             $printurl. "\cb", MSGLEVEL_CRAP);

  go_url($url);
}
Irssi::command_bind("gonode","cmd_gonode");

Irssi::active_win()->print("Irssi/\cbEverything2\cb script (c) WWWWolf",
                           MSGLEVEL_CRAP);

1;

Log in or registerto write something here or to contact authors.