From 6302ef479500ae2f3835e24ec51ca954ccb776f2 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sat, 1 Jun 2019 12:46:27 +0200 Subject: [PATCH] adjust examples to v0.90 --- bashbot.sh | 2 +- examples/background-scripts/mycommands.sh | 6 ------ examples/send-system-status/mycommands.sh | 14 ++++---------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index 898150c..d983bd4 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -11,7 +11,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.90-2-g274f5d8 +#### $$VERSION$$ v0.90-3-g9a81e44 # # Exit Codes: # - 0 sucess (hopefully) diff --git a/examples/background-scripts/mycommands.sh b/examples/background-scripts/mycommands.sh index c9f62ae..9be1051 100644 --- a/examples/background-scripts/mycommands.sh +++ b/examples/background-scripts/mycommands.sh @@ -36,12 +36,6 @@ mycommands() { # place your additional processing functions here ... -# returns true if function exist -_is_function() -{ - [ "$(LC_ALL=C type -t "$1")" = "function" ] -} - # inifnite loop for waching a given dir for new files # $1 dir to wtach for new files watch_dir_loop() { diff --git a/examples/send-system-status/mycommands.sh b/examples/send-system-status/mycommands.sh index 83bda07..f0c400e 100644 --- a/examples/send-system-status/mycommands.sh +++ b/examples/send-system-status/mycommands.sh @@ -5,7 +5,7 @@ # to show how you can customize bashbot by only editing mycommands.sh # NOTE: this is not tested, simply copied from original source and reworked! # -#### $$VERSION$$ v0.90-0-g7029f7f +#### $$VERSION$$ v0.90-3-g9a81e44 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 @@ -35,16 +35,10 @@ bashbot_help='*Availiable commands*: # your additional bahsbot commands # NOTE: command can have @botname attached, you must add * in case tests... mycommands() { - [[ "$MESSAGE" = '/'* ]] || return - set +f - # shellcheck disable=SC2206 - local arg=( $MESSAGE ) - set -f - local cmd="${arg[0]}" local msg="" if user_is_botadmin "${USER[ID]}" || user_is_allowed "${USER[ID]}" "systemstatus"; then - case "$cmd" in + case "$CMD" in '/md'*) msg="$(cat /proc/mdstat)";; '/smb'*) msg="$(smbstatus)" ;; '/se'*) msg="$(sensors | sed -r 's/\s|\)+//g' | sed -r 's/\(high=|\(min=/\//' | sed -r 's/\,crit=|\,max=/\//')";; @@ -55,8 +49,8 @@ mycommands() { '/lvm'*) msg="$(lvs | sed -r 's/\s+/\n/g')";; '/lvsd'*) msg="$(lvs -a -o +devices | sed -r 's/\s+/\n/g')";; '/smart'*) - [ "${arg[0]}" == "" ] && msg="example \`/smart sda\`" && return - drive="$(echo "${arg[0]}" | cut -c 1-3)" + [ "${CMD[1]}" == "" ] && msg="example \`/smart sda\`" && return + drive="$(echo "${CMD[1]}" | cut -c 1-3)" echo "smartctl -a /dev/$drive" msg="$(smartctl -a "/dev/$drive")" ;;