mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-25 08:47:34 +00:00
inform dot admin about stop, resume, restart
This commit is contained in:
parent
8991cc98f0
commit
b33132ea5e
@ -11,7 +11,7 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.98-dev-25-g4b18757
|
#### $$VERSION$$ v0.98-dev-26-g8991cc9
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 sucess (hopefully)
|
# - 0 sucess (hopefully)
|
||||||
@ -1055,6 +1055,9 @@ if [ "${SOURCE}" != "yes" ]; then
|
|||||||
if [ -n "${BOTPID}" ]; then
|
if [ -n "${BOTPID}" ]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
if kill ${BOTPID}; then
|
if kill ${BOTPID}; then
|
||||||
|
# inform botadmin about stop
|
||||||
|
ADMIN="$(getConfigKey "botadmin")"
|
||||||
|
[ "${ADMIN}" -gt 4 ] && send_normal_message "${ADMIN}" "Bot $(getConfigKey "botname") stopped ..." &
|
||||||
echo -e "${GREEN}OK. Bot stopped successfully.${NC}"
|
echo -e "${GREEN}OK. Bot stopped successfully.${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${RED}An error occured while stopping bot.${NC}"
|
echo -e "${RED}An error occured while stopping bot.${NC}"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.98-dev-17-gdda5b6d
|
#### $$VERSION$$ v0.98-dev-26-g8991cc9
|
||||||
|
|
||||||
# will be automatically sourced from bashbot
|
# will be automatically sourced from bashbot
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ inproc() {
|
|||||||
# suspendb*
|
# suspendb*
|
||||||
# resumeb*
|
# resumeb*
|
||||||
job_control() {
|
job_control() {
|
||||||
local content proc CHAT job fifo killall=""
|
local ADMIN content proc CHAT job fifo killall=""
|
||||||
for FILE in "${DATADIR:-.}/"*-back.cmd; do
|
for FILE in "${DATADIR:-.}/"*-back.cmd; do
|
||||||
[ "${FILE}" = "${DATADIR:-.}/*-back.cmd" ] && echo -e "${RED}No background processes.${NC}" && break
|
[ "${FILE}" = "${DATADIR:-.}/*-back.cmd" ] && echo -e "${RED}No background processes.${NC}" && break
|
||||||
content="$(< "${FILE}")"
|
content="$(< "${FILE}")"
|
||||||
@ -132,16 +132,25 @@ job_control() {
|
|||||||
"resumeb"*|"backgr"*)
|
"resumeb"*|"backgr"*)
|
||||||
printf "Restart Job: %s %s\n" "${proc}" " ${fifo}"
|
printf "Restart Job: %s %s\n" "${proc}" " ${fifo}"
|
||||||
restart_back "${CHAT}" "${proc}" "${job}"
|
restart_back "${CHAT}" "${proc}" "${job}"
|
||||||
|
# inform botadmin about stop
|
||||||
|
ADMIN="$(getConfigKey "botadmin")"
|
||||||
|
[ "${ADMIN}" -gt 4 ] && send_normal_message "${ADMIN}" "Bot $(getConfigKey "botname") restart background jobs ..." &
|
||||||
;;
|
;;
|
||||||
"suspendb"*)
|
"suspendb"*)
|
||||||
printf "Suspend Job: %s %s\n" "${proc}" " ${fifo}"
|
printf "Suspend Job: %s %s\n" "${proc}" " ${fifo}"
|
||||||
kill_proc "${CHAT}" "${job}"
|
kill_proc "${CHAT}" "${job}"
|
||||||
|
# inform botadmin about stop
|
||||||
|
ADMIN="$(getConfigKey "botadmin")"
|
||||||
|
[ "${ADMIN}" -gt 4 ] && send_normal_message "${ADMIN}" "Bot $(getConfigKey "botname") suspend background jobs ..." &
|
||||||
killall="y"
|
killall="y"
|
||||||
;;
|
;;
|
||||||
"killb"*)
|
"killb"*)
|
||||||
printf "Kill Job: %s %s\n" "${proc}" " ${fifo}"
|
printf "Kill Job: %s %s\n" "${proc}" " ${fifo}"
|
||||||
kill_proc "${CHAT}" "${job}"
|
kill_proc "${CHAT}" "${job}"
|
||||||
rm -f "${FILE}" # remove job
|
rm -f "${FILE}" # remove job
|
||||||
|
# inform botadmin about stop
|
||||||
|
ADMIN="$(getConfigKey "botadmin")"
|
||||||
|
[ "${ADMIN}" -gt 4 ] && send_normal_message "${ADMIN}" "Bot $(getConfigKey "botname") kill background jobs ..." &
|
||||||
killall="y"
|
killall="y"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user