Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # This script was based on Jolttz' script, thanks man!
- # Author: Tom
- # Blog: kaabel.net/blog/
- # IRC: irc.malvager.com #perlbar
- use strict;
- use Irssi;
- use vars qw($VERSION %IRSSI);
- Irssi::signal_add('print text', 'notify'); # Add the signals and match them to the appropriate subs.
- Irssi::signal_add('message private', 'private');
- $VERSION = '1.00';
- %IRSSI = (
- authors => 'jolttz, Tom',
- contact => 'jolttz[at]gmail.com, quellcode.blog[at]gmail.com',
- name => 'notify.pl',
- description => 'This script notifies you using notification-daemon or notify-osd whenever someone mentions your nickname or sends you a private message on IRC.'
- );
- my $own_nick = "nick1|nick2|nick3"; # Fill in all the nicknames you use, seperated by a '|'.
- sub notify {
- my ($dest, $text, $stripped) = @_;
- my $server = $dest->{server};
- return if (!($dest->{level} & MSGLEVEL_HILIGHT)); # If the message isn't highlighted, then return.
- # Get out bad characters
- $stripped =~ s/`//g; # Remove ` to prevent a crash.
- # Imagine going "notify-send -i /usr/share/pixmaps/gnome-irc.png -t 3500 \"$dest->{target} - $nick says:\" \"$message\"", where $message = `rm -rf *`: that would suck.
- $stripped =~ s/\\//g;
- $stripped =~ s/\$/'\$'/g; # Put $ in quotes
- my $message = $stripped;
- $message =~ s/^(<.\w+>)\s+(($own_nick).\s+)?//; # Do some regexp to only get out the message.
- $message =~ s/"/'/g;
- my $nick = $stripped;
- if ($nick =~ /^<.\w+>/) {
- $nick = $&;
- # Do some regexp to get out some chars, such as < and @
- $nick =~ s/<//g;
- $nick =~ s/>//g;
- $nick =~ s/@//g;
- }
- system("/full/path/to/irssiPush IRC \'$dest->{target} - $nick says:\' \'$message\'");
- }
- sub private {
- my ($server, $data, $nick, $address) = @_; # Get all the variables.
- # See $stripped above
- $data =~ s/\\//g;
- $data =~ s/`//g;
- $data =~ s/"/'/g;
- $data =~ s/\$/'\$'/g;
- system("/full/path/to/irssiPush IRC-MSG \"$nick says:\" \"$data\"");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement