Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# send libnotify updates only for certain users. Edit the variable okAccounts to select which accounts.
#
# depends on notify-send
# To install, add this to your ~/.purple/plugins directory (you may have to create it)
# Then enable the plugin
use Purple;
# edit the keys in this hash to enable alerts for only these users
# the value is irrelevant
%okAccounts = ('User 1' => '1',
'User 2' => '1');
%PLUGIN_INFO = (
perl_api_version => 2,
name => "SelectiveNotify",
version => "1.0",
summary => "Notifies only for select users",
description => "Notifies only for select users",
author => "Ben West <bwsithspawn00@yahoo.com>",
url => "na",
load => "plugin_load",
unload => "plugin_unload"
);
sub plugin_init {
return %PLUGIN_INFO;
}
sub signal_cb {
my $ref = shift;
my $buddy = $ref->get_alias();
if (exists $okAccounts{ $buddy }) {
Purple::Debug::info("SelectiveNotify", "buddy signed on: $buddy. They are in your list, so notifying\n");
system("notify-send \"$buddy signed on.\"");
} else {
Purple::Debug::info("Selective Notify", "buddy signed on: $buddy. They are not in your list, so ignoring\n");
}
}
sub plugin_load {
my $plugin = shift;
$data = "";
$buddylist_handle = Purple::BuddyList::get_handle ();
Purple::Debug::info("SelectiveNotify", "plugin_load() - Selective Notify Plugin Loaded.\n");
Purple::Signal::connect($buddylist_handle, "buddy-signed-on", $plugin, \&signal_cb, $data);
}
sub plugin_unload {
my $plugin = shift;
Purple::Debug::info("SelectiveNotify", "plugin_unload() - Selective Notify Plugin Unloaded.\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment