mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-21 15:15:09 +00:00
remove JSON.sh -s option to fix message newline conversion on ubuntu
This commit is contained in:
parent
2a5d47df8d
commit
6ec00d49b3
@ -4,7 +4,7 @@
|
||||
# Addons can register to bashbot events at startup
|
||||
# by providing their name and a callback per event
|
||||
#
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
#
|
||||
# If an event occurs each registered event function is called.
|
||||
#
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# description: Start or stop telegram-bash-bot
|
||||
#
|
||||
#### $$VERSION$$ v1.1-0-gc0eb399
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
# shellcheck disable=SC2009
|
||||
# shellcheck disable=SC2181
|
||||
|
||||
|
14
bashbot.sh
14
bashbot.sh
@ -11,7 +11,7 @@
|
||||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
#### $$VERSION$$ v1.1-0-gc0eb399
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 success (hopefully)
|
||||
@ -406,7 +406,7 @@ if [ -z "${BASHBOT_WGET}" ] && _exists curl ; then
|
||||
# shellcheck disable=SC2086
|
||||
res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}"\
|
||||
-d '{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' -X POST "${3}" \
|
||||
-H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n 2>/dev/null )"
|
||||
-H "Content-Type: application/json" | "${JSONSHFILE}" -b -n 2>/dev/null )"
|
||||
sendJsonResult "${res}" "sendJson (curl)" "$@"
|
||||
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "send" "${@}" &
|
||||
}
|
||||
@ -418,11 +418,11 @@ if [ -z "${BASHBOT_WGET}" ] && _exists curl ; then
|
||||
printf "%s: sendUpload CHAT=%s WHAT=%s FILE=%s CAPT=%s\n" "$(date)" "${1}" "${2}" "${3}" "${4}" >>"${UPDATELOG}"
|
||||
# shellcheck disable=SC2086
|
||||
res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1"\
|
||||
-F "$2=@$3;${3##*/}" -F "caption=$5" | "${JSONSHFILE}" -s -b -n 2>/dev/null )"
|
||||
-F "$2=@$3;${3##*/}" -F "caption=$5" | "${JSONSHFILE}" -b -n 2>/dev/null )"
|
||||
else
|
||||
# shellcheck disable=SC2086
|
||||
res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1"\
|
||||
-F "$2=@$3;${3##*/}" | "${JSONSHFILE}" -s -b -n 2>/dev/null )"
|
||||
-F "$2=@$3;${3##*/}" | "${JSONSHFILE}" -b -n 2>/dev/null )"
|
||||
fi
|
||||
sendJsonResult "${res}" "sendUpload (curl)" "$@"
|
||||
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "upload" "$@" &
|
||||
@ -442,7 +442,7 @@ else
|
||||
printf "%s: sendJson (wget) CHAT=%s JSON=%s URL=%s\n" "$(date)" "${1}" "${2:0:100}" "${3##*/}" >>"${UPDATELOG}"
|
||||
# shellcheck disable=SC2086
|
||||
res="$(wget --no-check-certificate -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - --post-data='{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' \
|
||||
--header='Content-Type:application/json' "${3}" | "${JSONSHFILE}" -s -b -n 2>/dev/null )"
|
||||
--header='Content-Type:application/json' "${3}" | "${JSONSHFILE}" -b -n 2>/dev/null )"
|
||||
sendJsonResult "${res}" "sendJson (wget)" "$@"
|
||||
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "send" "${@}" &
|
||||
}
|
||||
@ -564,7 +564,7 @@ title2Json(){
|
||||
|
||||
# get bot name
|
||||
getBotName() {
|
||||
getJson "$ME_URL" | "${JSONSHFILE}" -s -b -n 2>/dev/null | JsonGetString '"result","username"'
|
||||
getJson "$ME_URL" | "${JSONSHFILE}" -b -n 2>/dev/null | JsonGetString '"result","username"'
|
||||
}
|
||||
|
||||
# pure bash implementation, done by KayM (@gnadelwartz)
|
||||
@ -963,7 +963,7 @@ start_bot() {
|
||||
# adaptive sleep in ms rounded to next 0.1 s
|
||||
sleep "$(_round_float "${nextsleep}e-3" "1")"
|
||||
# get next update
|
||||
UPDATE="$(getJson "$UPD_URL$OFFSET" "nolog" 2>/dev/null | "${JSONSHFILE}" -s -b -n 2>/dev/null | iconv -f utf-8 -t utf-8 -c)"
|
||||
UPDATE="$(getJson "$UPD_URL$OFFSET" "nolog" 2>/dev/null | "${JSONSHFILE}" -b -n 2>/dev/null | iconv -f utf-8 -t utf-8 -c)"
|
||||
# did we get an response?
|
||||
if [ -n "${UPDATE}" ]; then
|
||||
# we got something, do processing
|
||||
|
@ -10,7 +10,7 @@ Run the following commands to see if your bash looks ok ...
|
||||
if which bash; then echo "bash seems available..."; else echo "NO bash"; fi
|
||||
|
||||
# real bash supports ARRAY
|
||||
bash -c 'if eval "a=(1)"; then echo "Shell support arrays..."; else echo "Shell has NO arrays"; fi'
|
||||
bash -c 'if eval "a[1]=1"; then echo "Shell support arrays..."; else echo "Shell has NO arrays"; fi'
|
||||
|
||||
# check for bash version by feature
|
||||
bash -c 'if [ "$(echo -e "\u1111")" != "\u1111" ]; then echo "Bash version ok ..."; else echo "LBash Version may be to old ..."; fi'
|
||||
|
@ -378,5 +378,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
|
||||
#### [Prev Advanced Use](3_advanced.md)
|
||||
#### [Next Best Practice](5_practice.md)
|
||||
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
|
||||
|
@ -158,5 +158,5 @@ The second warning is about an unused variable, this is true because in our exam
|
||||
#### [Prev Best Practice](5_practice.md)
|
||||
#### [Next Functions Reference](6_reference.md)
|
||||
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
|
||||
|
@ -1049,5 +1049,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca
|
||||
#### [Prev Best Practice](5_practice.md)
|
||||
#### [Next Notes for Developers](7_develop.md)
|
||||
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
|
||||
|
@ -347,5 +347,5 @@ fi
|
||||
|
||||
#### [Prev Function Reference](6_reference.md)
|
||||
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
|
||||
|
@ -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$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -2,7 +2,7 @@
|
||||
# file: run_filename
|
||||
# background job to display content of all new files in WATCHDIR
|
||||
#
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -2,7 +2,7 @@
|
||||
# file: run_filename
|
||||
# background job to display all new files in WATCHDIR
|
||||
#
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -2,7 +2,7 @@
|
||||
# file. multibot.sh
|
||||
# description: run multiple telegram bots from one installation
|
||||
#
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
|
||||
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
|
||||
echo "Usage: $0 botname command"
|
||||
|
@ -2,7 +2,7 @@
|
||||
# files: mycommands.sh.dist
|
||||
# copy to mycommands.sh and add all your commands and functions here ...
|
||||
#
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
#
|
||||
# shellcheck disable=SC2154
|
||||
# shellcheck disable=SC2034
|
||||
|
@ -5,7 +5,7 @@
|
||||
# to show how you can customize bashbot by only editing mycommands.sh
|
||||
# NOTE: this is not tested, simply copied from original source and reworked!
|
||||
#
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
#
|
||||
# shellcheck disable=SC2154
|
||||
# shellcheck disable=SC2034
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v1.0-0-g99217c4
|
||||
#### $$VERSION$$ v1.2-dev-13-g2a5d47d
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
Loading…
Reference in New Issue
Block a user