1# $Id: pager.pl,v 1.23 2003/01/27 09:45:16 jylefort Exp $ 2 3use strict; 4use Irssi 20020121.2020 (); 5 6use vars qw/$VERSION %IRSSI/; 7$VERSION = "1.2"; 8%IRSSI = ( 9 authors => 'Jean-Yves Lefort', 10 contact => 'jylefort\@brutele.be', 11 name => 'pager', 12 description => 'Notifies people if they send you a private message or a DCC chat offer while you are away; runs a shell command configurable via /set if they page you', 13 license => 'BSD', 14 changed => '$Date: 2017/03/06 $ ', 15); 16 17# note: 18# 19# Irssi special variables (see IRSSI_DOC_DIR/special_vars.txt) will be 20# expanded in *_notice /set's, and will NOT be expanded in page_command 21# for obvious security reasons. 22# 23# /set's: 24# 25# page_command a shell command to run if someone sends you the 26# private message 'page' while you are away 27# 28# away_notice a notice to send to someone sending you a private 29# message while you are away 30# 31# paged_notice a notice to send to someone who has just paged you 32# 33# dcc_notice a notice to send to someone who has just sent you 34# a DCC chat offer (this automatically pages you) 35# 36# changes: 37# 38# 2017-03-06 release 1.2 39# * declaration $VERSION %IRSSI 40# 41# 2003-01-27 release 1.1 42# * notices and commands are now optional 43# 44# 2002-07-04 release 1.01 45# * things are now printed in the right order 46# * signal_add's uses a reference instead of a string 47# 48# 2002-04-25 release 1.00 49# * increased version number 50# 51# 2002-02-06 release 0.20 52# * builtin expand deprecated; 53# now uses Irssi's special variables 54# 55# 2002-01-27 release 0.11 56# * uses builtin expand 57# 58# 2002-01-23 initial release 59 60use strict; 61use Irssi::Irc; # for DCC object 62 63sub message 64 { 65 my ($server, $msg, $nick, $address) = @_; 66 67 if ($server->{usermode_away}) 68 { 69 if (lc($msg) eq "page") 70 { 71 my $page_command = Irssi::settings_get_str("page_command"); 72 my $paged_notice = Irssi::settings_get_str("paged_notice"); 73 74 if ($page_command) 75 { 76 system($page_command); 77 } 78 if ($paged_notice) 79 { 80 $server->command("EVAL NOTICE $nick $paged_notice"); 81 } 82 } 83 else 84 { 85 my $away_notice = Irssi::settings_get_str("away_notice"); 86 87 if ($away_notice) 88 { 89 $server->command("EVAL NOTICE $nick $away_notice"); 90 } 91 } 92 } 93 } 94 95sub dcc_request 96 { 97 my ($dcc, $sendaddr) = @_; 98 99 if ($dcc->{server}->{usermode_away} && $dcc->{type} eq "CHAT") 100 { 101 my $page_command = Irssi::settings_get_str("page_command"); 102 my $dcc_notice = Irssi::settings_get_str("dcc_notice"); 103 104 if ($page_command) 105 { 106 system($page_command); 107 } 108 if ($dcc_notice) 109 { 110 $dcc->{server}->command("EVAL NOTICE $dcc->{nick} $dcc_notice"); 111 } 112 } 113 } 114 115Irssi::settings_add_str("misc", "page_command", 116 "esdplay ~/sound/events/page.wav &"); 117Irssi::settings_add_str("misc", "away_notice", 118 '$N is away ($A). Type /MSG $N PAGE to page him.'); 119Irssi::settings_add_str("misc", "paged_notice", 120 '$N has been paged.'); 121Irssi::settings_add_str("misc", "dcc_notice", 122 '$N is away ($A) and has been paged. Type /MSG $N PAGE to page him again.'); 123 124Irssi::signal_add_priority("message private", \&message, 125 Irssi::SIGNAL_PRIORITY_LOW + 1); 126Irssi::signal_add_priority("dcc request", \&dcc_request, 127 Irssi::SIGNAL_PRIORITY_LOW + 1); 128