-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathmh_secureonlychan_489.pl
More file actions
108 lines (93 loc) · 3.66 KB
/
mh_secureonlychan_489.pl
File metadata and controls
108 lines (93 loc) · 3.66 KB
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
#!/usr/bin/env false
##############################################################################
#
# mh_secureonlychan_489 v1.01
#
# Copyright (c) 2020 Michael Hansen
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
##############################################################################
#
# Fix for Irssi not fully supporting numeric 489 ERR_SECUREONLYCHAN.
#
# see https://github.com/irssi/irssi/issues/1193 for details about the issue.
#
# This script will display an error message in the status-window if you try to
# join a secure only channel without a secure connection. If you have the
# setting autoclose_windows off, you will still get the old raw message in the
# channel-window too.
#
# The script will die gracefully with a message if loaded in a version of
# Irssi that already have the source-code fixed (ABI version 29 or higher).
#
# see https://github.com/irssi/irssi/pull/1196 for details about the code fix.
#
##############################################################################
use v5.14.2;
use strict;
use warnings;
use Irssi ();
##############################################################################
#
# Irssi script header
#
##############################################################################
our $VERSION = '1.01';
our %IRSSI =
(
'name' => 'mh_secureonlychan_489',
'description' => 'Fix for Irssi not fully supporting numeric 489 ERR_SECUREONLYCHAN',
'url' => 'https://github.com/irssi/scripts.irssi.org/tree/master/scripts',
'license' => 'ISC/BSD',
'authors' => 'Michael Hansen',
'contact' => 'mh (IRCnet)',
'changed' => '2020-05-16',
);
##############################################################################
#
# Irssi signal handler
#
##############################################################################
sub signal_server_event
{
my ($serverrec, $data, $nick, $address) = @_;
if (substr($data, 0, 3) eq '489')
{
(undef, undef, my $channelname, $data) = split(/ /, $data, 4);
# numeric 489 is also used as ERR_VOICENEEDED, make sure this is an actual ERR_SECUREONLYCHAN
if (substr($data, 0, 20) eq ':Cannot join channel')
{
$serverrec->printformat('(status)', Irssi::MSGLEVEL_CRAP(), 'joinerror_secureonlychan_489', $channelname);
}
}
return(1);
}
##############################################################################
#
# script on load
#
##############################################################################
# selfdestruct if Irssi is new enough to have the source-code fixed for this issue
if (Irssi::parse_special('$abiversion') and (Irssi::parse_special('$abiversion') >= 29))
{
die('The script is not needed for this version of Irssi.' . "\n");
}
Irssi::theme_register(['joinerror_secureonlychan_489', 'Cannot join to channel {channel $0} (Secure clients only)']);
Irssi::signal_add_last("server event", 'signal_server_event');
1;
##############################################################################
#
# eof
#
##############################################################################