Created
September 21, 2011 09:32
-
-
Save chizmw/1231657 to your computer and use it in GitHub Desktop.
irssi plugin to munge nick and away message, preserving base nick
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 | |
# 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', | |
); | |
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