some small fixes, start dev3

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-05-14 13:04:57 +02:00
parent eef955abf3
commit 8a119f8806
55 changed files with 90 additions and 69 deletions

View File

@ -223,6 +223,6 @@ It features background tasks and interactive chats, and can serve as an interfac
<p>@Gnadelwartz</p> <p>@Gnadelwartz</p>
<h2>That's it!</h2> <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> <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.94-dev2-0-g3d636f7</h4> <h4>$$VERSION$$ v0.94-dev3-0-geef955a</h4>
</body> </body>
</html> </html>

View File

@ -180,4 +180,4 @@ This may happen if to many wrong requests are sent to api.telegram.org, e.g. usi
If you feel that there's something missing or if you found a bug, feel free to submit a pull request! If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -253,4 +253,4 @@ tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in
If you feel that there's something missing or if you found a bug, feel free to If you feel that there's something missing or if you found a bug, feel free to
submit a pull request! submit a pull request!
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -4,7 +4,7 @@
# this addon counts how many files, e.g. stickers, are sent to # this addon counts how many files, e.g. stickers, are sent to
# a chat and takes actions if threshold is reached # a chat and takes actions if threshold is reached
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# used events: # used events:
# #

View File

@ -4,7 +4,7 @@
# Addons can register to bashbot events at statup # Addons can register to bashbot events at statup
# by providing their name and a callback per event # by providing their name and a callback per event
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# #
# If an event occours each registered event function is called. # If an event occours each registered event function is called.
# #

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# description: Start or stop telegram-bash-bot # description: Start or stop telegram-bash-bot
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# shellcheck disable=SC2009 # shellcheck disable=SC2009
# shellcheck disable=SC2181 # shellcheck disable=SC2181
@ -76,6 +76,10 @@ case "$1" in
'suspendback'|'resumeback'|'killback') 'suspendback'|'resumeback'|'killback')
$runcmd "$start $1" $runcmd "$start $1"
RETVAL=$? RETVAL=$?
# kill inotifywait from runuser
if [ "$1" != "resumeback" ]; then
kill -9 "$(ps -u "$runas" | grep inotifywait | sed 's/ .*//')" >/dev/null 2>&1
fi
;; ;;
*) *)
echo "Usage: $0 { start | stop | restart | reload | restartback | suspendback | resumeback | killback }" echo "Usage: $0 { start | stop | restart | reload | restartback | suspendback | resumeback | killback }"

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# #
# Exit Codes: # Exit Codes:
# - 0 sucess (hopefully) # - 0 sucess (hopefully)
@ -136,7 +136,7 @@ declare -rx SCRIPT SCRIPTDIR MODULEDIR RUNDIR ADDONDIR TOKENFILE BOTADMIN BOTACL
declare -rx BOTTOKEN URL ME_URL UPD_URL GETFILE_URL declare -rx BOTTOKEN URL ME_URL UPD_URL GETFILE_URL
declare -ax CMD declare -ax CMD
declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY SERVICE NEWMEMBER
export res CAPTION export res CAPTION
@ -239,7 +239,7 @@ if [ "${BASHBOT_WGET}" = "" ] && _exists curl ; then
local chat=""; local chat="";
[ "${1}" != "" ] && chat='"chat_id":'"${1}"',' [ "${1}" != "" ] && chat='"chat_id":'"${1}"','
# shellcheck disable=SC2086 # shellcheck disable=SC2086
res="$(curl -s ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" -d '{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' -X POST "${3}" \ res="$(curl -s -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" -d '{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' -X POST "${3}" \
-H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n )" -H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n )"
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")" BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")"
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")" BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")"
@ -269,7 +269,7 @@ else
local chat=""; local chat="";
[ "${1}" != "" ] && chat='"chat_id":'"${1}"',' [ "${1}" != "" ] && chat='"chat_id":'"${1}"','
# shellcheck disable=SC2086 # shellcheck disable=SC2086
res="$(wget -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - --post-data='{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' \ 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 )" --header='Content-Type:application/json' "${3}" | "${JSONSHFILE}" -s -b -n )"
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")" BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")"
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")" BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")"
@ -596,9 +596,25 @@ process_message() {
LOCATION[LONGITUDE]="${UPD["result",${num},"message","location","longitude"]}" LOCATION[LONGITUDE]="${UPD["result",${num},"message","location","longitude"]}"
LOCATION[LATITUDE]="${UPD["result",${num},"message","location","latitude"]}" LOCATION[LATITUDE]="${UPD["result",${num},"message","location","latitude"]}"
# service messages
SERVICE=( ); NEWMEMBER=( )
SERVICE[NEWMEMBER]="${UPD["result",${num},"message","new_chat_member","id"]}"
if [ "${SERVICE[NEWMEMBER]}" != "" ]; then
NEWMEMBER[ID]="${SERVICE[NEWMEMBER]}"
NEWMEMBER[FIRSTNAME]="${UPD["result",${num},"message","new_chat_member","first_name"]}"
NEWMEMBER[LASTNAME]="${UPD["result",${num},"message","new_chat_member","last_name"]}"
NEWMEMBER[USERNAME]="${UPD["result",${num},"message","new_chat_member","username"]}"
NEWMEMBER[ISBOT]="${UPD["result",${num},"message","new_chat_member","is_bot"]}"
fi
SERVICE[LEFTMEMBER]="${UPD["result",${num},"message","left_chat_member","id"]}"
SERVICE[NEWTILE]="${UPD["result",${num},"message","new_chat_title"]}"
SERVICE[NEWPHOTO]="${UPD["result",${num},"message","new_chat_photo"]}"
SERVICE[PINNED]="${UPD["result",${num},"message","pinned_message"]}"
# split message in command and args # split message in command and args
CMD=( ) CMD=( )
if [[ "${MESSAGE[0]}" = "/"* ]]; then if [[ "${MESSAGE[0]}" == "/"* ]]; then
set -f; unset IFS set -f; unset IFS
# shellcheck disable=SC2206 # shellcheck disable=SC2206
CMD=( ${MESSAGE[0]} ) CMD=( ${MESSAGE[0]} )
@ -626,6 +642,8 @@ start_bot() {
# shellcheck source=./modules/aliases.sh # shellcheck source=./modules/aliases.sh
[ -r "${addons}" ] && source "${addons}" "startbot" "${DEBUG}" [ -r "${addons}" ] && source "${addons}" "startbot" "${DEBUG}"
done done
# shellcheck source=./commands.sh
source "${COMMANDS}" "startbot"
# start timer events # start timer events
if _is_function start_timer ; then if _is_function start_timer ; then
# shellcheck disable=SC2064 # shellcheck disable=SC2064

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# #
# adjust your language setting here, e.g.when run from other user or cron. # adjust your language setting here, e.g.when run from other user or cron.

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# this has to run once atfer git clone # this has to run once atfer git clone
# and every time we create new hooks # and every time we create new hooks
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -3,7 +3,7 @@
# #
# works together with git pre-push.sh and ADD all changed files since last push # works together with git pre-push.sh and ADD all changed files since last push
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
############ ############
# NOTE: you MUST run install-hooks.sh again when updating this file! # NOTE: you MUST run install-hooks.sh again when updating this file!

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
############ ############
# NOTE: you MUST run install-hooks.sh again when updating this file! # NOTE: you MUST run install-hooks.sh again when updating this file!

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# this has to run once atfer git clone # this has to run once atfer git clone
# and every time we create new hooks # and every time we create new hooks
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -2,7 +2,7 @@
# file: make-distribution.sh # file: make-distribution.sh
# creates files and arcchives to dirtribute bashbot # creates files and arcchives to dirtribute bashbot
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -5,7 +5,7 @@
# If you your bot is finished you can use make-standalone.sh to create the # 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! # the old all-in-one bashbot: bashbot.sh and commands.sh only!
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -1,3 +1,3 @@
# list of additional files to check from shellcheck # list of additional files to check from shellcheck
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
bashbot.rc bashbot.rc

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# shellcheck disable=SC2016 # shellcheck disable=SC2016
# #
# Easy Versioning in git: # Easy Versioning in git:

View File

@ -87,5 +87,5 @@ The old format is supported for backward compatibility, but may fail for corner
#### [Next Create Bot](1_firstbot.md) #### [Next Create Bot](1_firstbot.md)
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -65,5 +65,5 @@ group. This step is up to you actually.
#### [Prev Installation](0_install.md) #### [Prev Installation](0_install.md)
#### [Next Getting started](2_usage.md) #### [Next Getting started](2_usage.md)
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -223,5 +223,5 @@ send_action "${CHAT[ID]}" "action"
#### [Prev Create Bot](1_firstbot.md) #### [Prev Create Bot](1_firstbot.md)
#### [Next Advanced Usage](3_advanced.md) #### [Next Advanced Usage](3_advanced.md)
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -180,5 +180,5 @@ See also [answer_inline_multi, answer_inline_compose](6_reference.md#answer_inli
#### [Prev Getting started](2_usage.md) #### [Prev Getting started](2_usage.md)
#### [Next Expert Use](4_expert.md) #### [Next Expert Use](4_expert.md)
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -348,5 +348,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
#### [Prev Advanced Use](3_advanced.md) #### [Prev Advanced Use](3_advanced.md)
#### [Next Best Practice](5_practice.md) #### [Next Best Practice](5_practice.md)
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -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) #### [Prev Best Practice](5_practice.md)
#### [Next Functions Reference](6_reference.md) #### [Next Functions Reference](6_reference.md)
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -947,5 +947,5 @@ The name of your bot is availible as bash variable "$ME", there is no need to ca
#### [Prev Best Practice](5_practice.md) #### [Prev Best Practice](5_practice.md)
#### [Next Notes for Developers](7_develop.md) #### [Next Notes for Developers](7_develop.md)
#### $$VERSION$$ v0.94-dev2-1-g4f90215 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -321,5 +321,5 @@ fi
#### [Prev Function Reference](6_reference.md) #### [Prev Function Reference](6_reference.md)
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -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. **external-use** will contain some examples on how to send messages from external scripts to Telegram chats or users.
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a

View File

@ -4,7 +4,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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file: run_filename # file: run_filename
# background job to display content of all new files in WATCHDIR # background job to display content of all new files in WATCHDIR
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file: run_filename # file: run_filename
# background job to display all new files in WATCHDIR # background job to display all new files in WATCHDIR
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -4,7 +4,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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file. multibot.sh # file. multibot.sh
# description: run multiple telegram bots from one installation # description: run multiple telegram bots from one installation
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
echo "Usage: $0 botname command" echo "Usage: $0 botname command"

View File

@ -7,7 +7,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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
SHELL=/bin/sh SHELL=/bin/sh

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -4,7 +4,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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -1,7 +1,7 @@
# file: botacl # file: botacl
# a user not listed here, will return false from 'user_is_allowed' # a user not listed here, will return false from 'user_is_allowed'
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# Format: # Format:
# user:ressource:chat # user:ressource:chat

View File

@ -5,7 +5,7 @@
# to show how you can customize bashbot by only editing mycommands.sh # to show how you can customize bashbot by only editing mycommands.sh
# NOTE: this is not tested, simply copied from original source and reworked! # NOTE: this is not tested, simply copied from original source and reworked!
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# #
# shellcheck disable=SC2154 # shellcheck disable=SC2154
# shellcheck disable=SC2034 # shellcheck disable=SC2034

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# #
# source from commands.sh to use the aliases # source from commands.sh to use the aliases

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# source from commands.sh to use the inline functions # source from commands.sh to use the inline functions

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# source from commands.sh if you want ro use interactive or background jobs # source from commands.sh if you want ro use interactive or background jobs

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# source from commands.sh to use the member functions # source from commands.sh to use the member functions
@ -48,7 +48,6 @@ user_is_admin() {
user_is_botadmin() { user_is_botadmin() {
local admin; admin="$(head -n 1 "${BOTADMIN}")" local admin; admin="$(head -n 1 "${BOTADMIN}")"
[ "${admin}" = "${1}" ] && return 0 [ "${admin}" = "${1}" ] && return 0
[ "${admin}" = "${2}" ] && return 0
[[ "${admin}" = "@*" ]] && [[ "${admin}" = "${2}" ]] && return 0 [[ "${admin}" = "@*" ]] && [[ "${admin}" = "${2}" ]] && return 0
if [ "${admin}" = "?" ]; then printf '%s\n' "${1:-?}" >"${BOTADMIN}"; return 0; fi if [ "${admin}" = "?" ]; then printf '%s\n' "${1:-?}" >"${BOTADMIN}"; return 0; fi
return 1 return 1

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# #
# source from commands.sh to use jsonDB functions # source from commands.sh to use jsonDB functions
# #

View File

@ -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.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# source from commands.sh to use the sendMessage functions # source from commands.sh to use the sendMessage functions
@ -22,7 +22,7 @@ ACTION_URL=$URL'/sendChatAction'
FORWARD_URL=$URL'/forwardMessage' FORWARD_URL=$URL'/forwardMessage'
send_normal_message() { send_normal_message() {
local text="$(JsonEscape "${2}")" local text; text="$(JsonEscape "${2}")"
until [ -z "${text}" ]; do until [ -z "${text}" ]; do
sendJson "${1}" '"text":"'"${text:0:4096}"'"' "${MSG_URL}" sendJson "${1}" '"text":"'"${text:0:4096}"'"' "${MSG_URL}"
text="${text:4096}" text="${text:4096}"
@ -30,7 +30,7 @@ send_normal_message() {
} }
send_markdown_message() { send_markdown_message() {
local text="$(JsonEscape "${2}")" local text; text="$(JsonEscape "${2}")"
until [ -z "${text}" ]; do until [ -z "${text}" ]; do
sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"markdown"' "${MSG_URL}" sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"markdown"' "${MSG_URL}"
text="${text:4096}" text="${text:4096}"
@ -38,7 +38,7 @@ send_markdown_message() {
} }
send_html_message() { send_html_message() {
local text="$(JsonEscape "${2}")" local text; text="$(JsonEscape "${2}")"
until [ -z "${text}" ]; do until [ -z "${text}" ]; do
sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"html"' "${MSG_URL}" sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"html"' "${MSG_URL}"
text="${text:4096}" text="${text:4096}"
@ -46,7 +46,7 @@ send_html_message() {
} }
old_send_keyboard() { old_send_keyboard() {
local text='"text":"'$(JsonEscape "${2}")'"' local text; text='"text":"'$(JsonEscape "${2}")'"'
shift 2 shift 2
local keyboard="init" local keyboard="init"
OLDIFS="$IFS" OLDIFS="$IFS"
@ -64,24 +64,24 @@ sendEmpty() {
} }
send_keyboard() { send_keyboard() {
if [[ "$3" != *'['* ]]; then old_send_keyboard "${@}"; return; fi if [[ "$3" != *'['* ]]; then old_send_keyboard "${@}"; return; fi
local text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"' local text; text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"'
local one_time=', "one_time_keyboard":true' && [ "$4" != "" ] && one_time="" local one_time=', "one_time_keyboard":true' && [ "$4" != "" ] && one_time=""
sendEmpty "${1}" "${text}"', "reply_markup": {"keyboard": [ '"${3}"' ] '"${one_time}"'}' "$MSG_URL" sendEmpty "${1}" "${text}"', "reply_markup": {"keyboard": [ '"${3}"' ] '"${one_time}"'}' "$MSG_URL"
# '"text":"$2", "reply_markup": {"keyboard": [ ${3} ], "one_time_keyboard": true}' # '"text":"$2", "reply_markup": {"keyboard": [ ${3} ], "one_time_keyboard": true}'
} }
remove_keyboard() { remove_keyboard() {
local text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"' local text; text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"'
sendEmpty "${1}" "${text}"', "reply_markup": {"remove_keyboard":true}' "$MSG_URL" sendEmpty "${1}" "${text}"', "reply_markup": {"remove_keyboard":true}' "$MSG_URL"
#JSON='"text":"$2", "reply_markup": {"remove_keyboard":true}' #JSON='"text":"$2", "reply_markup": {"remove_keyboard":true}'
} }
send_inline_keyboard() { send_inline_keyboard() {
local text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"' local text; text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"'
sendEmpty "${1}" "${text}"', "reply_markup": {"inline_keyboard": [ '"${3}"' ]}' "$MSG_URL" sendEmpty "${1}" "${text}"', "reply_markup": {"inline_keyboard": [ '"${3}"' ]}' "$MSG_URL"
# JSON='"text":"$2", "reply_markup": {"inline_keyboard": [ $3->[{"text":"text", "url":"url"}]<- ]}' # JSON='"text":"$2", "reply_markup": {"inline_keyboard": [ $3->[{"text":"text", "url":"url"}]<- ]}'
} }
send_button() { send_button() {
send_inline_keyboard "${1}" "${2}" '[ {"text":"'$(JsonEscape "${3}")'", "url":"'"${4}"'"}]' send_inline_keyboard "${1}" "${2}" '[ {"text":"'"$(JsonEscape "${3}")"'", "url":"'"${4}"'"}]'
} }
@ -114,7 +114,7 @@ upload_file(){
WHAT="audio" WHAT="audio"
STATUS="upload_audio" STATUS="upload_audio"
;; ;;
png|jpg|jpeg|gif) png|jpg|jpeg|gif|pic)
CUR_URL="$PHO_URL" CUR_URL="$PHO_URL"
WHAT="photo" WHAT="photo"
STATUS="upload_photo" STATUS="upload_photo"

View File

@ -2,7 +2,7 @@
# files: mycommands.sh.dist # files: mycommands.sh.dist
# copy to mycommands.sh and add all your commands and functions here ... # copy to mycommands.sh and add all your commands and functions here ...
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# #
# uncomment the following lines to overwrite info and help messages # uncomment the following lines to overwrite info and help messages

View File

@ -2,7 +2,7 @@
# #
# ADD a new test skeleton to test dir, but does not activate test # ADD a new test skeleton to test dir, but does not activate test
# #
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# magic to ensure that we're always inside the root of our application, # magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script # no matter from which directory we'll run script

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# common variables # common variables
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
../dev/hooks/pre-commit.sh ../dev/hooks/pre-commit.sh

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# file: b-example-test.sh # file: b-example-test.sh
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### $$VERSION$$ v0.94-dev2-0-g3d636f7 #### $$VERSION$$ v0.94-dev3-0-geef955a
# include common functions and definitions # include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh # shellcheck source=test/ALL-tests.inc.sh