start dev3 - remove tmux
This commit is contained in:
parent
31a5d00a64
commit
bccd064516
|
@ -107,6 +107,6 @@
|
|||
<p><span class="citation">@Gnadelwartz</span></p>
|
||||
<h2 id="thats-it">That’s it!</h2>
|
||||
<p>If you feel that there’s something missing or if you found a bug, feel free to submit a pull request!</p>
|
||||
<h4 id="version-v0.76-1-ge8a1fd0"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.76-1-ge8a1fd0</h4>
|
||||
<h4 id="version-v0.80-dev3-0-g31a5d00"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.80-dev3-0-g31a5d00</h4>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -107,4 +107,4 @@ Well, thats a damn good question ... may be because I'm an Unix/Linux admin from
|
|||
|
||||
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
|
|
@ -155,4 +155,4 @@ health status
|
|||
If you feel that there's something missing or if you found a bug, feel free to
|
||||
submit a pull request!
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# description: Start or stop telegram-bash-bot
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
# shellcheck disable=SC2009
|
||||
# shellcheck disable=SC2181
|
||||
|
||||
|
|
31
bashbot.sh
31
bashbot.sh
|
@ -12,7 +12,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 sucess (hopefully)
|
||||
|
@ -58,7 +58,6 @@ if [ ! -f "${TOKENFILE}" ]; then
|
|||
echo "Running headless, run ${SCRIPT} init first!"
|
||||
exit 2
|
||||
else
|
||||
${CLEAR}
|
||||
echo -e "${RED}TOKEN MISSING.${NC}"
|
||||
echo -e "${ORANGE}PLEASE WRITE YOUR TOKEN HERE OR PRESS CTRL+C TO ABORT${NC}"
|
||||
read -r token
|
||||
|
@ -72,7 +71,6 @@ if [ ! -f "${BOTADMIN}" ]; then
|
|||
echo "Running headless, set botadmin to AUTO MODE!"
|
||||
echo '?' > "${BOTADMIN}"
|
||||
else
|
||||
${CLEAR}
|
||||
echo -e "${RED}BOTADMIN MISSING.${NC}"
|
||||
echo -e "${ORANGE}PLEASE WRITE YOUR TELEGRAM ID HERE OR ENTER '?'${NC}"
|
||||
echo -e "${ORANGE}TO MAKE FIRST USER TYPING '/start' TO BOTADMIN${NC}"
|
||||
|
@ -92,7 +90,6 @@ TMPDIR="${BASHBOT_VAR:-.}/data-bot-bash"
|
|||
if [ ! -d "${TMPDIR}" ]; then
|
||||
mkdir "${TMPDIR}"
|
||||
elif [ ! -w "${TMPDIR}" ]; then
|
||||
${CLEAR}
|
||||
echo -e "${RED}ERROR: Can't write to ${TMPDIR}!.${NC}"
|
||||
ls -ld "${TMPDIR}"
|
||||
exit 2
|
||||
|
@ -102,7 +99,6 @@ COUNTFILE="${BASHBOT_VAR:-.}/count"
|
|||
if [ ! -f "${COUNTFILE}" ]; then
|
||||
echo "" >"${COUNTFILE}"
|
||||
elif [ ! -w "${COUNTFILE}" ]; then
|
||||
${CLEAR}
|
||||
echo -e "${RED}ERROR: Can't write to ${COUNTFILE}!.${NC}"
|
||||
ls -l "${COUNTFILE}"
|
||||
exit 2
|
||||
|
@ -124,7 +120,6 @@ export res BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE
|
|||
COMMANDS="${BASHBOT_ETC:-.}/commands.sh"
|
||||
if [ "$1" != "source" ]; then
|
||||
if [ ! -f "${COMMANDS}" ] || [ ! -r "${COMMANDS}" ]; then
|
||||
${CLEAR}
|
||||
echo -e "${RED}ERROR: ${COMMANDS} does not exist or is not readable!.${NC}"
|
||||
ls -l "${COMMANDS}"
|
||||
exit 3
|
||||
|
@ -429,11 +424,11 @@ if [ "$1" != "source" ]; then
|
|||
"outproc") # forward output from interactive and jobs to chat
|
||||
[ "$3" = "" ] && echo "No file to read from" && exit 3
|
||||
[ "$2" = "" ] && echo "No chat to send to" && exit 3
|
||||
until [ "$line" = "imprettydarnsuredatdisisdaendofdacmd" ];do
|
||||
while true ;do
|
||||
line=""
|
||||
read -r -t 10 line
|
||||
[ "$line" != "" ] && [ "$line" != "imprettydarnsuredatdisisdaendofdacmd" ] && send_message "$2" "$line"
|
||||
done <"${TMPDIR:-.}/$3"
|
||||
[ "$line" != "" ] && send_message "$2" "$line"
|
||||
done
|
||||
rm -f -r "${TMPDIR:-.}/$3"
|
||||
exit
|
||||
;;
|
||||
|
@ -470,18 +465,15 @@ if [ "$1" != "source" ]; then
|
|||
while read -r f; do send_markdown_message "${f//COUNT}" "$*"; $sleep; done <"${COUNTFILE}"
|
||||
;;
|
||||
"start")
|
||||
${CLEAR}
|
||||
tmux kill-session -t "$ME" &>/dev/null
|
||||
tmux new-session -d -s "$ME" "bash $SCRIPT startbot" && echo -e "${GREEN}Bot started successfully.${NC}"
|
||||
echo "Tmux session name $ME" || echo -e "${RED}An error occurred while starting the bot. ${NC}"
|
||||
;;
|
||||
"kill")
|
||||
${CLEAR}
|
||||
tmux kill-session -t "$ME" &>/dev/null
|
||||
echo -e "${GREEN}OK. Bot stopped successfully.${NC}"
|
||||
;;
|
||||
"background" | "resumeback")
|
||||
${CLEAR}
|
||||
echo -e "${GREEN}Restart background processes ...${NC}"
|
||||
for FILE in "${TMPDIR:-.}/"*-back.cmd; do
|
||||
if [ "${FILE}" = "${TMPDIR:-.}/*-back.cmd" ]; then
|
||||
|
@ -492,33 +484,30 @@ if [ "$1" != "source" ]; then
|
|||
JOB="${RESTART#*:}"
|
||||
PROG="${JOB#*:}"
|
||||
JOB="${JOB%:*}"
|
||||
fifo="back-${JOB}-${ME}_${CHAT[ID]}" # compose fifo from jobname, $ME (botname) and CHAT[ID]
|
||||
fifo="$(fifoname "${CHAT[ID]}" "back-${JOB}")"
|
||||
echo "restartbackground ${PROG} ${fifo}"
|
||||
( tmux kill-session -t "${fifo}"; tmux kill-session -t "sendprocess_${fifo}"; rm -f -r "${TMPDIR:-.}/${fifo}") 2>/dev/null
|
||||
mkfifo "${TMPDIR:-.}/${fifo}"
|
||||
tmux new-session -d -s "${fifo}" "${PROG} &>${TMPDIR:-.}/${fifo}; echo imprettydarnsuredatdisisdaendofdacmd>${TMPDIR:-.}/${fifo}"
|
||||
tmux new-session -d -s "sendprocess_${fifo}" "bash $SCRIPT outproc ${CHAT[ID]} ${fifo}"
|
||||
start_back "${CHAT[ID]}" "${PROG}" "${JOB}"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
"killback" | "suspendback")
|
||||
${CLEAR}
|
||||
echo -e "${GREEN}Stopping background processes ...${NC}"
|
||||
for FILE in "${TMPDIR:-.}/"*-back.cmd; do
|
||||
if [ "${FILE}" = "${TMPDIR:-.}/*-back.cmd" ]; then
|
||||
echo -e "${RED}No background processes.${NC}"; break
|
||||
else
|
||||
REMOVE="$(< "${FILE}")"
|
||||
CHAT[ID]="${RESTART%%:*}"
|
||||
JOB="${REMOVE#*:}"
|
||||
fifo="back-${JOB%:*}-${ME}_${REMOVE%%:*}"
|
||||
JOB="${JOB%:*}"
|
||||
fifo="$(fifoname "${CHAT[ID]}" "back-${JOB}")"
|
||||
echo "killbackground ${fifo}"
|
||||
[ "$1" = "killback" ] && rm -f "${FILE}" # remove job
|
||||
( tmux kill-session -t "${fifo}"; tmux kill-session -t "sendprocess_${fifo}"; rm -f -r "${TMPDIR:-.}/${fifo}") 2>/dev/null
|
||||
kill_proc "${CHAT[ID]}" "back-${JOB}"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
"help")
|
||||
${CLEAR}
|
||||
less "README.txt"
|
||||
exit
|
||||
;;
|
||||
|
|
|
@ -5,7 +5,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
#
|
||||
|
||||
# adjust your language setting here, e.g.when run from other user or cron.
|
||||
|
@ -107,7 +107,7 @@ if [ "${1}" != "source" ];then
|
|||
if [ "$res" -eq 0 ] ; then killproc && _message "Command canceled.";else _message "No command is currently running.";fi
|
||||
;;
|
||||
*) # forward messages to optional dispatcher
|
||||
_is_function startproc && if tmux ls | grep -v send | grep -q "$copname"; then inproc; fi # interactive running
|
||||
_is_function forward_interactive && forward_interactive "${CHAT[ID]}" "${MESSAGE}" # interactive running
|
||||
_is_function mycommands && mycommands
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# this has to run once atfer git clone
|
||||
# and every time we create new hooks
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# works together with git pre-push.sh and ADD all changed files since last push
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# this has to run once atfer git clone
|
||||
# and every time we create new hooks
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: make-distribution.sh
|
||||
# creates files and arcchives to dirtribute bashbot
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# If you your bot is finished you can use make-standalone.sh to create the
|
||||
# the old all-in-one bashbot: bashbot.sh and commands.sh only!
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# list of additional files to check from shellcheck
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
bashbot.rc
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
# shellcheck disable=SC2016
|
||||
#
|
||||
# Easy Versioning in git:
|
||||
|
|
|
@ -70,5 +70,5 @@ The old format is supported for backward compatibility, but may fail for corner
|
|||
|
||||
#### [Next Create Bot](1_firstbot.md)
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
|
|
@ -65,5 +65,5 @@ group. This step is up to you actually.
|
|||
#### [Prev Installation](0_install.md)
|
||||
#### [Next Getting started](2_usage.md)
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
|
|
@ -182,5 +182,5 @@ send_action "${CHAT[ID]}" "action"
|
|||
#### [Prev Create Bot](1_firstbot.md)
|
||||
#### [Next Advanced Usage](3_advanced.md)
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
|
|
@ -180,5 +180,5 @@ See also [answer_inline_multi, answer_inline_compose](6_reference.md#answer_inli
|
|||
#### [Prev Getting started](2_usage.md)
|
||||
#### [Next Expert Use](4_expert.md)
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
|
|
@ -104,5 +104,5 @@ An example crontab is provided in ```examples/bashbot.cron```.
|
|||
#### [Prev Expert Use](4_expert.md)
|
||||
#### [Next Best Practice](5_practice.md)
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
|
|
@ -153,5 +153,5 @@ The second warning is about an unused variable, this is true because in our exam
|
|||
#### [Prev Best Practice](5_practice.md)
|
||||
#### [Next Functions Reference](6_reference.md)
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
|
|
@ -592,5 +592,5 @@ Send Input from Telegram to waiting Interactive Chat.
|
|||
#### [Prev Best Practice](5_practice.md)
|
||||
#### [Next Notes for Developers](7_develop.md)
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
|
|
@ -188,5 +188,5 @@ fi
|
|||
#### [Prev Function Reference](6_reference.md)
|
||||
#### [Next Bashbot Environment](8_custom.md)
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
|
|
@ -131,5 +131,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
|
|||
|
||||
#### [Prev Notes for Developers](7_develop.md)
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
|
|
@ -55,6 +55,6 @@ convert existing bots.
|
|||
|
||||
**external-use** will contain some examples on how to send messages from external scripts to Telegram chats or users.
|
||||
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: run_filename
|
||||
# background job to display content of all new files in WATCHDIR
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file: run_filename
|
||||
# background job to display all new files in WATCHDIR
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -4,7 +4,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# file. multibot.sh
|
||||
# description: run multiple telegram bots from one installation
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
|
||||
echo "Usage: $0 botname command"
|
||||
|
|
|
@ -7,7 +7,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
|
||||
SHELL=/bin/sh
|
||||
|
|
|
@ -5,7 +5,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -4,7 +4,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -5,7 +5,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# file: botacl
|
||||
# a user not listed here, will return false from 'user_is_allowed'
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
# Format:
|
||||
# user:ressource:chat
|
||||
|
||||
|
|
|
@ -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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
#
|
||||
# shellcheck disable=SC2154
|
||||
# shellcheck disable=SC2034
|
||||
|
|
|
@ -5,7 +5,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
#
|
||||
# source from commands.sh to use the aliases
|
||||
|
||||
|
|
|
@ -5,7 +5,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# source from commands.sh to use the inline functions
|
||||
|
||||
|
|
|
@ -5,48 +5,103 @@
|
|||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# source from commands.sh if you want ro use interactive or background jobs
|
||||
|
||||
######
|
||||
# interactive and background functions
|
||||
|
||||
# old syntax as aliases
|
||||
background() {
|
||||
echo "${CHAT[ID]}:$2:$1" >"${TMPDIR:-.}/${copname:--}$2-back.cmd"
|
||||
startproc "$1" "back-$2-"
|
||||
start_back "${CHAT[ID]}" "$1" "$2"
|
||||
}
|
||||
|
||||
startproc() {
|
||||
killproc "$2"
|
||||
local fifo="$2${copname}"
|
||||
mkfifo "${TMPDIR:-.}/${fifo}"
|
||||
tmux new-session -d -s "${fifo}" "$1 &>${TMPDIR:-.}/${fifo}; echo imprettydarnsuredatdisisdaendofdacmd>${TMPDIR:-.}/${fifo}"
|
||||
tmux new-session -d -s "sendprocess_${fifo}" "bash $SCRIPT outproc ${CHAT[ID]} ${fifo}"
|
||||
start_proc "${CHAT[ID]}" "$1" "$2"
|
||||
}
|
||||
|
||||
|
||||
checkback() {
|
||||
checkproc "back-$1-"
|
||||
check_back "${CHAT[ID]}" "$1"
|
||||
}
|
||||
checkproc() {
|
||||
check_proc "${CHAT[ID]}" "$1"
|
||||
}
|
||||
killback() {
|
||||
kill_back "${CHAT[ID]}" "$1"
|
||||
}
|
||||
killproc() {
|
||||
kill_proc "${CHAT[ID]}" "$1"
|
||||
}
|
||||
|
||||
checkproc() {
|
||||
tmux ls | grep -q "$1${copname}"
|
||||
# internal functions
|
||||
# $1 chatid
|
||||
# $2 prefix
|
||||
fifoname(){
|
||||
echo "$2${ME}_$1"
|
||||
}
|
||||
|
||||
# $1 pipename
|
||||
listproc() {
|
||||
# shellcheck disable=SC2009
|
||||
ps -ef | grep -v grep| grep "$1" | sed 's/\s\+/\t/g' | cut -f 2
|
||||
}
|
||||
|
||||
# inline and backgound functions
|
||||
# $1 chatid
|
||||
# $2 program
|
||||
# $3 jobname
|
||||
start_back() {
|
||||
local fifo; fifo="$(fifoname "$1")"
|
||||
echo "$1:$3:$2" >"${TMPDIR:-.}/${fifo}$3-back.cmd"
|
||||
start_proc "$1" "$2" "back-$3-"
|
||||
}
|
||||
|
||||
|
||||
# $1 chatid
|
||||
# $2 program
|
||||
# $3 prefix
|
||||
start_proc() {
|
||||
[ "$2" = "" ] && return
|
||||
kill_proc "$1" "$3"
|
||||
local fifo; fifo="$(fifoname "$1" "$3")"
|
||||
mkfifo "${TMPDIR:-.}/${fifo}"
|
||||
( $2 <"${TMPDIR:-.}/${fifo}" | "${SCRIPT}" outproc "${1}" "${fifo}"; ) &>>"${TMPDIR:-.}/${fifo}.log" &
|
||||
disown -a
|
||||
}
|
||||
|
||||
|
||||
# $1 chatid
|
||||
# $2 jobname
|
||||
check_back() {
|
||||
check_proc "$1" "back-$2-"
|
||||
}
|
||||
|
||||
# $1 chatid
|
||||
# $2 prefix
|
||||
check_proc() {
|
||||
[ "$(listproc "$(fifoname "$1" "$2")")" != "" ]
|
||||
# shellcheck disable=SC2034
|
||||
res=$?; return $?
|
||||
}
|
||||
|
||||
killback() {
|
||||
killproc "back-$1-"
|
||||
rm -f "${TMPDIR:-.}/${copname}$1-back.cmd"
|
||||
# $1 chatid
|
||||
# $2 jobname
|
||||
kill_back() {
|
||||
kill_proc "$1" "back-$2-"
|
||||
rm -f "${TMPDIR:-.}/$(fifoname "$1")$2-back.cmd"
|
||||
}
|
||||
|
||||
killproc() {
|
||||
local fifo="$1${copname}"
|
||||
(tmux kill-session -t "${fifo}"; echo imprettydarnsuredatdisisdaendofdacmd>"${TMPDIR:-.}/${fifo}"; tmux kill-session -t "sendprocess_${fifo}"; rm -f -r "${TMPDIR:-.}/${fifo}")2>/dev/null
|
||||
|
||||
# $1 chatid
|
||||
# $2 prefix
|
||||
kill_proc() {
|
||||
local fifo; fifo="$(fifoname "$1" "$2")"
|
||||
kill -15 "$(listproc "${fifo}")" 2>/dev/null
|
||||
rm -f -r "${TMPDIR:-.}/${fifo}";
|
||||
}
|
||||
|
||||
inproc() {
|
||||
tmux send-keys -t "$copname" "${MESSAGE[0]} ${URLS[*]}
|
||||
"
|
||||
# $1 chat
|
||||
# $2 message
|
||||
forward_interactive() {
|
||||
local fifo; fifo="$(fifoname "$1")"
|
||||
[ -p "${fifo}" ] && echo "$2" >"${fifo}"
|
||||
}
|
||||
|
|
|
@ -5,7 +5,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# source from commands.sh to use the member functions
|
||||
|
||||
|
|
|
@ -5,7 +5,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.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# source from commands.sh to use the sendMessage functions
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# files: mycommands.sh.dist
|
||||
# copy to mycommands.sh and add all your commands and functions here ...
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
#
|
||||
|
||||
# uncomment the following lines to overwrite info and help messages
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# ADD a new test skeleton to test dir, but does not activate test
|
||||
#
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# common variables
|
||||
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
../dev/hooks/pre-commit.sh
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# file: b-example-test.sh
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.76-1-ge8a1fd0
|
||||
#### $$VERSION$$ v0.80-dev3-0-g31a5d00
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
|
Loading…
Reference in New Issue