mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-01-01 06:11:46 +00:00
fix / allow more complex keyboards
This commit is contained in:
parent
bf97646361
commit
3824137433
14
README.md
14
README.md
@ -51,6 +51,20 @@ git clone --recursive https://github.com/topkecleon/telegram-bot-bash
|
|||||||
- Seperate Bot logic from command
|
- Seperate Bot logic from command
|
||||||
- Test your Bot with shellcheck
|
- Test your Bot with shellcheck
|
||||||
|
|
||||||
|
## Note to Keyboards
|
||||||
|
To make using Keayboards easier I changed the format of send_keyboard as of send_message "mykeyboardstartshere ...".
|
||||||
|
Now you must provide the keyboards in Telegram JSON style "[ \"yes\" , \"no\" ]".
|
||||||
|
The advantage is that you can create every type of keyboard iwithout relying on bashbot ```send_keyboard``` functionality.
|
||||||
|
**This is incompatible with keyboards in bashbot versions older than 0.6!**
|
||||||
|
|
||||||
|
*Example Keboards*:
|
||||||
|
|
||||||
|
- Yes No in one row: "[ \"yes\" , \"no\" ]"
|
||||||
|
- Yes No ind two rows: "[ \"yes\" ] , [ \"no\" ]"
|
||||||
|
- numpad keyboard: "[ \"1\" , \"2\" , \"3\" ] , [ \"4\" , \"5\" , \"6\" ] , [ \"7\" , \"8\" , \"9\" ] , [ \"0\" ]"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Security Considerations
|
## Security Considerations
|
||||||
Running a Telegram Bot means you are conneted to the public, you never know whats send to your Bot.
|
Running a Telegram Bot means you are conneted to the public, you never know whats send to your Bot.
|
||||||
|
|
||||||
|
12
bashbot.sh
12
bashbot.sh
@ -357,14 +357,8 @@ answer_inline_query() {
|
|||||||
send_keyboard() {
|
send_keyboard() {
|
||||||
local chat="$1"
|
local chat="$1"
|
||||||
local text="$2"
|
local text="$2"
|
||||||
shift 2
|
local keyboard="$3"
|
||||||
local keyboard=init
|
res="$(curl -s "$MSG_URL" --header "content-type: multipart/form-data" -F "chat_id=$chat" -F "text=$text" -F "reply_markup={\"keyboard\": [${keyboard}],\"one_time_keyboard\": true}")"
|
||||||
OLDIFS=$IFS
|
|
||||||
IFS=$(echo -en "\"")
|
|
||||||
for f in "$@" ;do [ "$f" != " " ] && keyboard="$keyboard, [\"$f\"]";done
|
|
||||||
IFS=$OLDIFS
|
|
||||||
keyboard=${keyboard/init, /}
|
|
||||||
res="$(curl -s "$MSG_URL" --header "content-type: multipart/form-data" -F "chat_id=$chat" -F "text=$text" -F "reply_markup={\"keyboard\": [$keyboard],\"one_time_keyboard\": true}")"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_keyboard() {
|
remove_keyboard() {
|
||||||
@ -470,7 +464,7 @@ checkback() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkproc() {
|
checkproc() {
|
||||||
tmux ls | grep -q "$1${copname}"; res=$?
|
tmux ls | grep -q "$1${copname}"; res=$?; return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
killback() {
|
killback() {
|
||||||
|
Loading…
Reference in New Issue
Block a user