-
Notifications
You must be signed in to change notification settings - Fork 4
/
SSLOnly.pm
48 lines (40 loc) · 1.13 KB
/
SSLOnly.pm
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
# Copyright (c) 2016, matthew
#
# Created on MacBook-Pro
# Fri Jul 29 20:57:09 EDT 2016
# SSLOnly.pm
#
# @name: 'Channel::SSLOnly'
# @package: 'M::Channel::SSLOnly'
# @description: 'Adds mode to allow only ssl users to join'
#
# @depends.modules: ['Base::ChannelModes']
#
# @author.name: 'Matt Barksdale'
# @author.website: 'https://github.com/mattwb65'
#
package M::Channel::SSLOnly;
use warnings;
use strict;
use 5.010;
our ($api, $mod, $pool);
# channel modes
our %channel_modes = (
ssl_only => { type => 'normal' }
);
sub init {
# Hook on to the can_join event to prevent joining a channel that is ssl users only.
$pool->on('user.can_join' => \&on_user_can_join, 'is.ssl.user');
return 1;
}
sub on_user_can_join {
my ($user, $event, $channel) = @_;
# A user can join a channel that isn't +S
return unless $channel->is_mode('ssl_only');
# User must be connected via ssl otherwise
return if $user->{ssl};
# Let them know they can't join if they're not on ssl
$user->server_notice("Only users using SSL can join this channel!");
$event->stop('channel_ssl_only');
}
$mod