Last active
September 20, 2015 19:33
-
-
Save shmup/dc3e0526cc980445aa2c to your computer and use it in GitHub Desktop.
boilerplate irssi plugin
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
#!/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