diff --git a/README.html b/README.html index 15590ae..da7e872 100644 --- a/README.html +++ b/README.html @@ -139,6 +139,7 @@ Written by Drew (@topkecleon), Daniil Gentili (@danogentili), and Kay M (@gnadel
  • Sending Messages, Files, Keyboards
  • User Access Control
  • Inline Queries
  • +
  • jsshDB Bashbot key-value storage
  • Background and Interactive Jobs
  • Deveoper Notes @@ -230,6 +231,6 @@ It features background tasks and interactive chats, and can serve as an interfac

    @Gnadelwartz

    That's it!

    If you feel that there's something missing or if you found a bug, feel free to submit a pull request!

    -

    $$VERSION$$ 0.96-dev2-0-gcbad540

    +

    $$VERSION$$ v0.96-dev3-0-gdddd1ce

    diff --git a/README.md b/README.md index 6df4f22..51c0bfe 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do * Sending Messages, Files, Keyboards * User Access Control * Inline Queries + * jsshDB Bashbot key-value storage * Background and Interactive Jobs * [Deveoper Notes](doc/7_develop.md) * Debug bashbot @@ -197,4 +198,4 @@ This may happen if to many wrong requests are sent to api.telegram.org, e.g. usi If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ 0.96-dev2-0-gcbad540 +#### $$VERSION$$ v0.96-dev3-0-gdddd1ce diff --git a/README.txt b/README.txt index 02c6066..288cbd7 100644 --- a/README.txt +++ b/README.txt @@ -65,6 +65,7 @@ availible on www.github.com * Sending Messages, Files, Keyboards * User Access Control * Inline Queries + * jsshDB Bashbot key-value storage * Background and Interactive Jobs * [Deveoper Notes](doc/7_develop.md) * Debug bashbot @@ -280,4 +281,4 @@ in 'mycommands.sh' as example. If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ 0.96-dev2-0-gcbad540 +#### $$VERSION$$ v0.96-dev3-0-gdddd1ce diff --git a/doc/2_usage.md b/doc/2_usage.md index 124078f..629dadb 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -17,22 +17,27 @@ Have FUN! ### Files ``` . -├── mycommands.sh # THIS is your bot, place logic and commands here! +├── mycommands.sh # THIS is your bot, place logic and commands here! │ ├── mycommands.sh.clean # copy to "mycommands.sh" if you start devloping your bot -├── mycommands.sh.dist # example bot, also used for testing bashbot internally +├── mycommands.sh.dist # example bot, also used for testing bashbot internally │ -├── bashbot.sh # main bashbot script - DO NOT EDIT! +├── count.jssh # count bashbot usage in jssh key-value store +├── blocked.jssh # list of blocked USER[ID] in jssh key-value store +│ +├── bashbot.sh # main bashbot script - DO NOT EDIT! ├── commands.sh # command dispatcher - DO NOT EDIT! -├── JSON.sh # bashbots JSON parser, see https://github.com/dominictarr/JSON.sh +├── JSON.sh # bashbots JSON parser, see https://github.com/dominictarr/JSON.sh +│ +├── scripts # place your bashbot interactive and background scripts hereh │ ├── modules # optional functions, sourced by commands.sh │   ├── aliases.sh # to disable modules rename them xxx.sh.off │   ├── answerInline.sh -│   ├── jsshDB.sh # read and store JSON.sh stlye JSON +│   ├── jsshDB.sh # read and store JSON.sh stlye JSON, mandatory │   ├── background.sh # interactive and background functions │   ├── chatMember.sh -│   └── sendMessage.sh # main send message functions, do not disable +│   └── sendMessage.sh # main send message functions, mandatory │ ├── addons # optional addons, disbaled by default │   ├── example.sh # to enable addons change their XXX_ENABLE to true @@ -241,5 +246,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.96-dev-7-g0153928 +#### $$VERSION$$ v0.96-dev3-0-gdddd1ce diff --git a/test/ALL-tests.inc.sh b/test/ALL-tests.inc.sh index e3ae191..9d78bd0 100644 --- a/test/ALL-tests.inc.sh +++ b/test/ALL-tests.inc.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ 0.96-dev2-10-ged373a8 +#### $$VERSION$$ v0.96-dev3-0-gdddd1ce # common variables export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME @@ -32,8 +32,9 @@ export INPUTFILE REFFILE OUTPUTFILE OUTPUTFILE="${TESTDIR}/${REFDIR}.out" # do not query telegram when testing -export BASHBOT_URL +export BASHBOT_URL TESTTOKEN BASHBOT_URL="https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?" +TESTTOKEN="123456789:BASHBOTTESTSCRIPTbashbottestscript_" # print arrays in reproducible order print_array() { diff --git a/test/c-init-test.sh b/test/c-init-test.sh index 5f96083..6cc9c1b 100755 --- a/test/c-init-test.sh +++ b/test/c-init-test.sh @@ -1,12 +1,11 @@ #!/usr/bin/env bash -#### $$VERSION$$ 0.96-dev2-10-ged373a8 +#### $$VERSION$$ v0.96-dev3-0-gdddd1ce # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh source "./ALL-tests.inc.sh" -TESTTOKEN="bashbottestscript" -TESTFILES="${TOKENFILE} ${ACLFILE} ${COUNTFILE} ${ADMINFILE}" +TESTFILES="${TOKENFILE} ${ACLFILE} ${COUNTFILE} ${BLOCKEDFILE} ${ADMINFILE}" set -e @@ -46,5 +45,5 @@ cd "${DIRME}" || exit 1 echo "${SUCCESS}" echo "Test bashbot.sh count" -#cp "${REFDIR}/count.test" "${TESTDIR}/counti.jssh" -#"${TESTDIR}/bashbot.sh" count +cp "${REFDIR}/count.test" "${TESTDIR}/count.jssh" +"${TESTDIR}/bashbot.sh" count diff --git a/test/c-init-test/count.test b/test/c-init-test/count.test new file mode 100644 index 0000000..313248d --- /dev/null +++ b/test/c-init-test/count.test @@ -0,0 +1,27 @@ +["counted_user_id"] "num_messages_seen" +["712677"] "2" +["-1001189446"] "29" +["-1001288661"] "6" +["-1001433755"] "4" +["-408138"] "2" +["1246831"] "7" +["-1001186489"] "4" +["-1001259400"] "8" +["791626"] "18" +["-1001293952"] "4" +["-1001435141"] "7" +["733039"] "2" +["-1001319011"] "6" +["-1001220313"] "15" +["26122"] "3" +["988411"] "8" +["908527"] "6" +["-1001450413"] "58" +["748933"] "2" +["-1001425571"] "5" +["788295"] "3" +["586928"] "45" +["-1001359971"] "7" +["1069707"] "19" +["-1001189446"] "30" +["-1001189446"] "31" diff --git a/test/c-init-test/token b/test/c-init-test/token index 60557b1..006890a 100644 --- a/test/c-init-test/token +++ b/test/c-init-test/token @@ -1 +1 @@ -bashbottestscript +123456789:BASHBOTTESTSCRIPTbashbottestscript_ diff --git a/test/d-process_message-test.sh b/test/d-process_message-test.sh index ade74d2..fad677e 100755 --- a/test/d-process_message-test.sh +++ b/test/d-process_message-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ 0.96-dev2-10-ged373a8 +#### $$VERSION$$ v0.96-dev3-0-gdddd1ce # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh @@ -34,7 +34,7 @@ USER[ID]="123456789" CHAT[ID]="123456789" # output processed input -print_array "USER" "CHAT" "REPLYTO" "FORWARD" "URLS" "CONTACT" "CAPTION" "LOCATION" "MESSAGE" "VENUE" >"${OUTPUTFILE}" +print_array "USER" "CHAT" "REPLYTO" "FORWARD" "URLS" "CONTACT" "CAPTION" "LOCATION" "MESSAGE" "VENUE" "SERVICE">"${OUTPUTFILE}" diff -c "${REFFILE}" "${OUTPUTFILE}" || exit 1 echo "${SUCCESS}" diff --git a/test/d-process_message-test/d-process_message-test.input b/test/d-process_message-test/d-process_message-test.input index e166651..798449c 100644 --- a/test/d-process_message-test/d-process_message-test.input +++ b/test/d-process_message-test/d-process_message-test.input @@ -89,3 +89,16 @@ ["result",0,"message","voice","duration"] 2 ["result",0,"message","voice","mime_type"] "audio/ogg" ["result",0,"message","voice","file_size"] 4262 +["result",0,"message","new_chat_participant","id"] 123456789 +["result",0,"message","new_chat_participant","is_bot"] false +["result",0,"message","new_chat_participant","first_name"] "Kay" +["result",0,"message","new_chat_participant","last_name"] "M" +["result",0,"message","new_chat_member","id"] 123456789 +["result",0,"message","new_chat_member","is_bot"] false +["result",0,"message","new_chat_member","first_name"] "Kay" +["result",0,"message","new_chat_member","last_name"] "M" +["result",0,"message","new_chat_members",0,"id"] 123456789 +["result",0,"message","new_chat_members",0,"is_bot"] false +["result",0,"message","new_chat_members",0,"first_name"] "Kay" +["result",0,"message","new_chat_members",0,"last_name"] "M" +["result",0,"message","left_chat_member","id"] 123456789 diff --git a/test/d-process_message-test/d-process_message-test.result b/test/d-process_message-test/d-process_message-test.result index d242a2f..7fbedaf 100644 --- a/test/d-process_message-test/d-process_message-test.result +++ b/test/d-process_message-test/d-process_message-test.result @@ -42,3 +42,9 @@ VENUE: FOURSQUARE 4c4321afce54e21eee980d1a VENUE: LATITUDE 49.631824 VENUE: LONGITUDE 8.377072 VENUE: TITLE Kolb's Biergarten +SERVICE: 0 yes +SERVICE: LEFTMEMBER 123456789 +SERVICE: NEWMEMBER 123456789 +SERVICE: NEWPHOTO +SERVICE: NEWTILE +SERVICE: PINNED diff --git a/test/d-send_message-test/d-send_message-test.result b/test/d-send_message-test/d-send_message-test.result index 05ddf73..da76762 100644 --- a/test/d-send_message-test/d-send_message-test.result +++ b/test/d-send_message-test/d-send_message-test.result @@ -1,64 +1,64 @@ chat:123456 JSON:"text":"\# test for text only output" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":"This is a normal text" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":"This is a normal text with a line break" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":" This is a HTML<\/b> text","parse_mode":"html" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":" This is a HTML<\/b> text with a line break","parse_mode":"html" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":" This is a \*MARKDOWN\* text","parse_mode":"markdown" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":" This is a \*MARKDOWN\* text with a line break","parse_mode":"markdown" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":"\# test for keyboard\, file\, venue output" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":"Text plus keyboard will appear in chat", "reply_markup": {"keyboard": [ [ "Yep, sure" , "No, highly unlikely" ] ] , "one_time_keyboard":true} -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"latitude": la10, "longitude": lo20 -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendLocation +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendLocation chat:123456 JSON:"latitude": la10, "longitude": lo20, "address": "Diagon Alley N. 37", "title": "my home" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendVenue +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendVenue chat:123456 JSON:"text":"\# test for new inline button" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":"Text plus keyboard will appear in chat", "reply_markup": {"inline_keyboard": [ [ {"text":"Button Text", "url":"https://www..."}] ]} -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":"STABILO 88\/240 Fineliner point 88 -[https:\/\/images\-na.ssl\-images\-amazon.com\/images\/I\/41oypA3kmHL.l_SX300.jpg] +[https:\/\/images\-na\.ssl\-images\-amazon\.com\/images\/I\/41oypA3kmHL\.l_SX300\.jpg] second part of text -plus newline.", "reply_markup": {"inline_keyboard": [ [ {"text":"Bei Amazon ansehen ...", "url":"https://www.amazon.de/dp/B014TN3JYW"}] ]} -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +plus newline\.", "reply_markup": {"inline_keyboard": [ [ {"text":"Bei Amazon ansehen \.\.\.", "url":"https://www.amazon.de/dp/B014TN3JYW"}] ]} +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"text":"\# test for sendfile" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendMessage +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendMessage chat:123456 JSON:"photo":"/tmp/allowed/this_is_my.gif","caption":"Text plus absolute file will appear in chat" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendPhoto +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendPhoto chat:123456 JSON:"action": "upload_photo" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendChatAction +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendChatAction chat:123456 JSON:"document":"/tmp/allowed/this_is_my.doc","caption":"Text plus absolute file will appear in chat" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendDocument +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendDocument chat:123456 JSON:"action": "upload_document" -URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?bashbottestscript/sendChatAction +URL:https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/getMe?123456789:BASHBOTTESTSCRIPTbashbottestscript_/sendChatAction diff --git a/test/e-env-test.sh b/test/e-env-test.sh index 0eec21a..8aeeb73 100755 --- a/test/e-env-test.sh +++ b/test/e-env-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.96-dev-7-g0153928 +#### $$VERSION$$ v0.96-dev3-0-gdddd1ce # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh @@ -33,7 +33,6 @@ cp ${TESTDIR}/*commands.sh "${BASHBOT_ETC}" || exit 1 set -f cp -r "${TESTDIR}/bashbot.sh" "${TESTDIR}/modules" "${BASHBOT_BIN}" || exit 1 -TESTTOKEN="bashbottestscript" TESTFILES="${TOKENFILE} ${ACLFILE} ${ADMINFILE}"