Skip to content

Instantly share code, notes, and snippets.

@chizmw
Last active December 10, 2015 23:28
Show Gist options
  • Save chizmw/4509438 to your computer and use it in GitHub Desktop.
Save chizmw/4509438 to your computer and use it in GitHub Desktop.
An irssi plugin that makes it easier to change your nick and away status to make your availability really obvious (used at $work)
#!/usr/bin/env perl
# An irssi plugin that makes it easier to change your nick and away status to
# make your availability really obvious (used at $work)
#
# Simple examples are:
# gone --> gone = "/availability gone";
# idme = "/msg NickServ IDENTIFY s3kritw0rd";
# here --> here = "/availability here; /idme";
# Usage: /AVAILABILITY [here|lunch|meeting]
sub cmd_availability {
# data - contains the parameters for /HELLO
# 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;
}
# find the 'base' of our current nick (using | as a separator
my ($base_nick) = ($server->{nick} =~ m{^([^\|]+)});
$base_nick ||= 'borked';
my %availability_for = (
coffee => 'Wandered out to buy a coffee based beverage',
firesafety => 'Performing Fire Safety Tasks',
gone => q{Gone somewhere that's not here - probably home},
lunch => 'Gone to lunch',
meeting => 'In a meeting',
shard => 'IN the Shard',
);
if ($data) {
if ($data =~ /^here$/i) {
$server->command("AWAY");
$server->command("NICK ${base_nick}");
}
elsif (exists $availability_for{$data}) {
$server->command("NICK ${base_nick}|$data");
$server->command("AWAY $availability_for{$data}");
}
else {
Irssi::print("Unknown availability type '$data'");
}
}
else {
Irssi::print("No availability type given");
}
}
Irssi::command_bind('availability', 'cmd_availability');
Irssi::print("loaded cmd_availability.pl");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment