updated README.md
This commit is contained in:
parent
0a1e936fb8
commit
3182b639dd
24
README.md
24
README.md
|
@ -3,7 +3,7 @@ bashbot-lib provides generic functionality for telegram bots made in bash<br>
|
||||||
with this library you will be able to run a telegram bot with few dependencies<br>
|
with this library you will be able to run a telegram bot with few dependencies<br>
|
||||||
**IMPORTANT**: bashbot-lib uses the getUpdates method with tcp_keepalive, not webhooks<br>
|
**IMPORTANT**: bashbot-lib uses the getUpdates method with tcp_keepalive, not webhooks<br>
|
||||||
**IMPORTANT**: bashbot-lib is not made for asynchronous use, only one message is received at a time and is done so in order<br>
|
**IMPORTANT**: bashbot-lib is not made for asynchronous use, only one message is received at a time and is done so in order<br>
|
||||||
|
[TOC2]
|
||||||
## license
|
## license
|
||||||
this program is licensed under the **Affero GNU Public License v3**, you can read the copy that comes along with this program or read it at [gnu.org's website](http://www.gnu.org/licenses/agpl-3.0.html)
|
this program is licensed under the **Affero GNU Public License v3**, you can read the copy that comes along with this program or read it at [gnu.org's website](http://www.gnu.org/licenses/agpl-3.0.html)
|
||||||
|
|
||||||
|
@ -58,9 +58,9 @@ the `getmsg_content` receives two arguments
|
||||||
**IMPORANT**: you must pass only the name of the associative array and not a reference to it
|
**IMPORANT**: you must pass only the name of the associative array and not a reference to it
|
||||||
```
|
```
|
||||||
# wrong way
|
# wrong way
|
||||||
getmsg_content ${curmsg} updates.txt
|
getmsg_content "${curmsg}" "updates.txt"
|
||||||
# right way
|
# right way
|
||||||
getmsg_content curmsg updates.txt
|
getmsg_content "curmsg" "updates.txt"
|
||||||
```
|
```
|
||||||
this is so because bash associative arrays can only be passed to functions as named references
|
this is so because bash associative arrays can only be passed to functions as named references
|
||||||
|
|
||||||
|
@ -81,14 +81,14 @@ the bash associative array will hold the following contents
|
||||||
| text | may contain special symbols |
|
| text | may contain special symbols |
|
||||||
| callback | callback_data, empty if there is none |
|
| callback | callback_data, empty if there is none |
|
||||||
|
|
||||||
if you sourced the viewer, you can view these contents with `view_content curmsg` where `curmsg` is the name of the bash associative array populated by `getmsg_content`
|
if you sourced the viewer, you can view these contents with `view_content "curmsg"` where `curmsg` is the name of the bash associative array populated by `getmsg_content`
|
||||||
|
|
||||||
### sending messages
|
### sending messages
|
||||||
use the `sendmsg` function to send messages and print the result to `sentmsgs.txt`
|
use the `sendmsg` function to send messages and print the result to `sentmsgs.txt`
|
||||||
|
|
||||||
the `sendmsg` function takes up to three arguments
|
the `sendmsg` function takes up to three arguments
|
||||||
* the chat_id of the chat to send the message to
|
* the chat_id of the chat to send the message to
|
||||||
* the contents of the message (text only for this version)
|
* the contents of the message (text only for this version, support for images and media will come in future versions)
|
||||||
* (optional) an inline keyboard made with `mkinline_kbd`
|
* (optional) an inline keyboard made with `mkinline_kbd`
|
||||||
|
|
||||||
**IMPORTANT**: you must [URL % encode](https://www.w3schools.com/tags/ref_urlencode.ASP) some special characters in the contents of the message or telegram won't accept them
|
**IMPORTANT**: you must [URL % encode](https://www.w3schools.com/tags/ref_urlencode.ASP) some special characters in the contents of the message or telegram won't accept them
|
||||||
|
@ -151,7 +151,7 @@ declare -a kbd_rows=( 1 3 3)
|
||||||
declare -a kbd_text=( "apple" "orange" "banana" "peach" "cherry" "pear" "lemon" )
|
declare -a kbd_text=( "apple" "orange" "banana" "peach" "cherry" "pear" "lemon" )
|
||||||
declare -a kbd_data=( "red" "orange" "yellow" "orange" "red" "green" "yellow" )
|
declare -a kbd_data=( "red" "orange" "yellow" "orange" "red" "green" "yellow" )
|
||||||
|
|
||||||
mkinline_kbd kbd_rows kbd_text kbd_data
|
mkinline_kbd "kbd_rows" "kbd_text" "kbd_data"
|
||||||
```
|
```
|
||||||
will result in
|
will result in
|
||||||
```
|
```
|
||||||
|
@ -159,4 +159,14 @@ will result in
|
||||||
```
|
```
|
||||||
if you use this with sendmsg, the keyboard will look like this
|
if you use this with sendmsg, the keyboard will look like this
|
||||||
|
|
||||||
![why are you blind](./images/example1.png "example 1 image")
|
![why are you blind](https://i.imgur.com/IRC2lhk.png "example 1 image")
|
||||||
|
|
||||||
|
## acknowledgements
|
||||||
|
bash manpage
|
||||||
|
sed manpage
|
||||||
|
grep manpage
|
||||||
|
telegram bot api reference
|
||||||
|
stackoverflow
|
||||||
|
|
||||||
|
## bug-reporting
|
||||||
|
send me an email at celsochan@disroot.org with the contents of error.log and a description of your issue with reproduction steps if possible
|
||||||
|
|
Loading…
Reference in New Issue