summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/inviteadmin.bash34
1 files changed, 34 insertions, 0 deletions
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
+}