summaryrefslogtreecommitdiffstats
path: root/scripts/page_reeler.pl
blob: 502045a13412bcb23ef637fced275cb0b4a80d96 (plain)
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
# Page script 0.2
#
# Thomas Graf <irssi@reeler.org>

use strict;
use Irssi;
use Irssi::Irc;
use vars qw($VERSION %IRSSI);
$VERSION = "0.2";
%IRSSI = (
    authors     => 'Thomas Graf',
    contact     => 'irssi@reeler.org',
    name        => 'page',
    description => 'display and send CTCP PAGE',
    license     => 'GNU GPLv2 or later',
    url         => 'http://irssi.reeler.org/',
);

sub sig_ctcp_msg
{
    my ($server, $args, $sender, $addr, $target) = @_;

    if ( $args =~ /page/i ) {
        Irssi::active_win()->printformat(MSGLEVEL_CRAP, 'page', "$sender!$addr is paging you!");
        Irssi::signal_stop();
    }
}

sub sig_page
{
    my ($cmd_line, $server, $win_item) = @_;
    my @args = split(' ', $cmd_line);

    if (@args <= 0) {
        Irssi::active_win()->print("Usage: PAGE <nick>");
        return;
    }

    my $nick = lc(shift(@args));

    $server->command("CTCP $nick PAGE");
}

Irssi::signal_add_first('default ctcp msg', 'sig_ctcp_msg');
Irssi::command_bind('page', 'sig_page');

Irssi::theme_register(['page', '[%gPAGE%n]$0-']);