1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
use strict;
use vars qw($VERSION %IRSSI);
use Irssi 20020120;
$VERSION = "0.03";
%IRSSI = (
authors => "c0ffee",
contact => "c0ffee\@penguin-breeder.org",
name => "mIRC pager",
description => "Adds the /PAGE command to page a nick (use /page nick <text>)... to ignore pages /set pager_mode off",
license => "Public Domain",
url => "http://www.penguin-breeder.org/?page=irssi",
changed => "2017-03-12",
);
use Irssi::Irc;
Irssi::theme_register(['page_received','-({channick_hilight $0})- $1',
'page_sending','Paging {nick $0}...',
'page_pageroff','Page request ignored: {nick $0}\'s pager is {hilight OFF}',
'page_pagersilent','Page request to {nick $0} dispatched silently',
'page_pageron','Page request to {nick $0} dispatched']);
sub signal_ctcpmsg_reply {
my ($server, $data, $nick, $addr, $target) = @_;
if ($data eq "0") {
Irssi::printformat(MSGLEVEL_CRAP,'page_pageroff',$nick);
} elsif ($data eq "1") {
Irssi::printformat(MSGLEVEL_CRAP,'page_pagersilent',$nick);
} elsif ($data eq "2") {
Irssi::printformat(MSGLEVEL_CRAP,'page_pageron',$nick);
}
Irssi::signal_stop();
}
sub signal_ctcpmsg {
my ($server, $data, $nick, $addr, $target) = @_;
my $pm = Irssi::settings_get_bool('pager_mode');
my $cmd = Irssi::settings_get_str('pager_cmd');
my $answer = 0;
my $rnd = int(rand(65535));
if ($pm) {
$data = "requesting your attention" if ($data eq "");
Irssi::printformat(MSGLEVEL_CTCPS, 'page_received',$nick,$data);
$answer = 1;
$nick =~ s/\\/\\\\/g;
$nick =~ s/\$/\\\$/g;
$nick =~ s/;/\\;/g;
$data =~ s/\\/\\\\/g;
$data =~ s/\$/\\\$/g;
$data =~ s/;/\\;/g;
if ($cmd ne "") {
$answer = 2;
$cmd =~ s/\$r/$rnd/g;
$cmd =~ s/\$n/$nick/g;
$cmd =~ s/\$i/$server->{chatnet}/g;
$cmd =~ s/\$s/$server->{address}/g;
$cmd =~ s/\$t/scalar localtime/eg;
$cmd =~ s/\$m/$data/g;
Irssi::command("$cmd");
}
}
$server->send_raw("NOTICE $nick :\001PAGE $answer\001");
Irssi::signal_stop();
}
sub cmd_page {
my ($data, $server, $channel) = @_;
my ($nick, $what);
$nick = $data;
$nick =~ s/\s(.+)//;
$what = $1;
$what = " $what" if ($what ne "");
$server->send_raw("PRIVMSG $nick :\001PAGE$what\001");
Irssi::printformat(MSGLEVEL_CRAP,'page_sending', $nick);
}
Irssi::signal_add('ctcp msg page', 'signal_ctcpmsg');
Irssi::signal_add('ctcp reply page', 'signal_ctcpmsg_reply');
Irssi::command_bind('page','cmd_page');
Irssi::settings_add_bool('misc','pager_mode',1);
Irssi::settings_add_str('misc', 'pager_cmd', "");
# ok, here for the pager_cmd syntax:
# "command [parameters]+"
# where the following things will be replaced:
# $n the nick who paged you
# $m the message
# $t timestamp (format depends on locale)
# $i ircnet
# $s server
# $r a random number
#
# for example:
# /set pager_cmd exec - play /usr/share/sounds/generic.wav
# /set pager_cmd beep
# /set pager_cmd eval exec -nosh -name wish$r wish - ; exec -in wish$r wm withdraw . ; exec -in wish$r tk_messageBox -message "$m" -icon info -type ok -title "$n paging..." ; exec -in wish$r destroy .
|