mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-26 01:07:34 +00:00
add jsshDB functions to function reference
This commit is contained in:
parent
2a28e7f0c9
commit
1c5594a5c2
@ -19,14 +19,12 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do
|
|||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
* [Introdution to Telegram Bots](https://core.telegram.org/bots)
|
* [Introdution to Telegram Bots](https://core.telegram.org/bots)
|
||||||
* [One Bot to rule them all](https://core.telegram.org/bots#3-how-do-i-create-a-bot)
|
|
||||||
* [Bot commands](https://core.telegram.org/bots#commands)
|
|
||||||
* [Install Bashbot](doc/0_install.md)
|
* [Install Bashbot](doc/0_install.md)
|
||||||
* Install release
|
* Install release
|
||||||
* Install from githup
|
* Install from githup
|
||||||
* Update Bashbot
|
* Update Bashbot
|
||||||
* Notes on Updates
|
* Notes on Updates
|
||||||
* [Create a new Telegram Bot with botfather](doc/1_firstbot.md)
|
* [Get Bottoken from Botfather](doc/1_firstbot.md)
|
||||||
* [Getting Started](doc/2_usage.md)
|
* [Getting Started](doc/2_usage.md)
|
||||||
* Managing your Bot
|
* Managing your Bot
|
||||||
* Recieve data
|
* Recieve data
|
||||||
|
@ -25,18 +25,20 @@ Have FUN!
|
|||||||
├── modules # optional functions, sourced by commands.sh
|
├── modules # optional functions, sourced by commands.sh
|
||||||
│ ├── aliases.sh # to disable modules rename them xxx.sh.off
|
│ ├── aliases.sh # to disable modules rename them xxx.sh.off
|
||||||
│ ├── answerInline.sh
|
│ ├── answerInline.sh
|
||||||
│ ├── jsonDB.sh
|
│ ├── jsshDB.sh # read and store JSON.sh stlye JSON
|
||||||
│ ├── background.sh
|
│ ├── background.sh # interactive and background functions
|
||||||
│ ├── chatMember.sh
|
│ ├── chatMember.sh
|
||||||
│ └── sendMessage.sh # main send message functions, do not disable
|
│ └── sendMessage.sh # main send message functions, do not disable
|
||||||
│
|
│
|
||||||
├── addons # optional addons, disbaled by default
|
├── addons # optional addons, disbaled by default
|
||||||
│ ├── example.sh # to enable addons change their XXX_ENABLE to true
|
│ ├── example.sh # to enable addons change their XXX_ENABLE to true
|
||||||
|
│ ├── antiFlood.sh # simple addon taking actions based on # files and text sent to chat
|
||||||
│ └── xxxxxage.sh
|
│ └── xxxxxage.sh
|
||||||
│
|
│
|
||||||
├── bashbot.rc # start/stop script if you run basbot as service
|
├── bashbot.rc # start/stop script if you run basbot as service
|
||||||
│
|
│
|
||||||
├── examples # example scripts and configs for bashbot
|
├── examples # example scripts and configs for bashbot
|
||||||
|
│ ├── README.md # description of files and examples
|
||||||
│ └── bashbot.cron # example crontab
|
│ └── bashbot.cron # example crontab
|
||||||
│
|
│
|
||||||
├── doc # Documentation and License
|
├── doc # Documentation and License
|
||||||
|
@ -453,6 +453,58 @@ Usually message is automatically forwarded in 'commands.sh', but you can forwar
|
|||||||
|
|
||||||
*replaces:*' incproc
|
*replaces:*' incproc
|
||||||
|
|
||||||
|
### JSON.sh DB
|
||||||
|
Since output of JSON.sh is so handy to use in bash, we provide a simple wrapper to read and write JSON.sh style data from and to files.
|
||||||
|
All file names must be relaitive to BASHBOT_ETC and must not contain '..'. The suffix '.jssh' is added to file name!
|
||||||
|
|
||||||
|
You must include ```source modules/jsshDB.sh``` in 'commands.sh' to have the following functions availible.
|
||||||
|
|
||||||
|
##### jssh_newDB
|
||||||
|
Creats new empty "DB" file if not exist.
|
||||||
|
|
||||||
|
*usage:* jssh_newDB "filename"
|
||||||
|
|
||||||
|
##### jssh_readDB
|
||||||
|
Read content of a file in JSON.sh format into given ARRAY. ARRAY name must be delared with "declare -A ARRAY" upfront,
|
||||||
|
|
||||||
|
*usage:* jssh_readDB "ARRAY" "filename"
|
||||||
|
|
||||||
|
*example:*
|
||||||
|
```bash
|
||||||
|
# read file data-bot-bash/somevalues.jssh into array SOMEVALUES
|
||||||
|
jssh_readDB "SOMEVALUES" "${DATADIR:-}/somevalues"
|
||||||
|
|
||||||
|
print "${SOMEVALUES[*]}"
|
||||||
|
```
|
||||||
|
|
||||||
|
##### jssh_writeDB
|
||||||
|
wWrite content of given ARRAY into file. ARRAY name must be delared with "declare -A ARRAY" upfront,
|
||||||
|
"DB" file MUST exist or nothing is written.
|
||||||
|
|
||||||
|
*usage:* jssh_writeDB "ARRAY" "filename"
|
||||||
|
|
||||||
|
*example:*
|
||||||
|
```bash
|
||||||
|
MYVALUES["value1"]="value1"
|
||||||
|
MYVALUES["loveit"]="value2"
|
||||||
|
MYVALUES["whynot"]="value3"
|
||||||
|
|
||||||
|
# create DB
|
||||||
|
jssh_newDB "${DATADIR:-}/myvalues"
|
||||||
|
|
||||||
|
# write to file data-bot-bash/somevalues.jssh from array MYVALUES
|
||||||
|
jssh_writeDB "MYVALUES" "${DATADIR:-}/myvalues"
|
||||||
|
|
||||||
|
# show whats written
|
||||||
|
cat ""${DATADIR:-}/myvalues.jssh"
|
||||||
|
["value1"] "value1"
|
||||||
|
["loveit"] "value2"
|
||||||
|
["whynot"] "value3"
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
### Aliases - shortcuts for often used funtions
|
### Aliases - shortcuts for often used funtions
|
||||||
You must include ```source modules/aliases.sh``` in 'commands.sh' to have the following functions availible.
|
You must include ```source modules/aliases.sh``` in 'commands.sh' to have the following functions availible.
|
||||||
|
|
||||||
@ -732,5 +784,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.90-dev2-0-gec85636
|
#### $$VERSION$$ v0.90-dev2-22-g9148dc5
|
||||||
|
|
||||||
|
@ -272,5 +272,5 @@ fi
|
|||||||
|
|
||||||
#### [Prev Function Reference](6_reference.md)
|
#### [Prev Function Reference](6_reference.md)
|
||||||
|
|
||||||
#### $$VERSION$$ v0.90-dev2-21-g405276b
|
#### $$VERSION$$ v0.90-dev2-22-g9148dc5
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user