From bf976463610feb682d3c4fa39d716b6553b16b37 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Mon, 15 Apr 2019 14:17:18 +0200 Subject: [PATCH] dev3-rc1 candidate --- README.md | 2 +- README.txt | 2 +- bashbot.cron | 2 +- bashbot.rc | 2 +- bashbot.sh | 2 +- calc | 3 ++- commands.sh | 22 +++++++++++----------- doc/1_firstbot.md | 2 +- doc/2_usage.md | 2 +- doc/3_advanced.md | 2 +- doc/4_expert.md | 2 +- doc/5_practice.md | 2 +- doc/6_reference.md | 36 ++++++++++-------------------------- notify | 2 +- question | 2 +- version | 2 +- 16 files changed, 36 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index f22a7c8..cfb11eb 100644 --- a/README.md +++ b/README.md @@ -77,4 +77,4 @@ No - its not less (in)secure as any other Bot written in any other language. But If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.6-rc1-0-gc001d14 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 diff --git a/README.txt b/README.txt index 244455f..6e04c34 100644 --- a/README.txt +++ b/README.txt @@ -122,5 +122,5 @@ That's it! If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -latexmath:[\[VERSION\]] v0.6-rc1-0-gc001d14 +latexmath:[\[VERSION\]] v0.6-rc1-7-g14eb352 +++++++++++++++++++++++++++++++++++++++++++ diff --git a/bashbot.cron b/bashbot.cron index d9c74cc..fc0d5c2 100644 --- a/bashbot.cron +++ b/bashbot.cron @@ -7,7 +7,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.6-rc1-0-gc001d14 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 SHELL=/bin/sh diff --git a/bashbot.rc b/bashbot.rc index 3c6804e..d5e46cd 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.6-rc1-0-gc001d14 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index 00b2cc8..32151d5 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -10,7 +10,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.6-rc1-5-g2ac5e6f +#### $$VERSION$$ v0.6-rc1-7-g14eb352 # # Exit Codes: # - 0 sucess (hopefully) diff --git a/calc b/calc index a79c376..fcc86f6 100755 --- a/calc +++ b/calc @@ -3,7 +3,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.6-rc1-0-gc001d14 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment @@ -20,6 +20,7 @@ read -r A echo 'Enter second number.' read -r B echo 'Select Operation: mykeyboardstartshere "Addition" "Subtraction" "Multiplication" "Division" "Cancel"' +echo 'Your anwser can be: add, sub, mul, div or cancel' read -r opt echo -n 'Result: ' case $opt in diff --git a/commands.sh b/commands.sh index d698859..924bea2 100755 --- a/commands.sh +++ b/commands.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.6-rc1-0-gc001d14 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 @@ -71,7 +71,7 @@ else [ ! -z "${LOCATION[*]}" ] && send_location "${CHAT[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}" # Inline - if [ $INLINE == 1 ]; then + if [ "$INLINE" = 1 ]; then # inline query data iUSER[FIRST_NAME]="$(echo "$res" | sed 's/^.*\(first_name.*\)/\1/g' | cut -d '"' -f3 | tail -1)" iUSER[LAST_NAME]="$(echo "$res" | sed 's/^.*\(last_name.*\)/\1/g' | cut -d '"' -f3)" @@ -80,18 +80,18 @@ else iQUERY_MSG="$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -6 | head -1)" # Inline examples - if [[ "$iQUERY_MSG" == "photo" ]]; then + if [[ "$iQUERY_MSG" = "photo" ]]; then answer_inline_query "$iQUERY_ID" "photo" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" fi - if [[ "$iQUERY_MSG" == "sticker" ]]; then + if [[ "$iQUERY_MSG" = "sticker" ]]; then answer_inline_query "$iQUERY_ID" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC" fi - if [[ "$iQUERY_MSG" == "gif" ]]; then + if [[ "$iQUERY_MSG" = "gif" ]]; then answer_inline_query "$iQUERY_ID" "cached_gif" "BQADBAADIwYAAmwsDAABlIia56QGP0YC" fi - if [[ "$iQUERY_MSG" == "web" ]]; then + if [[ "$iQUERY_MSG" = "web" ]]; then answer_inline_query "$iQUERY_ID" "article" "GitHub" "http://github.com/topkecleon/telegram-bot-bash" fi fi & @@ -131,8 +131,8 @@ else ;; '/start') send_action "${CHAT[ID]}" "typing" - user_is_botadmin "${USER[ID]}" && send_markdown_message "${CHAT[ID]}" "You are *BOTADMIN*." - if user_is_allowed "${USER[ID]}" "start" "${CHAT[ID]}" ; then + _is_botadmin && send_markdown_message "${CHAT[ID]}" "You are *BOTADMIN*." + if _is_allowed "start" ; then bot_help "${CHAT[ID]}" else send_normal_message "${CHAT[ID]}" "You are not allowed to start Bot." @@ -140,7 +140,7 @@ else ;; '/leavechat') # bot leave chat if user is admin in chat - if user_is_admin "${CHAT[ID]}" "${USER[ID]}"; then + if _is_admin ; then send_markdown_message "${CHAT[ID]}" "*LEAVING CHAT...*" leave_chat "${CHAT[ID]}" fi @@ -155,8 +155,8 @@ else checkprog if [ "$res" -eq 0 ] ; then killproc && send_message "${CHAT[ID]}" "Command canceled.";else send_message "${CHAT[ID]}" "No command is currently running.";fi ;; - *) - if tmux ls | grep -v send | grep -q "$copname";then inproc; else send_message "${CHAT[ID]}" "$MESSAGE" "safe";fi + *) # forward input to interactive chat if running + if tmux ls | grep -v send | grep -q $copname;then inproc; fi ;; esac fi diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index 15247e8..05b1cca 100644 --- a/doc/1_firstbot.md +++ b/doc/1_firstbot.md @@ -70,5 +70,5 @@ git clone --recursive https://github.com/topkecleon/telegram-bot-bash ``` 3. Change to directory ```telegram-bot.bash```, run ```./bashbot.sh init``` and follow the instructions. At this stage you are asked for your Bots token given by botfather. -#### $$VERSION$$ v0.6-rc1-6-ge18b200 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 diff --git a/doc/2_usage.md b/doc/2_usage.md index b0926d7..8f4f1da 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -154,6 +154,6 @@ Allowed values: typing for text messages, upload_photo for photos, record_video send_action "${CHAT[ID]}" "action" ``` -#### $$VERSION$$ v0.6-rc1-6-ge18b200 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 diff --git a/doc/3_advanced.md b/doc/3_advanced.md index 319e4a0..c4b1f56 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -153,5 +153,5 @@ To send stickers through an *inline query*: answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker" ``` -#### $$VERSION$$ v0.6-rc1-6-ge18b200 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 diff --git a/doc/4_expert.md b/doc/4_expert.md index b2157fc..5ca2782 100644 --- a/doc/4_expert.md +++ b/doc/4_expert.md @@ -102,5 +102,5 @@ An example crontab is provided in ```bashbot.cron```. - if you run bashbot as an other user or a system service edit ```bashbot.cron``` to fit your needs and replace username```nobody``` with the username you want to run bashbot. copy the modified file to ```/etc/cron.d/bashbot``` -#### $$VERSION$$ v0.6-rc1-6-ge18b200 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 diff --git a/doc/5_practice.md b/doc/5_practice.md index d98323f..0ede099 100644 --- a/doc/5_practice.md +++ b/doc/5_practice.md @@ -112,5 +112,5 @@ In bashbot.sh line 490: Here are two warnings in bashbots scripts. The first is a hint you may use shell substitions instead of sed, this is really possible and much faster! The second warning is about an unused variable, this is true because in our examples CONTACT is not used but assigned in case you want to use it :-) -#### $$VERSION$$ v0.6-rc1-6-ge18b200 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 diff --git a/doc/6_reference.md b/doc/6_reference.md index 7e9a60e..c68fe6f 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -30,12 +30,12 @@ ---- ##### send_message -Send Message is only used to process the output of interactive chats an background jobs. -I reccommend to use the more dedicated send_xxx_message() functions above. +Send Message must (only) used to process the output of interactive chats and background jobs. +**For your commands I reccommend the more dedicated send_xxx_message() functions above.** *usage:* -*example:* see [Usage](2_usage.md#send_message) and [Advanced Usage](3_advanced.md#Interactive-Chats) +*example:* - see [Usage](2_usage.md#send_message) and [Advanced Usage](3_advanced.md#Interactive-Chats) ---- @@ -161,59 +161,43 @@ I reccommend to use the more dedicated send_xxx_message() functions above. *example:* ### Bashbot internal -These function are for internal use only and must not used for your bot commands. +These functions are for internal use only and must not used in your bot commands. ##### send_text *usage:* -*example:* - ---- ##### JsonDecode *usage:* -*example:* - ##### JsonGetString *usage:* -*example:* - ##### JsonGetValue *usage:* -*example:* - ---- ##### get_chat_member_status *usage:* -*example:* - ---- ##### process_client -*usage:* - -*example:* +Every Message sent to your Bot is processd by this function. It parse the send JSON and assign the found Values to bash variables. ##### process_updates -*usage:* - -*example:* +If new updates are availible, this functions gets the JSON from Telegram and dispatch it. ---- ##### getBotName -*usage:* +The name of your bot is availible as bash variable "$ME", there is no need to call this function if Bot is running. -*example:* +*usage:* ME="$(getBotNiname)" ##### inproc -*usage:* +Send Input from Telegram to waiting Interactive Chat. -*example:* - -#### $$VERSION$$ v0.6-rc1-6-ge18b200 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 diff --git a/notify b/notify index bb1daff..0a38bdd 100755 --- a/notify +++ b/notify @@ -2,7 +2,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.6-rc1-0-gc001d14 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/question b/question index 036490e..4050fd5 100755 --- a/question +++ b/question @@ -3,7 +3,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.6-rc1-0-gc001d14 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/version b/version index da01d03..367cf74 100755 --- a/version +++ b/version @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ v0.6-rc1-0-gc001d14 +#### $$VERSION$$ v0.6-rc1-7-g14eb352 # shellcheck disable=SC2016 # # Easy Versioning in git: