diff options
-rwxr-xr-x | ircbot.bash | 2 | ||||
-rw-r--r-- | modules/inviteadmin.bash | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/ircbot.bash b/ircbot.bash index 3939311..b6701c0 100755 --- a/ircbot.bash +++ b/ircbot.bash @@ -228,7 +228,7 @@ _readloop() { if [[ $pos -lt 0 ]]; then return 1 fi - src="${msg:1:$pos}" + src="${msg:1:$((pos-1))}" ((++pos)) msg="${msg:$pos}" fi diff --git a/modules/inviteadmin.bash b/modules/inviteadmin.bash new file mode 100644 index 0000000..16d1da9 --- /dev/null +++ b/modules/inviteadmin.bash @@ -0,0 +1,34 @@ +# modules/inviteadmin.bash +# +# Lets a user control joins/parts + + +if [ -z "$IRCBOT_MODULE" ]; then + printf "error: %s is a module for ircbot.bash and should not be run separately\n" "$0" + exit 1 +fi + + +if [ -z "$INVITEADMIN_ADMIN" ]; then + printf "module %s requires a configured admin\n" "$0" + exit 1 +fi + +inviteadmin_nick="$(parse_source_nick "$INVITEADMIN_ADMIN")" + + +# notify the admin about the invite +on_self_invite() { # args: $1 - source, $2 - channel + sendmsg PRIVMSG "$inviteadmin_nick" "invited to $2 by $1" +} + +# join/part channels if the admin commands it +on_dm() { # args: $1 - source, $2 - message + if [[ $1 == "$INVITEADMIN_ADMIN" ]]; then + read -r cmd chan <<< "$2" + case "$cmd" in + join) sendmsg JOIN "$chan" ;; + part) sendmsg PART "$chan" ;; + esac + fi +} |