From b4830e97ae51396ccaa9ca2acb469aef80094ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Silva?= Date: Fri, 2 Jun 2017 15:44:54 -0300 Subject: Add initial files from envbot v0.1-beta1 --- modules/m_join.sh | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 modules/m_join.sh (limited to 'modules/m_join.sh') diff --git a/modules/m_join.sh b/modules/m_join.sh new file mode 100644 index 0000000..3151eef --- /dev/null +++ b/modules/m_join.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +########################################################################### +# # +# envbot - an IRC bot in bash # +# Copyright (C) 2007-2008 Arvid Norlander # +# Copyright (C) 2007-2008 EmErgE # +# # +# 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 . # +# # +########################################################################### +#--------------------------------------------------------------------- +## 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> []' + helpentry_join_join_description='Join a <#channel>, with an optional channel .' + + helpentry_join_part_syntax='<#channel> []"' + helpentry_join_part_description='Part a <#channel> with an optional .' +} + +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> []" + 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> []" + fi +} -- cgit v1.2.3