Skip to content

Instantly share code, notes, and snippets.

@shmup
Last active September 20, 2015 19:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shmup/dc3e0526cc980445aa2c to your computer and use it in GitHub Desktop.
Save shmup/dc3e0526cc980445aa2c to your computer and use it in GitHub Desktop.
boilerplate irssi plugin
#!/usr/bin/env perl -w
use strict;
use vars qw/$VERSION %IRSSI $NAME/;
$| = 1; # flush the output buffer preceding the next output
$NAME = 'changeme';
$VERSION = '0.1';
%IRSSI = (
name => $NAME,
version => $VERSION,
author => 'shmup',
contact => 'shmup@slashnet',
download => '',
description => '',
license => 'WTFPL',
);
use Irssi;
use utf8;
sub cmd_changeme {
# data - contains the parameters for /changeme
# server - the active server in window
# witem - the active window item (eg. channel, query)
# or undef if the window is empty
my ($data, $server, $witem) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
# store empty string if the data is just whitespace
$data = $data =~/^\s*$/ ? "" : $data;
if ($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq "QUERY")) {
# output data to channel or query
$witem->command("MSG ".$witem->{name}." ".$data);
} else {
Irssi::print("no active channel/query in window");
}
}
Irssi::command_bind('changeme', 'cmd_changeme');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment