blob: 3151eefcdb6a40b3cca0565d98f06ab080b48d85 (
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
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
|
#!/bin/bash
# -*- coding: utf-8 -*-
###########################################################################
# #
# envbot - an IRC bot in bash #
# Copyright (C) 2007-2008 Arvid Norlander #
# Copyright (C) 2007-2008 EmErgE <halt.system@gmail.com> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###########################################################################
#---------------------------------------------------------------------
## Join/part
#---------------------------------------------------------------------
module_join_INIT() {
modinit_API='2'
modinit_HOOKS=''
commands_register "$1" 'join' || return 1
commands_register "$1" 'part' || return 1
helpentry_module_join_description="Join/part commands."
helpentry_join_join_syntax='<#channel> [<key>]'
helpentry_join_join_description='Join a <#channel>, with an optional channel <key>.'
helpentry_join_part_syntax='<#channel> [<reason>]"'
helpentry_join_part_description='Part a <#channel> with an optional <reason>.'
}
module_join_UNLOAD() {
return 0
}
module_join_REHASH() {
return 0
}
module_join_handler_part() {
local sender="$1"
local parameters="$3"
if [[ "$parameters" =~ ^(#[^ ]+)(\ (.+))? ]]; then
local channel="${BASH_REMATCH[1]}"
local reason="${BASH_REMATCH[3]}"
if access_check_capab "join" "$sender" "$channel"; then
if [[ -z "$reason" ]]; then
channels_part "$channel"
else
channels_part "$channel" "$reason"
fi
else
access_fail "$sender" "make the bot part channel" "join"
fi
else
local sendernick
parse_hostmask_nick "$sender" 'sendernick'
feedback_bad_syntax "$sendernick" "part" "<#channel> [<reason>]"
fi
}
module_join_handler_join() {
local sender="$1"
local parameters="$3"
if [[ "$parameters" =~ ^(#[^ ]+)(\ [^ ]+)? ]]; then
local channel="${BASH_REMATCH[1]}"
local key="${BASH_REMATCH[2]}"
if access_check_capab "join" "$sender" "$channel"; then
key="${key## }"
if [[ -z "$key" ]]; then
channels_join "${channel}"
else
channels_join "${channel}" "$key"
fi
else
access_fail "$sender" "make the join channel" "join"
fi
else
local sendernick
parse_hostmask_nick "$sender" 'sendernick'
feedback_bad_syntax "$sendernick" "join" "<#channel> [<key>]"
fi
}
|