Created
September 14, 2012 21:06
-
-
Save bentglasstube/3724824 to your computer and use it in GitHub Desktop.
Notification plugin for ZNC
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
use base 'ZNC::Module'; | |
sub module_types { | |
$ZNC::CModInfo::UserModule; | |
} | |
sub description { | |
"Notify you when you are not attached to ZNC"; | |
} | |
our %keywords = (); | |
sub OnModCommand { | |
my ($self, $command) = @_; | |
if ($command =~ /^help/i) { | |
$self->PutModule("Watch List - shows list of watched keywords"); | |
$self->PutModule("Watch Add <keyword> - add <keyword> to list"); | |
$self->PutModule("Watch Del <keyword> - remove <keyword> from list"); | |
} elsif ($command =~ /^watch list/i) { | |
$self->PutModule("Watching for the following words:"); | |
$self->PutModule(" $_") for sort keys %keywords; | |
} elsif ($command =~ /^watch add (.+)/i) { | |
my $key = lc $1; | |
if ($keywords{$key}) { | |
$self->PutModule("Already watching for $key"); | |
} else { | |
$self->PutModule("Watching for $key"); | |
$keywords{$key} = 1; | |
} | |
} elsif ($command =~ /^watch del (.+)/i) { | |
my $key = lc $1; | |
if ($keywords{$key}) { | |
$self->PutModule("No longer watching for $key"); | |
delete $keywords{$key}; | |
} else { | |
$self->PutModule("Not watching for $key"); | |
} | |
} else { | |
$self->PutModule('Unknown command'); | |
} | |
} | |
sub OnChanMsg { | |
my ($self, $nick, $chan, $msg) = @_; | |
my $connected = $self->GetNetwork->IsUserOnline; | |
# check keywords | |
return $ZNC::CONTINUE; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment