mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-06-03 10:50:52 +00:00
add bin/bashbot_env.inc.sh
This commit is contained in:
parent
0db0215d9b
commit
bd155f8cb5
33
bin/bashbot_env.inc.sh
Normal file
33
bin/bashbot_env.inc.sh
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
# FILE: bashbor_env.inc.sh
|
||||||
|
#
|
||||||
|
# DESCRIPTION: set bashbot environment for all scripts in this directory
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||||
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||||
|
# CREATED: 18.12.2020 12:27
|
||||||
|
#
|
||||||
|
#### $$VERSION$$ v1.2-dev2-38-g0db0215
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
# set where your bashbot lives
|
||||||
|
# default: one dir up
|
||||||
|
BASHBOT_HOME="$(cd "${BASH_SOURCE[0]%/*}" >/dev/null 2>&1 && pwd)/../"
|
||||||
|
|
||||||
|
#####
|
||||||
|
# if files are not readable, eviroment is wrong or bashbot is not initialized
|
||||||
|
|
||||||
|
# check for botconfig.jssh readable
|
||||||
|
if [ ! -r "${BASHBOT_HOME}/botconfig.jssh" ]; then
|
||||||
|
echo "Bashbot config file in \"${BASHBOT_HOME}\" does not exist or is not readable."
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
# check for count.jssh readable
|
||||||
|
if [ ! -r "${BASHBOT_HOME}/count.jssh" ]; then
|
||||||
|
echo "Bashbot count file in \"${BASHBOT_HOME}\" does not exist or is not readable"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash -
|
#!/bin/bash
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
# FILE: broadcast_message.sh
|
# FILE: broadcast_message.sh
|
||||||
|
@ -21,37 +21,30 @@
|
||||||
#
|
#
|
||||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||||
# CREATED: 16.12.2020 16:14:57
|
# CREATED: 16.12.2020 16:14
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v1.2-dev2-34-gc356143
|
#### $$VERSION$$ v1.2-dev2-38-g0db0215
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
# set where your bashbot lives
|
# set bashbot environment
|
||||||
BASHBOT_HOME="$(cd "${BASH_SOURCE[0]%/*}" >/dev/null 2>&1 && pwd)/../"
|
# shellcheck disable=SC1090
|
||||||
|
source "${0%/*}/bashbot_env.inc.sh"
|
||||||
# check for botconfig.jssh
|
|
||||||
if [ ! -r "${BASHBOT_HOME}/botconfig.jssh" ]; then
|
|
||||||
echo "No bashbot config file in ${BASHBOT_HOME}"
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
# check for count.jssh
|
|
||||||
if [ ! -r "${BASHBOT_HOME}/count.jssh" ]; then
|
|
||||||
echo "No bashbot count file in ${BASHBOT_HOME}"
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
####
|
||||||
# broadcast is dangerous, without --doit we do a dry run ...
|
# broadcast is dangerous, without --doit we do a dry run ...
|
||||||
if [ "$1" == "--doit" ]; then
|
if [ "$1" == "--doit" ]; then
|
||||||
DOIT="yes"
|
DOIT="yes"
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
####
|
||||||
# send to users by default, --group sends to groups also
|
# send to users by default, --group sends to groups also
|
||||||
if [ "$1" == "--groups" ]; then
|
if [ "$1" == "--groups" ]; then
|
||||||
GROUPSALSO=" and groups"
|
GROUPSALSO=" and groups"
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
####
|
||||||
# parse args -----------------
|
# parse args -----------------
|
||||||
SEND="send_message"
|
SEND="send_message"
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash -
|
#!/bin/bash
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
# FILE: send_message.sh
|
# FILE: send_message.sh
|
||||||
|
@ -19,20 +19,16 @@
|
||||||
#
|
#
|
||||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||||
# CREATED: 16.12.2020 11:34:27
|
# CREATED: 16.12.2020 11:34
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v1.2-dev2-34-gc356143
|
#### $$VERSION$$ v1.2-dev2-38-g0db0215
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
# set where your bashbot lives
|
# set bashbot environment
|
||||||
BASHBOT_HOME="$(cd "${BASH_SOURCE[0]%/*}" >/dev/null 2>&1 && pwd)/../"
|
# shellcheck disable=SC1090
|
||||||
|
source "${0%/*}/bashbot_env.inc.sh"
|
||||||
# check for botconfig.jssh
|
|
||||||
if [ ! -r "${BASHBOT_HOME}/botconfig.jssh" ]; then
|
|
||||||
echo "No bashbot config file in ${BASHBOT_HOME}"
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
####
|
||||||
# parse args
|
# parse args
|
||||||
SEND="send_message"
|
SEND="send_message"
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -61,16 +57,16 @@ case "$1" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ "$1" == *[!0-9-]* ]]; then
|
|
||||||
echo "CHAT[ID] is not a number! use: $0 -h for help"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# source bashbot and send message
|
# source bashbot and send message
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "${BASHBOT_HOME}/bashbot.sh" source "$3"
|
source "${BASHBOT_HOME}/bashbot.sh" source "$3"
|
||||||
|
|
||||||
|
####
|
||||||
|
# ready, do stuff here -----
|
||||||
|
|
||||||
|
# send message in selected format
|
||||||
"${SEND}" "$1" "$2"
|
"${SEND}" "$1" "$2"
|
||||||
|
|
||||||
# output result
|
# output send message result
|
||||||
jssh_printDB "BOTSENT" | sort -r
|
jssh_printDB "BOTSENT" | sort -r
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user