summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclsr <clsr@clsr.net>2019-01-02 09:38:06 +0100
committerclsr <clsr@clsr.net>2019-01-02 09:38:06 +0100
commite1f5ab2a59b9aae73f9bb73acd73b50606df47e5 (patch)
treef5021cf8d1620ce0a5bee7e4f54a7a85646a5be0
parent74c839cd6bb5582e30c4412dea34620be4c0c844 (diff)
downloadmbibot-e1f5ab2a59b9aae73f9bb73acd73b50606df47e5.tar.gz
mbibot-e1f5ab2a59b9aae73f9bb73acd73b50606df47e5.zip
Add modules/inviteadmin.bash
-rwxr-xr-xircbot.bash2
-rw-r--r--modules/inviteadmin.bash34
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
+}