SHARE
TWEET

torvald

a guest Jun 10th, 2012 127 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2. # This script was based on Jolttz' script, thanks man!
  3. # Author: Tom
  4. # Blog: kaabel.net/blog/
  5. # IRC: irc.malvager.com #perlbar
  6.  
  7. use strict;
  8. use Irssi;
  9. use vars qw($VERSION %IRSSI);
  10. Irssi::signal_add('print text', 'notify'); # Add the signals and match them to the appropriate subs.
  11. Irssi::signal_add('message private',  'private');
  12.  
  13. $VERSION = '1.00';
  14. %IRSSI = (
  15.     authors     => 'jolttz, Tom',
  16.     contact     => 'jolttz[at]gmail.com, quellcode.blog[at]gmail.com',
  17.     name        => 'notify.pl',
  18.     description => 'This script notifies you using notification-daemon or notify-osd whenever someone mentions your nickname or sends you a private message on IRC.'
  19. );
  20.  
  21. my $own_nick = "nick1|nick2|nick3"; # Fill in all the nicknames you use, seperated by a '|'.
  22.  
  23. sub notify {
  24.     my ($dest, $text, $stripped) = @_;
  25.     my $server = $dest->{server};
  26.  
  27.     return if (!($dest->{level} & MSGLEVEL_HILIGHT)); # If the message isn't highlighted, then return.
  28.  
  29.     # Get out bad characters
  30.     $stripped =~ s/`//g; # Remove ` to prevent a crash.
  31.     # 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.
  32.     $stripped =~ s/\\//g;
  33.     $stripped =~ s/\$/'\$'/g; # Put $ in quotes
  34.     my $message = $stripped;
  35.     $message =~ s/^(<.\w+>)\s+(($own_nick).\s+)?//; # Do some regexp to only get out the message.
  36.     $message =~ s/"/'/g;
  37.     my $nick = $stripped;
  38.     if ($nick =~ /^<.\w+>/) {
  39.   $nick = $&;
  40.         # Do some regexp to get out some chars, such as < and @
  41.   $nick =~ s/<//g;
  42.   $nick =~ s/>//g;
  43.   $nick =~ s/@//g;
  44.     }
  45.     system("/full/path/to/irssiPush IRC \'$dest->{target} - $nick says:\' \'$message\'");
  46. }
  47.  
  48. sub private {
  49.     my ($server, $data, $nick, $address) = @_; # Get all the variables.
  50.     # See $stripped above
  51.     $data =~ s/\\//g;
  52.     $data =~ s/`//g;
  53.     $data =~ s/"/'/g;
  54.     $data =~ s/\$/'\$'/g;
  55.     system("/full/path/to/irssiPush IRC-MSG \"$nick says:\" \"$data\"");
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top