Created
July 24, 2012 11:06
-
-
Save chizmw/3169408 to your computer and use it in GitHub Desktop.
irssi 'availability' plugin script
This file contains hidden or 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 | |
# 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"); |
... and yes, it would be much better to move the key:value pairs for availability to config settings .... one day ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've also got the following aliases defined in .irssi/config: