diff --git a/README.md b/README.md index cfb11eb..58a6fbb 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,20 @@ git clone --recursive https://github.com/topkecleon/telegram-bot-bash - Seperate Bot logic from command - 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 Running a Telegram Bot means you are conneted to the public, you never know whats send to your Bot. diff --git a/bashbot.sh b/bashbot.sh index 32151d5..37ced4f 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -357,14 +357,8 @@ answer_inline_query() { send_keyboard() { local chat="$1" local text="$2" - shift 2 - local keyboard=init - 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}")" + local keyboard="$3" + 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() { @@ -470,7 +464,7 @@ checkback() { } checkproc() { - tmux ls | grep -q "$1${copname}"; res=$? + tmux ls | grep -q "$1${copname}"; res=$?; return $? } killback() {