mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-26 17:26:27 +00:00
commit
a64ec1afa9
@ -90,7 +90,7 @@ Written by Drew (@topkecleon), Daniil Gentili (@danogentili), and Kay M (@gnadel
|
||||
<p>Contributions by JuanPotato, BigNerd95, TiagoDanin, and iicc1.</p>
|
||||
<p>Released to the public domain wherever applicable. Elsewhere, consider it released under the <a href="http://www.wtfpl.net/txt/copying/">WTFPLv2</a>.</p>
|
||||
<h2>Prerequisites</h2>
|
||||
<p>Uses <a href="http://github.com/dominictarr/JSON.sh">JSON.sh</a>, but no more TMUX.</p>
|
||||
<p>Uses <a href="http://github.com/dominictarr/JSON.sh">JSON.sh</a> and the magic of sed.</p>
|
||||
<p>Even bashbot is written in bash, it depends on commands typically available in a Unix/Linux Environment. More concret on the common commands provided by recent versions of <a href="https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands">coreutils</a>, <a href="https://en.wikipedia.org/wiki/BusyBox#Commands">busybox</a> or <a href="https://landley.net/toybox/help.html">toybox</a>, see <a href="doc/7_develop.md#common-commands">Developer Notes</a></p>
|
||||
<p><em>Note for MacOS and BSD Users:</em> As bashbot heavily uses modern bash and (gnu) grep/sed features, bashbot will not run without installing additional software, see <a href="doc/0_install.md">Install Bashbot</a></p>
|
||||
<p>Bashbot <a href="https://github.com/topkecleon/telegram-bot-bash">Documentation</a> and <a href="https://github.com/topkecleon/telegram-bot-bash/releases">Downloads</a> are available on www.github.com</p>
|
||||
@ -225,7 +225,7 @@ It features background tasks and interactive chats, and can serve as an interfac
|
||||
<h3>Why Bash and not the much better xyz?</h3>
|
||||
<p>Well, that's a damn good question ... may be because I'm an Unix/Linux admin from stone age. Nevertheless there are more reasons from my side:</p>
|
||||
<ul>
|
||||
<li>bashbot will run everywhere where bash is available, from embedded linux to mainframe</li>
|
||||
<li>bashbot will run everywhere where bash and (gnu) sed is available, from embedded linux to mainframe</li>
|
||||
<li>easy to integrate with other shell script, e.g. for sending system message / health status</li>
|
||||
<li>no need to install or learn a new programming language, library or framework</li>
|
||||
<li>no database, not event driven, not OO ...</li>
|
||||
@ -257,6 +257,6 @@ It features background tasks and interactive chats, and can serve as an interfac
|
||||
<p>@Gnadelwartz</p>
|
||||
<h2>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>$$VERSION$$ v0.98-dev-70-g694ee61</h4>
|
||||
<h4>$$VERSION$$ v0.98-pre2-0-ga597303</h4>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -9,7 +9,7 @@ Released to the public domain wherever applicable.
|
||||
Elsewhere, consider it released under the [WTFPLv2](http://www.wtfpl.net/txt/copying/).
|
||||
|
||||
## Prerequisites
|
||||
Uses [JSON.sh](http://github.com/dominictarr/JSON.sh), but no more TMUX.
|
||||
Uses [JSON.sh](http://github.com/dominictarr/JSON.sh) and the magic of sed.
|
||||
|
||||
Even bashbot is written in bash, it depends on commands typically available in a Unix/Linux Environment.
|
||||
More concret on the common commands provided by recent versions of [coreutils](https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands), [busybox](https://en.wikipedia.org/wiki/BusyBox#Commands) or [toybox](https://landley.net/toybox/help.html), see [Developer Notes](doc/7_develop.md#common-commands)
|
||||
@ -190,7 +190,7 @@ Bashbot is not more (in)secure as any other Bot written in any other language, w
|
||||
### Why Bash and not the much better xyz?
|
||||
Well, that's a damn good question ... may be because I'm an Unix/Linux admin from stone age. Nevertheless there are more reasons from my side:
|
||||
|
||||
- bashbot will run everywhere where bash is available, from embedded linux to mainframe
|
||||
- bashbot will run everywhere where bash and (gnu) sed is available, from embedded linux to mainframe
|
||||
- easy to integrate with other shell script, e.g. for sending system message / health status
|
||||
- no need to install or learn a new programming language, library or framework
|
||||
- no database, not event driven, not OO ...
|
||||
@ -239,4 +239,4 @@ wget -t 1 -T 10 https://api.telegram.org/bot
|
||||
|
||||
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
|
||||
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
@ -13,7 +13,7 @@ Elsewhere, consider it released under the
|
||||
[WTFPLv2](http://www.wtfpl.net/txt/copying/).
|
||||
|
||||
## Prerequisites
|
||||
Uses [JSON.sh](http://github.com/dominictarr/JSON.sh), but no more TMUX.
|
||||
Uses [JSON.sh](http://github.com/dominictarr/JSON.sh) and the magic of sed.
|
||||
|
||||
Even bashbot is written in bash, it depends on commands typically available in
|
||||
a Unix/Linux Environment.
|
||||
@ -262,8 +262,8 @@ execution bug, pls update if you use an older version!
|
||||
Well, that's a damn good question ... may be because I'm an Unix/Linux admin
|
||||
from stone age. Nevertheless there are more reasons from my side:
|
||||
|
||||
- bashbot will run everywhere where bash is available, from embedded linux to
|
||||
mainframe
|
||||
- bashbot will run everywhere where bash and (gnu) sed is available, from
|
||||
embedded linux to mainframe
|
||||
- easy to integrate with other shell script, e.g. for sending system message /
|
||||
health status
|
||||
- no need to install or learn a new programming language, library or framework
|
||||
@ -327,4 +327,4 @@ failed: Connection timed out.
|
||||
If you feel that there's something missing or if you found a bug, feel free to
|
||||
submit a pull request!
|
||||
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
@ -4,7 +4,7 @@
|
||||
# this addon counts how many files, e.g. stickers, are sent to
|
||||
# a chat and takes actions if threshold is reached
|
||||
#
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# used events:
|
||||
#
|
||||
|
@ -4,7 +4,7 @@
|
||||
# Addons can register to bashbot events at startup
|
||||
# by providing their name and a callback per event
|
||||
#
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
#
|
||||
# If an event occurs each registered event function is called.
|
||||
#
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# description: Start or stop telegram-bash-bot
|
||||
#
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
# shellcheck disable=SC2009
|
||||
# shellcheck disable=SC2181
|
||||
|
||||
|
86
bashbot.sh
86
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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-4-g724f36b
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 success (hopefully)
|
||||
@ -64,6 +64,28 @@ getConfigKey() {
|
||||
[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
|
||||
[ -r "${BOTCONFIG}.jssh" ] && sed -n 's/\["'"$1"'"\]\t*"\(.*\)"/\1/p' <"${BOTCONFIG}.jssh" | tail -n 1
|
||||
}
|
||||
# $1 token
|
||||
# return true if token seems to be valid
|
||||
check_token(){
|
||||
[[ "${1}" =~ ^[0-9]{8,10}:[a-zA-Z0-9_-]{35}$ ]] && return 0
|
||||
return 1
|
||||
}
|
||||
# log error to ERRORLOG with date
|
||||
log_error(){
|
||||
printf"%s: %s\n" "$(date)" "$*" >>"${ERRORLOG}"
|
||||
}
|
||||
# additional tests if we run in debug mode
|
||||
# $1 where $2 command $3 may debug
|
||||
debug_checks(){
|
||||
[[ "${3}" != *"debug"* ]] && return
|
||||
local DATE WHERE MYTOKEN; DATE="$(date)"; WHERE="${1}"; shift
|
||||
printf "%s: debug_checks: %s: bashbot.sh %s\n" "${DATE}" "${WHERE}" "$*"
|
||||
MYTOKEN="$(getConfigKey "bottoken")"
|
||||
[ -z "${MYTOKEN}" ] && printf "%s: %s\n" "${DATE}" "Bot token is missing!"
|
||||
check_token "${MYTOKEN}" || printf "%s: %s\n" "${DATE}" "Invalid bot token!"
|
||||
[ -z "$(getConfigKey "botadmin")" ] && printf "%s: %s\n" "${DATE}" "Bot admin is missing!"
|
||||
[ -f ".jssh" ] && printf "%s: %s\n" "${DATE}" "Ups, found file \"${PWD:-.}/.jssh\"!"
|
||||
} >>"${DEBUGLOG}"
|
||||
|
||||
# get location and name of bashbot.sh
|
||||
SCRIPT="$0"
|
||||
@ -132,6 +154,7 @@ DEBUGLOG="${LOGDIR}/DEBUG.log"
|
||||
ERRORLOG="${LOGDIR}/ERROR.log"
|
||||
UPDATELOG="${LOGDIR}/BASHBOT.log"
|
||||
|
||||
debug_checks "start SOURCE=${SOURCE:-no}" "$@"
|
||||
# we assume everything is already set up correctly if we have TOKEN
|
||||
if [ -z "${BOTTOKEN}" ]; then
|
||||
# BOTCONFIG does not exist, create
|
||||
@ -207,8 +230,10 @@ fi
|
||||
if [ -z "${BOTTOKEN}" ]; then
|
||||
BOTTOKEN="$(getConfigKey "bottoken")"
|
||||
if [ -z "${BOTTOKEN}" ]; then
|
||||
echo -e "${ORANGE}Warning: can't get bot token, try to recover working config.${NC}"
|
||||
BOTERROR="Warning: can't get bot token, try to recover working config"
|
||||
echo -e "${ORANGE}${BOTERROR}${NC}"
|
||||
if [ -r "${BOTCONFIG}.jssh.ok" ]; then
|
||||
log_error "${BOTERROR}"
|
||||
cp "${BOTCONFIG}.jssh.ok" "${BOTCONFIG}.jssh"
|
||||
BOTTOKEN="$(getConfigKey "bottoken")"
|
||||
else
|
||||
@ -220,7 +245,7 @@ fi
|
||||
|
||||
|
||||
# BOTTOKEN format checks
|
||||
if [[ ! "${BOTTOKEN}" =~ ^[0-9]{8,10}:[a-zA-Z0-9_-]{35}$ ]]; then
|
||||
if ! check_token "${BOTTOKEN}"; then
|
||||
echo -e "${ORANGE}Warning: your bottoken may incorrect. it should have the following format:${NC}"
|
||||
echo -e "${GREY}123456789${RED}:${GREY}Aa-Zz_0Aa-Zz_1Aa-Zz_2Aa-Zz_3Aa-Zz_4${ORANGE} => ${NC}\c"
|
||||
echo -e "${GREY}8-10 digits${RED}:${GREY}35 alnum characters + '_-'${NC}"
|
||||
@ -360,6 +385,7 @@ if [ -z "${BASHBOT_WGET}" ] && _exists curl ; then
|
||||
-d '{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' -X POST "${3}" \
|
||||
-H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n 2>/dev/null )"
|
||||
sendJsonResult "${res}" "sendJson (curl)" "$@"
|
||||
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "send" "${@}" &
|
||||
}
|
||||
#$1 Chat, $2 what , $3 file, $4 URL, $5 caption
|
||||
sendUpload() {
|
||||
@ -375,6 +401,7 @@ if [ -z "${BASHBOT_WGET}" ] && _exists curl ; then
|
||||
-F "$2=@$3;${3##*/}" | "${JSONSHFILE}" -s -b -n 2>/dev/null )"
|
||||
fi
|
||||
sendJsonResult "${res}" "sendUpload (curl)" "$@"
|
||||
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "upload" "$@" &
|
||||
}
|
||||
else
|
||||
# simple curl or wget call outputs result to stdout
|
||||
@ -392,11 +419,12 @@ else
|
||||
res="$(wget --no-check-certificate -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - --post-data='{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' \
|
||||
--header='Content-Type:application/json' "${3}" | "${JSONSHFILE}" -s -b -n 2>/dev/null )"
|
||||
sendJsonResult "${res}" "sendJson (wget)" "$@"
|
||||
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "send" "${@}" &
|
||||
}
|
||||
sendUpload() {
|
||||
printf "%s: %s\n" "$(date)" "Sorry, wget does not support file upload\n" >>"${ERRORLOG}"
|
||||
log_error "Sorry, wget does not support file upload"
|
||||
BOTSENT[OK]="false"
|
||||
[[ -z "${SOURCE}" && -n "${BASHBOT_EVENT_SEND[*]}" ]] && event_send "upload" "$@" &
|
||||
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "upload" "$@" &
|
||||
}
|
||||
fi
|
||||
|
||||
@ -413,12 +441,15 @@ sendJsonRetry(){
|
||||
'sendUpload'*)
|
||||
sendUpload "$@"
|
||||
;;
|
||||
'send_album'*)
|
||||
send_album "$@"
|
||||
;;
|
||||
*)
|
||||
printf "%s: Error: unknown function %s, cannot retry\n" "$(date)" "${retry}"
|
||||
log_error "Error: unknown function ${retry}, cannot retry"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
[ "${BOTSENT[OK]}" = "true" ] && printf "%s: Retry OK: %s %s %s\n" "$(date)" "${retry}" "${1}" "${2:0:60}"
|
||||
[ "${BOTSENT[OK]}" = "true" ] && log_error "Retry OK:${retry} ${1} ${2:0:60}"
|
||||
} >>"${ERRORLOG}"
|
||||
|
||||
# process sendJson result
|
||||
@ -431,7 +462,6 @@ sendJsonResult(){
|
||||
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "${1}")"
|
||||
if [ "${BOTSENT[OK]}" = "true" ]; then
|
||||
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "${1}")"
|
||||
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "send" "${@:3}"
|
||||
return
|
||||
# hot path everything OK!
|
||||
else
|
||||
@ -897,8 +927,7 @@ start_bot() {
|
||||
if [ -n "${UPDATE}" ]; then
|
||||
# we got something, do processing
|
||||
[ "${OFFSET}" = "-999" ] && [ "${nextsleep}" -gt "$((maxsleep*2))" ] &&\
|
||||
printf "%s: Recovered from timeout/broken/no connection, continue with telegram updates\n"\
|
||||
"$(date)" >>"${ERRORLOG}"
|
||||
log_error "Recovered from timeout/broken/no connection, continue with telegram updates"
|
||||
# escape bash $ expansion bug
|
||||
((nextsleep+= stepsleep , nextsleep= nextsleep>maxsleep ?maxsleep:nextsleep))
|
||||
UPDATE="${UPDATE//$/\\$}"
|
||||
@ -914,8 +943,7 @@ start_bot() {
|
||||
# ups, something bad happened, wait maxsleep*10
|
||||
(( nextsleep=nextsleep*2 , nextsleep= nextsleep>maxsleep*10 ?maxsleep*10:nextsleep ))
|
||||
[ "${OFFSET}" = "-999" ] &&\
|
||||
printf "%s: Repeated timeout/broken/no connection on telegram update, sleep %ds\n"\
|
||||
"$(date)" "$(_round_float "${nextsleep}e-3")" >>"${ERRORLOG}"
|
||||
log_error "Repeated timeout/broken/no connection on telegram update, sleep $(_round_float "${nextsleep}e-3")s"
|
||||
OFFSET="-999"
|
||||
fi
|
||||
done
|
||||
@ -926,15 +954,19 @@ bot_init() {
|
||||
[ -n "${BASHBOT_HOME}" ] && cd "${BASHBOT_HOME}" || exit 1
|
||||
local DEBUG="$1"
|
||||
# upgrade from old version
|
||||
echo "Check for Update actions ..."
|
||||
local OLDTMP="${BASHBOT_VAR:-.}/tmp-bot-bash"
|
||||
[ -d "${OLDTMP}" ] && { mv -n "${OLDTMP}/"* "${DATADIR}"; rmdir "${OLDTMP}"; }
|
||||
# no more existing modules
|
||||
[ -f "modules/inline.sh" ] && rm -f "modules/inline.sh"
|
||||
# load addons on startup
|
||||
echo "Done."
|
||||
echo "Initialize modules and addons ..."
|
||||
for addons in "${ADDONDIR:-.}"/*.sh ; do
|
||||
# shellcheck source=./modules/aliases.sh
|
||||
[ -r "${addons}" ] && source "${addons}" "init" "${DEBUG}"
|
||||
done
|
||||
echo "Done."
|
||||
#setup bashbot
|
||||
[[ "${UID}" -eq "0" ]] && RUNUSER="nobody"
|
||||
echo -n "Enter User to run basbot [$RUNUSER]: "
|
||||
@ -948,7 +980,7 @@ bot_init() {
|
||||
oldbot="$(ps -fu "$TOUSER" | grep startbot | grep -v -e 'grep' -e '\-startbot' )"
|
||||
[ -n "${oldbot}" ] && \
|
||||
echo -e "${ORANGE}Warning: At least one not upgraded TMUX bot is running! You must stop it with kill command:${NC}\\n${oldbot}"
|
||||
echo "Adjusting user \"${TOUSER}\" files and permissions ..."
|
||||
echo "Adjusting files and permissions for user \"${TOUSER}\" ..."
|
||||
[ -w "bashbot.rc" ] && sed -i '/^[# ]*runas=/ s/runas=.*$/runas="'$TOUSER'"/' "bashbot.rc"
|
||||
chown -R "$TOUSER" . ./*
|
||||
chmod 711 .
|
||||
@ -957,9 +989,23 @@ bot_init() {
|
||||
chmod -R o-r,o-w "${COUNTFILE}"* "${BLOCKEDFILE}"* "${DATADIR}" "${TOKENFILE}" "${BOTADMIN}" "${BOTACL}" 2>/dev/null
|
||||
# jsshDB must writeable by owner
|
||||
find . -name '*.jssh*' -exec chmod u+w \{\} +
|
||||
echo "Done."
|
||||
fi
|
||||
# check if botconf if seems valid
|
||||
echo -e "${GREEN}This is your bot config:${NC}"
|
||||
sed 's/^/\t/' "${BOTCONFIG}.jssh" | grep -vF '["bot_config_key"]'
|
||||
if [[ "$(getConfigKey "bottoken")" =~ ^[0-9]{8,10}:[a-zA-Z0-9_-]{35}$ && "$(getConfigKey "botadmin")" =~ ^[0-9]+$ ]]; then
|
||||
echo -e "Bot config seems to be valid. Should I make a backup copy? (Y/n) Y\b\c"
|
||||
read -r ANSWER
|
||||
if [[ -z "${ANSWER}" || "${ANSWER}" =~ ^[^Nn] ]]; then
|
||||
echo "Copy bot config to ${BOTCONFIG}.jssh.ok ..."
|
||||
cp "${BOTCONFIG}.jssh" "${BOTCONFIG}.jssh.ok"
|
||||
fi
|
||||
else
|
||||
echo -e "${ORANGE}Bot config may not complete, pls check.${NC}"
|
||||
fi
|
||||
# show result
|
||||
ls -l
|
||||
ls -ld "${DATADIR}" "${LOGDIR}" ./*.jssh* ./*.sh
|
||||
}
|
||||
|
||||
if ! _is_function send_message ; then
|
||||
@ -982,10 +1028,9 @@ fi
|
||||
# do not execute if read from other scripts
|
||||
|
||||
if [ -z "${SOURCE}" ]; then
|
||||
|
||||
##############
|
||||
# internal options only for use from bashbot and developers
|
||||
case "$1" in
|
||||
case "${1}" in
|
||||
# update botname botname when starting only
|
||||
"botname"|"start"*)
|
||||
ME="$(getBotName)"
|
||||
@ -1017,16 +1062,19 @@ if [ -z "${SOURCE}" ]; then
|
||||
# cleanup datadir, keep logfile if not empty
|
||||
rm -f -r "${DATADIR:-.}/$3"
|
||||
[ -s "${DATADIR:-.}/$3.log" ] || rm -f "${DATADIR:-.}/$3.log"
|
||||
debug_checks "end outproc" "$@"
|
||||
exit
|
||||
;;
|
||||
# finally starts the read update loop, internal use only1
|
||||
"startbot" )
|
||||
start_bot "$2"
|
||||
debug_checks "end startbot" "$@"
|
||||
exit
|
||||
;;
|
||||
# run after every update to update files and adjust permissions
|
||||
"init")
|
||||
bot_init "$2"
|
||||
debug_checks "end init" "$@"
|
||||
exit
|
||||
;;
|
||||
# print usage sats
|
||||
@ -1045,6 +1093,7 @@ if [ -z "${SOURCE}" ]; then
|
||||
(( MESSAGES+=MSG ))
|
||||
done
|
||||
echo "A total of ${MESSAGES} messages from ${USERS} users are processed."
|
||||
debug_checks "end $1" "$@"
|
||||
exit
|
||||
;;
|
||||
# sedn message to all users
|
||||
@ -1065,6 +1114,7 @@ if [ -z "${SOURCE}" ]; then
|
||||
fi
|
||||
done
|
||||
echo -e "\nMessage \"$*\" sent to ${USERS} users."
|
||||
debug_checks "end $1" "$@"
|
||||
exit
|
||||
;;
|
||||
# does what is says
|
||||
@ -1079,6 +1129,7 @@ if [ -z "${SOURCE}" ]; then
|
||||
echo -e "${ORANGE}No Bot running with UID ${RUNUSER}.${NC}"
|
||||
exit 5
|
||||
fi
|
||||
debug_checks "end status" "$@"
|
||||
;;
|
||||
|
||||
# start bot as background jod and check if bot is running
|
||||
@ -1097,6 +1148,7 @@ if [ -z "${SOURCE}" ]; then
|
||||
echo -e "${RED}An error occurred while starting the bot.${NC}"
|
||||
exit 5
|
||||
fi
|
||||
debug_checks "end start" "$@"
|
||||
;;
|
||||
# does what it says
|
||||
"kill") echo -e "${RED}Command ${GREY}kill${RED} is deprecated, use ${GREY}stop{$RED}instead.${NC}";&
|
||||
@ -1118,6 +1170,7 @@ if [ -z "${SOURCE}" ]; then
|
||||
else
|
||||
echo -e "${ORANGE}No Bot running with UID ${RUNUSER}.${NC}"
|
||||
fi
|
||||
debug_checks "end stop" "$@"
|
||||
exit
|
||||
;;
|
||||
# suspend, resume or kill background jobs
|
||||
@ -1125,6 +1178,7 @@ if [ -z "${SOURCE}" ]; then
|
||||
_is_function job_control || { echo -e "${RED}Module background is not available!${NC}"; exit 3; }
|
||||
ME="$(getConfigKey "botname")"
|
||||
job_control "$1"
|
||||
debug_checks "end background $1" "$@"
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}${REALME##*/}: unknown command${NC}"
|
||||
|
@ -15,7 +15,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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
#
|
||||
|
||||
# adjust your language setting here, e.g.when run from other user or cron.
|
||||
|
@ -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.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# 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.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# 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.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.98-pre-0-g03700cd
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
############
|
||||
# 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.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# 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.98-dev-64-gcac1ea4
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# 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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
@ -1,4 +1,4 @@
|
||||
# list of additional files to check from shellcheck
|
||||
#### $$VERSION$$ v0.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
bashbot.rc
|
||||
mycommands.sh.clean
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
#### $$VERSION$$ v0.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
# shellcheck disable=SC2016
|
||||
#
|
||||
# Easy Versioning in git:
|
||||
|
@ -39,7 +39,7 @@ As an alternative to download the zip files, you can clone the github repository
|
||||
4. Extract all files to your existing bashbot dir
|
||||
5. Run ```sudo ./bashbot.sh init``` to setup your environment after the update
|
||||
|
||||
If you modified ```commands.sh``` move your changes to ```mycommands.sh```, this avoids overwrrite of you changes on updates.
|
||||
If you modified ```commands.sh``` move your changes to ```mycommands.sh```, this avoids overwriting your commands on update.
|
||||
|
||||
Now you can restart your bashbot instances.
|
||||
|
||||
@ -48,25 +48,49 @@ Now you can restart your bashbot instances.
|
||||
**On MacOS** you must install a more recent version of bash, as the default bash is way to old,
|
||||
see e.g. [Install Bash on Mac](http://macappstore.org/bash/)
|
||||
|
||||
**On BSD and MacOS** I recommend to install gnu coreutils and include them in front of your PATH
|
||||
**On BSD and MacOS** I recommend to install gnu coreutils and include them in your PATH
|
||||
environment variable before running bashbot, e.g. the gnu versions of sed, grep, find ...
|
||||
|
||||
On BSD and MacOS you must adjust the shebang line of the scripts ```bashbot.sh``` and ```json.sh``` to point to to the correct bash
|
||||
or use the script: ```examples/bash2env *.sh */*.sh``` to convert them for you.
|
||||
|
||||
Bashbot will stay with /bin/bash shebang, as using a fixed path is more secure than the portable /usr/bin/env variant, see
|
||||
[Security Considerations](../README.md#Security-Considerations)
|
||||
|
||||
I considered to make bashbot BSD sed compatible, but much of the bashbot "magic" relies on
|
||||
(gnu) sed features, e.g. alternation ```|```, non printables ```\n\t\<``` or repeat ```?+``` pattern, not supported by BSD sed.
|
||||
BSD/MacOS sed compatibility will result in a rewrite of all grep/sed commands with an uncertain outcome,
|
||||
see [BSD/MacOS vs. GNU sed](https://riptutorial.com/sed/topic/9436/bsd-macos-sed-vs--gnu-sed-vs--the-posix-sed-specification)
|
||||
to get an impression how different they are.
|
||||
|
||||
In adition you must adjust the shebang line of the scripts ```bashbot.sh``` and ```json.sh``` to point to to the correct bash
|
||||
or use the example script: ```examples/bash2env *.sh */*.sh```
|
||||
If you are a sed guru and can convert the following examples to work correct with gnu and BSD sed, contact me.
|
||||
|
||||
Bashbot will stay with /bin/bash shebang, as using a fixed path is more secure than the portable /usr/bin/env variant, see
|
||||
[Security Considerations](../README.md#Security-Considerations)
|
||||
```bash
|
||||
# easy start
|
||||
sed -n -e '0,/\['"$1"'\]/ s/\['"$1"'\][ \t]\([0-9.,]*\).*/\1/p'
|
||||
OUT="$(sed -e ':a;N;$!ba;s/\r\n/ mynewlinestartshere /g' <<<"$1"| iconv -f utf-8 -t utf-8 -c)"
|
||||
|
||||
### Notes on Updates
|
||||
# more complex
|
||||
address="$(sed <<< "${2}" '/myaddressstartshere /!d;s/.*myaddressstartshere //;s/ *my[nkfltab][a-z]\{2,13\}startshere.*//;s/ *mykeyboardendshere.*//')"
|
||||
|
||||
# for experts?
|
||||
source <( printf "$1"'=( %s )' "$(sed -E -n -e ':x /"text"\]/ { N; s/([^"])\n/\1\\n/g ; tx }' -e '/\["[-0-9a-zA-Z_,."]+"\]\+*\t/ s/\t/=/gp' -e 's/=(true|false)/="\1"/')" )
|
||||
```
|
||||
|
||||
### Notes per Version
|
||||
|
||||
#### Change in storing config values
|
||||
|
||||
Up to version 0.94 bashbot stores config values as values in ```token```, ```botadmin``` and ```count```. Since version 0.96 bashbot
|
||||
uses jsonDB key/value store. Config is stored in ```botconfig.jssh```, counting of users is done in ```count.jssh```.
|
||||
The acl file ```botacl``` stay as is. On first run of bashbot.sh after an update bashbot converts
|
||||
the files to the new config format. Afterwards the files ```token```, ```botadmin``` and ```count``` can be deleted.
|
||||
|
||||
You may notice the new file ```blocked.jssh```, every telegram user or chat id stored here will be blocked from
|
||||
using your bot.
|
||||
|
||||
#### removal of TMUX
|
||||
From version 0.80 on TMUX is no longer needed and the bachsbot command 'attach' is deleted. Old function 'inproc'
|
||||
From version 0.80 on TMUX is no longer needed and the bashbot command 'attach' is deleted. Old function 'inproc'
|
||||
is replaced by 'send_interactive'. send_interactive does checks if an interactive job is running internally.
|
||||
Pls check if you make use of inproc and remove it including the old checks, e.g.
|
||||
```bash
|
||||
@ -107,5 +131,5 @@ The old format is supported for backward compatibility, but may fail for corner
|
||||
|
||||
#### [Next Create Bot](1_firstbot.md)
|
||||
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
@ -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.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
@ -281,5 +281,5 @@ send_action "${CHAT[ID]}" "action"
|
||||
#### [Prev Create Bot](1_firstbot.md)
|
||||
#### [Next Advanced Usage](3_advanced.md)
|
||||
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
@ -289,5 +289,5 @@ Note: If you disable automatic retry, se above, you disable also connection prob
|
||||
#### [Prev Getting started](2_usage.md)
|
||||
#### [Next Expert Use](4_expert.md)
|
||||
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
@ -381,5 +381,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
|
||||
#### [Prev Advanced Use](3_advanced.md)
|
||||
#### [Next Best Practice](5_practice.md)
|
||||
|
||||
#### $$VERSION$$ v0.98-pre-0-g03700cd
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
@ -152,5 +152,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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
@ -1039,5 +1039,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca
|
||||
#### [Prev Best Practice](5_practice.md)
|
||||
#### [Next Notes for Developers](7_develop.md)
|
||||
|
||||
#### $$VERSION$$ v0.98-dev-72-gfb61a48
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
@ -347,5 +347,5 @@ fi
|
||||
|
||||
#### [Prev Function Reference](6_reference.md)
|
||||
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
@ -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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
||||
|
@ -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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -2,7 +2,7 @@
|
||||
# file: run_filename
|
||||
# background job to display content of all new files in WATCHDIR
|
||||
#
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -2,7 +2,7 @@
|
||||
# file: run_filename
|
||||
# background job to display all new files in WATCHDIR
|
||||
#
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -6,7 +6,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.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# 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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
|
||||
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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -1,7 +1,7 @@
|
||||
# file: botacl
|
||||
# a user not listed here, will return false from 'user_is_allowed'
|
||||
#
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
# Format:
|
||||
# user:resource: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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
#
|
||||
# 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.98-dev-17-gdda5b6d
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
#
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
|
@ -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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
|
@ -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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
|
@ -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.98-dev-17-gdda5b6d
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
|
@ -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.98-pre-1-gea92c55
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
#
|
||||
# source from commands.sh to use jsonDB 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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-6-gbee55fe
|
||||
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
@ -25,6 +25,7 @@ LOCATION_URL=$URL'/sendLocation'
|
||||
VENUE_URL=$URL'/sendVenue'
|
||||
ACTION_URL=$URL'/sendChatAction'
|
||||
FORWARD_URL=$URL'/forwardMessage'
|
||||
ALBUM_URL=$URL'/sendMediaGroup'
|
||||
|
||||
send_normal_message() {
|
||||
local len text; text="$(JsonEscape "${2}")"
|
||||
@ -81,11 +82,6 @@ old_send_keyboard() {
|
||||
sendJson "${1}" "${text}"', "reply_markup": {"keyboard": [ '"${keyboard}"' ],"one_time_keyboard": true}' "$MSG_URL"
|
||||
}
|
||||
|
||||
ISEMPTY="ThisTextIsEmptyAndWillBeDeleted"
|
||||
sendEmpty() {
|
||||
sendJson "${@}"
|
||||
[[ "${2}" = *"${ISEMPTY}"* ]] && delete_message "${1}" "${BOTSENT[ID]}" "nolog"
|
||||
}
|
||||
send_keyboard() {
|
||||
if [[ "$3" != *'['* ]]; then old_send_keyboard "${@}"; return; fi
|
||||
local text; text='"text":"'$(JsonEscape "${2}")'"'; [ -z "${2}" ] && text='"text":"'"Keyboard:"'"'
|
||||
@ -95,8 +91,9 @@ send_keyboard() {
|
||||
}
|
||||
|
||||
remove_keyboard() {
|
||||
local text; text='"text":"'$(JsonEscape "${2}")'"'; [ -z "${2}" ] && text='"text":"'"${ISEMPTY}"'"'
|
||||
sendEmpty "${1}" "${text}"', "reply_markup": {"remove_keyboard":true}' "$MSG_URL"
|
||||
local text; text='"text":"'$(JsonEscape "${2}")'"'; [ -z "${2}" ] && text='"text":"'"remove custom keyboard ..."'"'
|
||||
sendJson "${1}" "${text}"', "reply_markup": {"remove_keyboard":true}' "$MSG_URL"
|
||||
[[ -z "${2}" ]] && delete_message "${1}" "${BOTSENT[ID]}" "nolog"
|
||||
#JSON='"text":"$2", "reply_markup": {"remove_keyboard":true}'
|
||||
}
|
||||
send_inline_keyboard() {
|
||||
@ -114,11 +111,35 @@ UPLOADDIR="${BASHBOT_UPLOAD:-${DATADIR}/upload}"
|
||||
# for now this can only send local files with curl!
|
||||
# extend to allow send files by URL or telegram ID
|
||||
send_file() {
|
||||
[ -z "$2" ] && return
|
||||
[[ "$2" = "http"* ]] && return # currently we do not support URL
|
||||
upload_file "${@}"
|
||||
}
|
||||
|
||||
if [ -z "${BASHBOT_WGET}" ] && _exists curl ; then
|
||||
# there are no checks if URL or ID exists
|
||||
# $1 chat $3 ... $n URL or ID
|
||||
send_album(){
|
||||
[ -z "${1}" ] && return 1
|
||||
[ -z "${3}" ] && return 2 # minimum 2 files
|
||||
local CHAT JSON IMAGE; CHAT="${1}"; shift
|
||||
for IMAGE in "$@"
|
||||
do
|
||||
[ -n "${JSON}" ] && JSON+=","
|
||||
JSON+='{"type":"photo","media":"'${IMAGE}'"}'
|
||||
done
|
||||
# shellcheck disable=SC2086
|
||||
res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} "${ALBUM_URL}" -F "chat_id=${CHAT}"\
|
||||
-F "media=[${JSON}]" | "${JSONSHFILE}" -s -b -n 2>/dev/null )"
|
||||
sendJsonResult "${res}" "send_album (curl)" "${CHAT}" "$@"
|
||||
[[ -z "${SOURCE}" && -n "${BASHBOT_EVENT_SEND[*]}" ]] && event_send "album" "$@" &
|
||||
}
|
||||
else
|
||||
send_album(){
|
||||
log_error "Sorry, wget Album upload not yet implemented"
|
||||
BOTSENT[OK]="false"
|
||||
[[ -z "${SOURCE}" && -n "${BASHBOT_EVENT_SEND[*]}" ]] && event_send "album" "$@" &
|
||||
}
|
||||
fi
|
||||
|
||||
upload_file(){
|
||||
local CUR_URL WHAT STATUS file="$2"
|
||||
# file access checks ...
|
||||
|
@ -8,7 +8,7 @@
|
||||
# #### if you start to develop your own bot, use the clean version of this file:
|
||||
# #### mycommands.clean
|
||||
#
|
||||
#### $$VERSION$$ v0.98-pre-0-g03700cd
|
||||
#### $$VERSION$$ v0.98-pre2-7-g3569a76
|
||||
#
|
||||
|
||||
# uncomment the following lines to overwrite info and help messages
|
||||
@ -48,6 +48,10 @@ unset BASHBOT_START_TIMER
|
||||
# set to "yes" and give your bot admin privilegs to remove service messaes from groups
|
||||
export SILENCER="no"
|
||||
|
||||
# uncomment if you use keyboards in your commands
|
||||
# export REMOVEKEYBOARD="yes"
|
||||
# export REMOVEKEYBOARD_PRIVATE="yes"
|
||||
|
||||
# messages for admin only commands
|
||||
NOTADMIN="Sorry, this command is allowed for admin or owner only"
|
||||
NOTBOTADMIN="Sorry, this command is allowed for bot owner only"
|
||||
@ -82,6 +86,10 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# remove keyboard if you use keyboards
|
||||
[ -n "${REMOVEKEYBOARD}" ] && remove_keyboard "${CHAT[ID]}" &
|
||||
[[ -n "${REMOVEKEYBOARD_PRIVATE}" && "${CHAT[ID]}" == "${USER[ID]}" ]] && remove_keyboard "${CHAT[ID]}" &
|
||||
|
||||
# example for actions based on chat or sender
|
||||
case "${USER[ID]}+${CHAT[ID]}" in
|
||||
'USERID+'*) # do something for all messages from USER
|
||||
@ -218,7 +226,6 @@ else
|
||||
answer_inline_query "${iQUERY[ID]}" "cached_gif" "BQADBAADIwYAAmwsDAABlIia56QGP0YC"
|
||||
;;
|
||||
esac
|
||||
set +x
|
||||
}
|
||||
|
||||
# place your processing functions here
|
||||
|
@ -4,7 +4,7 @@
|
||||
# files: mycommands.sh.clean
|
||||
# copy to mycommands.sh and add all your commands and functions here ...
|
||||
#
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-7-g3569a76
|
||||
#
|
||||
|
||||
##########
|
||||
@ -45,6 +45,10 @@ unset BASHBOT_START_TIMER
|
||||
# set to "yes" and give your bot admin privilegs to remove service messaes from groups
|
||||
export SILENCER="no"
|
||||
|
||||
# uncomment if you use keyboards in your commands
|
||||
# export REMOVEKEYBOARD="yes"
|
||||
# export REMOVEKEYBOARD_PRIVATE="yes"
|
||||
|
||||
########
|
||||
# special network setups may require to provide additional ARGS to curl
|
||||
#
|
||||
@ -78,6 +82,10 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# remove keyboard if you use keyboards
|
||||
[ -n "${REMOVEKEYBOARD}" ] && remove_keyboard "${CHAT[ID]}" &
|
||||
[[ -n "${REMOVEKEYBOARD_PRIVATE}" && "${CHAT[ID]}" == "${USER[ID]}" ]] && remove_keyboard "${CHAT[ID]}" &
|
||||
|
||||
case "${MESSAGE}" in
|
||||
##################
|
||||
# example command, replace them by your own
|
||||
|
@ -6,7 +6,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.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# ADD a new test skeleton to test dir, but does not activate test
|
||||
#
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# 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.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# common variables
|
||||
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
../dev/hooks/pre-commit.sh
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# file: b-example-test.sh
|
||||
#### $$VERSION$$ v0.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.96-0-g3871ca9
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
||||
#### $$VERSION$$ v0.98-pre2-0-ga597303
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
Loading…
Reference in New Issue
Block a user