mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-01-17 02:55:11 +00:00
Merge branch 'develop' into master
This commit is contained in:
commit
a2f10bf70e
@ -224,10 +224,10 @@ It features background tasks and interactive chats, and can serve as an interfac
|
|||||||
<a class="sourceLine" id="cb4-3" title="3"></a>
|
<a class="sourceLine" id="cb4-3" title="3"></a>
|
||||||
<a class="sourceLine" id="cb4-4" title="4"><span class="fu">wget</span> -t 1 -T 10 https://api.telegram.org/bot</a>
|
<a class="sourceLine" id="cb4-4" title="4"><span class="fu">wget</span> -t 1 -T 10 https://api.telegram.org/bot</a>
|
||||||
<a class="sourceLine" id="cb4-5" title="5"><span class="co">#Connecting to api.telegram.org (api.telegram.org)|46.38.243.234|:443... failed: Connection timed out.</span></a></code></pre></div>
|
<a class="sourceLine" id="cb4-5" title="5"><span class="co">#Connecting to api.telegram.org (api.telegram.org)|46.38.243.234|:443... failed: Connection timed out.</span></a></code></pre></div>
|
||||||
<p>This may happen if to many wrong requests are sent to api.telegram.org, e.g. using a wrong token or not existing API calls. If you have a fixed IP you can ask telegram service to unblock your ip or change your IP. If you are running a tor proxy on your server you may uncomment the <code>BASHBOT_CURL_ARGS</code> line in 'mycommands.sh'</p>
|
<p>This may happen if to many wrong requests are sent to api.telegram.org, e.g. using a wrong token or not existing API calls. If you have a fixed IP you can ask telegram service to unblock your ip or change your IP. If you are running a socks or tor proxy on your server look for the <code>BASHBOT_CURL_ARGS</code> lines in 'mycommands.sh' as example.</p>
|
||||||
<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-9-g46af634</h4>
|
<h4>$$VERSION$$ v0.96-dev-8-ge63590b</h4>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -188,7 +188,7 @@ curl -m 10 https://api.telegram.org/bot
|
|||||||
wget -t 1 -T 10 https://api.telegram.org/bot
|
wget -t 1 -T 10 https://api.telegram.org/bot
|
||||||
#Connecting to api.telegram.org (api.telegram.org)|46.38.243.234|:443... failed: Connection timed out.
|
#Connecting to api.telegram.org (api.telegram.org)|46.38.243.234|:443... failed: Connection timed out.
|
||||||
```
|
```
|
||||||
This may happen if to many wrong requests are sent to api.telegram.org, e.g. using a wrong token or not existing API calls. If you have a fixed IP you can ask telegram service to unblock your ip or change your IP. If you are running a tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in 'mycommands.sh'
|
This may happen if to many wrong requests are sent to api.telegram.org, e.g. using a wrong token or not existing API calls. If you have a fixed IP you can ask telegram service to unblock your ip or change your IP. If you are running a socks or tor proxy on your server look for the ```BASHBOT_CURL_ARGS``` lines in 'mycommands.sh' as example.
|
||||||
|
|
||||||
|
|
||||||
@Gnadelwartz
|
@Gnadelwartz
|
||||||
@ -197,4 +197,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-9-g46af634
|
#### $$VERSION$$ v0.96-dev-8-ge63590b
|
||||||
|
@ -259,8 +259,8 @@ failed: Connection timed out.
|
|||||||
This may happen if to many wrong requests are sent to api.telegram.org, e.g.
|
This may happen if to many wrong requests are sent to api.telegram.org, e.g.
|
||||||
using a wrong token or not existing API calls. If you have a fixed IP you can
|
using a wrong token or not existing API calls. If you have a fixed IP you can
|
||||||
ask telegram service to unblock your ip or change your IP. If you are running a
|
ask telegram service to unblock your ip or change your IP. If you are running a
|
||||||
tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in
|
socks or tor proxy on your server look for the ```BASHBOT_CURL_ARGS``` lines
|
||||||
'mycommands.sh'
|
in 'mycommands.sh' as example.
|
||||||
|
|
||||||
|
|
||||||
@Gnadelwartz
|
@Gnadelwartz
|
||||||
@ -270,4 +270,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-9-g46af634
|
#### $$VERSION$$ v0.96-dev-8-ge63590b
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# used events:
|
# used events:
|
||||||
#
|
#
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
#
|
#
|
||||||
# If an event occours each registered event function is called.
|
# If an event occours each registered event function is called.
|
||||||
#
|
#
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
# shellcheck disable=SC2009
|
# shellcheck disable=SC2009
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
|
|
||||||
|
@ -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-8-g3d92bf3
|
#### $$VERSION$$ v0.96-dev-8-ge63590b
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 sucess (hopefully)
|
# - 0 sucess (hopefully)
|
||||||
@ -318,7 +318,7 @@ fi
|
|||||||
# $1 string
|
# $1 string
|
||||||
# output escaped string
|
# output escaped string
|
||||||
JsonEscape() {
|
JsonEscape() {
|
||||||
sed 's/\([-"`´,§$%&ß/(){}#@?*]\)/\\\1/g' <<< "$1"
|
sed 's/\([-"`´,§$%&/(){}#@!?*.]\)/\\\1/g' <<< "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# convert common telegram entities to JSON
|
# convert common telegram entities to JSON
|
||||||
|
@ -15,7 +15,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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
#
|
#
|
||||||
|
|
||||||
# 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.
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
############
|
############
|
||||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
############
|
############
|
||||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
# NOTE: you MUST run install-hooks.sh again when updating this 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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# list of additional files to check from shellcheck
|
# list of additional files to check from shellcheck
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
bashbot.rc
|
bashbot.rc
|
||||||
mycommands.sh.clean
|
mycommands.sh.clean
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
#
|
#
|
||||||
# Easy Versioning in git:
|
# Easy Versioning in git:
|
||||||
|
@ -101,5 +101,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-8-g876361f
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
@ -241,5 +241,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-2-gced78d3
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
@ -685,6 +685,22 @@ Deleted a key=value pair froma jsshDB file, key name is only allowed to contain
|
|||||||
jssh_deleteKeyDB "delkey"" "${DATADIR:-.}/myvalues"
|
jssh_deleteKeyDB "delkey"" "${DATADIR:-.}/myvalues"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### jssh_countKeyDB
|
||||||
|
Increase a key=value pair from a jsshDB file by 1, key name is only allowed to contain '-a-zA-Z0-9,._'
|
||||||
|
If value is given key is increased by value.
|
||||||
|
|
||||||
|
Side effect: if value is given key is updated "in place" (slower) and file is cleand up, if no value is given fast path is used
|
||||||
|
and new count is added to the end of file.
|
||||||
|
|
||||||
|
*usage:* jssh_countKeyDB "key" "filename" ["value"]
|
||||||
|
|
||||||
|
*usage:* jssh_countKeyDB_async "key" "filename" ["value"]
|
||||||
|
|
||||||
|
*example:*
|
||||||
|
```bash
|
||||||
|
jssh_countKeyDB "usercount"" "${DATADIR:-.}/myvalues"
|
||||||
|
```
|
||||||
|
|
||||||
https://linuxhint.com/associative_array_bash/
|
https://linuxhint.com/associative_array_bash/
|
||||||
|
|
||||||
https://linuxconfig.org/how-to-use-arrays-in-bash-script
|
https://linuxconfig.org/how-to-use-arrays-in-bash-script
|
||||||
@ -973,5 +989,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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
@ -328,5 +328,5 @@ fi
|
|||||||
|
|
||||||
#### [Prev Function Reference](6_reference.md)
|
#### [Prev Function Reference](6_reference.md)
|
||||||
|
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -6,7 +6,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-7-g3d92bf3
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
|
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
|
||||||
echo "Usage: $0 botname command"
|
echo "Usage: $0 botname command"
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
|
|
||||||
SHELL=/bin/sh
|
SHELL=/bin/sh
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
# Format:
|
# Format:
|
||||||
# user:ressource:chat
|
# user:ressource:chat
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
#
|
#
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
#
|
#
|
||||||
# source from commands.sh to use the aliases
|
# source from commands.sh to use the aliases
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# source from commands.sh to use the inline functions
|
# source from commands.sh to use the inline functions
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# source once magic, function named like file
|
# source once magic, function named like file
|
||||||
eval "$(basename "${BASH_SOURCE[0]}")(){ :; }"
|
eval "$(basename "${BASH_SOURCE[0]}")(){ :; }"
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
#
|
#
|
||||||
# source from commands.sh to use jsonDB functions
|
# source from commands.sh to use jsonDB functions
|
||||||
#
|
#
|
||||||
@ -36,7 +36,7 @@ if _exists flock; then
|
|||||||
local DB; DB="$(jssh_checkDB "$2")"
|
local DB; DB="$(jssh_checkDB "$2")"
|
||||||
[ -z "${DB}" ] && return 1
|
[ -z "${DB}" ] && return 1
|
||||||
[ ! -f "${DB}" ] && return 2
|
[ ! -f "${DB}" ] && return 2
|
||||||
# shared lock, many processes can read, maximum wait 1s
|
# shared lock, many processes can read, max wait 1s
|
||||||
{ flock -s -w 1 200; Json2Array "$1" <"${DB}"; } 200>"${DB}${BASHBOT_LOCKNAME}"
|
{ flock -s -w 1 200; Json2Array "$1" <"${DB}"; } 200>"${DB}${BASHBOT_LOCKNAME}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ if _exists flock; then
|
|||||||
local DB; DB="$(jssh_checkDB "$3")"
|
local DB; DB="$(jssh_checkDB "$3")"
|
||||||
[ -z "${DB}" ] && return 1
|
[ -z "${DB}" ] && return 1
|
||||||
[ ! -f "${DB}" ] && return 2
|
[ ! -f "${DB}" ] && return 2
|
||||||
# start atomic update here, exclusive max wait 2si, it's append, not overwrite
|
# start atomic update here, exclusive max wait 2, it's append, not overwrite
|
||||||
{ flock -e -w 2 200
|
{ flock -e -w 2 200
|
||||||
# it's append, but last one counts, its a simple DB ...
|
# it's append, but last one counts, its a simple DB ...
|
||||||
printf '["%s"]\t"%s"\n' "${key//,/\",\"}" "${value//\"/\\\"}" >>"${DB}"
|
printf '["%s"]\t"%s"\n' "${key//,/\",\"}" "${value//\"/\\\"}" >>"${DB}"
|
||||||
@ -118,6 +118,44 @@ if _exists flock; then
|
|||||||
} 200>"${DB}${BASHBOT_LOCKNAME}"
|
} 200>"${DB}${BASHBOT_LOCKNAME}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# delete key/value from jsshDB
|
||||||
|
# $1 key name, can onyl contain -a-zA-Z0-9,._
|
||||||
|
# $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
|
||||||
|
jssh_getKeyDB() {
|
||||||
|
[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
|
||||||
|
local DB; DB="$(jssh_checkDB "$2")"
|
||||||
|
declare -A oldARR
|
||||||
|
# start atomic delete here, exclusive max wait 1s
|
||||||
|
{ flock -e -w 1 200
|
||||||
|
Json2Array "oldARR" <"${DB}"
|
||||||
|
} 200>"${DB}${BASHBOT_LOCKNAME}"
|
||||||
|
echo "${oldARR["$1"]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# add a value to key, used for conters
|
||||||
|
# $1 key name, can onyl contain -a-zA-Z0-9,._
|
||||||
|
# $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..'
|
||||||
|
# $3 optional count, value added to count3r, add 1 if empty
|
||||||
|
# side effect: if $3 is not given, we add to end of file to be as fast as possible
|
||||||
|
jssh_countKeyDB() {
|
||||||
|
[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
|
||||||
|
local DB; DB="$(jssh_checkDB "$2")"
|
||||||
|
declare -A oldARR
|
||||||
|
# start atomic delete here, exclusive max wait 5
|
||||||
|
{ flock -e -w 5 200
|
||||||
|
Json2Array "oldARR" <"${DB}"
|
||||||
|
if [ "$3" != "" ]; then
|
||||||
|
(( oldARR["$1"]+="$3" ));
|
||||||
|
Array2Json "oldARR" >"${DB}"
|
||||||
|
else
|
||||||
|
# it's append, but last one counts, its a simple DB ...
|
||||||
|
(( oldARR["$1"]++ ));
|
||||||
|
printf '["%s"]\t"%s"\n' "${1//,/\",\"}" "${oldARR["$1"]//\"/\\\"}" >>"${DB}"
|
||||||
|
fi
|
||||||
|
} 200>"${DB}${BASHBOT_LOCKNAME}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
#########
|
#########
|
||||||
@ -142,6 +180,13 @@ else
|
|||||||
jssh_deleteKeyDB() {
|
jssh_deleteKeyDB() {
|
||||||
jssh_deleteKeyDB_async "$@"
|
jssh_deleteKeyDB_async "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jssh_getKeyDB() {
|
||||||
|
jssh_getKeyDB_async "$@"
|
||||||
|
}
|
||||||
|
jssh_countKeyDB() {
|
||||||
|
jssh_countKeyDB "$@"
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##############
|
##############
|
||||||
@ -244,3 +289,22 @@ jssh_deleteKeyDB_async() {
|
|||||||
jssh_writeDB_async "oldARR" "$2"
|
jssh_writeDB_async "oldARR" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jssh_getKeyDB_async() {
|
||||||
|
[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
|
||||||
|
local DB; DB="$(jssh_checkDB "$2")"
|
||||||
|
declare -A oldARR
|
||||||
|
Json2Array "oldARR" <"${DB}"
|
||||||
|
echo "${oldARR["$1"]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
jssh_countKeyDB_async() {
|
||||||
|
[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
|
||||||
|
local DB COUNT="1"; DB="$(jssh_checkDB "$2")"
|
||||||
|
[ "$3" != "" ] && COUNT="$3"
|
||||||
|
declare -A oldARR
|
||||||
|
# start atomic delete here, exclusive max wait 10s
|
||||||
|
Json2Array "oldARR" <"${DB}"
|
||||||
|
(( oldARR["$1"]+=COUNT ));
|
||||||
|
Array2Json "oldARR" >"${DB}"
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -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.941-0-ga055b77
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# source once magic, function named like file
|
# source once magic, function named like file
|
||||||
eval "$(basename "${BASH_SOURCE[0]}")(){ :; }"
|
eval "$(basename "${BASH_SOURCE[0]}")(){ :; }"
|
||||||
@ -40,6 +40,16 @@ send_markdown_message() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
send_markdownv2_message() {
|
||||||
|
local text; text="$(JsonEscape "${2}")"
|
||||||
|
# markdown v2 needs additional double escaping!
|
||||||
|
text="$(sed -E -e 's|([#{}()!.-])|\\\1|g' <<< "$text")"
|
||||||
|
until [ -z "${text}" ]; do
|
||||||
|
sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"markdownv2"' "${MSG_URL}"
|
||||||
|
text="${text:4096}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
send_html_message() {
|
send_html_message() {
|
||||||
local text; text="$(JsonEscape "${2}")"
|
local text; text="$(JsonEscape "${2}")"
|
||||||
until [ -z "${text}" ]; do
|
until [ -z "${text}" ]; do
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# #### if you start to develop your own bot, use the clean version of this file:
|
# #### if you start to develop your own bot, use the clean version of this file:
|
||||||
# #### mycommands.clean
|
# #### mycommands.clean
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
#
|
#
|
||||||
|
|
||||||
# uncomment the following lines to overwrite info and help messages
|
# uncomment the following lines to overwrite info and help messages
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# files: mycommands.sh.clean
|
# files: mycommands.sh.clean
|
||||||
# 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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
#
|
#
|
||||||
|
|
||||||
##########
|
##########
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# common variables
|
# common variables
|
||||||
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
|
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
../dev/hooks/pre-commit.sh
|
../dev/hooks/pre-commit.sh
|
||||||
|
|
||||||
|
@ -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-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ V0.94-0-gbdb50c8
|
#### $$VERSION$$ v0.96-dev-7-g0153928
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
Loading…
Reference in New Issue
Block a user