mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-10-31 15:42:30 +00:00
some improvements to send_message
This commit is contained in:
parent
d26a992ecb
commit
fba89518c0
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# this has to run once atfer git clone
|
||||
# and every time we create new hooks
|
||||
#### $$VERSION$$ v0.70-dev2-27-g2da31c1
|
||||
#### $$VERSION$$ v0.70-dev3-14-gd26a992
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
@ -51,4 +51,7 @@ fi
|
||||
|
||||
echo "${passed} / ${tests}"
|
||||
[ -d "${TESTENV}" ] && echo "Logfiles from run are in ${TESTENV}"
|
||||
|
||||
ls -ld /tmp/bashbot.test* 2>/dev/null && echo "Don not forget to deleted bashbot test files in /tmp!!"
|
||||
|
||||
exit ${exitcode}
|
||||
|
@ -5,7 +5,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.70-dev3-13-g81b540a
|
||||
#### $$VERSION$$ v0.70-dev3-14-gd26a992
|
||||
|
||||
# source from commands.sh if you want ro use interactive or background jobs
|
||||
|
||||
@ -18,27 +18,26 @@ send_message() {
|
||||
local text arg keyboard file lat long title address sent
|
||||
[ "$2" = "" ] && return
|
||||
local mychat="$1"
|
||||
text="$(echo "$2" | sed 's/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ mylongstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
text="$(sed <<< "${2}" 's/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ mylongstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
arg="$3"
|
||||
[ "$arg" != "safe" ] && {
|
||||
text="${text// mynewlinestartshere /$'\r\n'}"
|
||||
no_keyboard="$(echo "$2" | sed '/mykeyboardendshere/!d;s/.*mykeyboardendshere.*/mykeyboardendshere/')"
|
||||
no_keyboard="$(sed <<< "${2}" '/mykeyboardendshere/!d;s/.*mykeyboardendshere.*/mykeyboardendshere/')"
|
||||
|
||||
keyboard="$(echo "$2" | sed '/mykeyboardstartshere /!d;s/.*mykeyboardstartshere //g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ mylongstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
keyboard="$(sed <<< "${2}" '/mykeyboardstartshere /!d;s/.*mykeyboardstartshere //g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ mylongstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
|
||||
file="$(echo "$2" | sed '/myfilelocationstartshere /!d;s/.*myfilelocationstartshere //g;s/ mykeyboardstartshere.*//g;s/ mylatstartshere.*//g;s/ mylongstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
file="$(sed <<< "${2}" '/myfilelocationstartshere /!d;s/.*myfilelocationstartshere //g;s/ mykeyboardstartshere.*//g;s/ mylatstartshere.*//g;s/ mylongstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
|
||||
lat="$(echo "$2" | sed '/mylatstartshere /!d;s/.*mylatstartshere //g;s/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylongstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
lat="$(sed <<< "${2}" '/mylatstartshere /!d;s/.*mylatstartshere //g;s/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylongstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
|
||||
long="$(echo "$2" | sed '/mylongstartshere /!d;s/.*mylongstartshere //g;s/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
long="$(sed <<< "${2}" '/mylongstartshere /!d;s/.*mylongstartshere //g;s/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ mytitlestartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
|
||||
title="$(echo "$2" | sed '/mytitlestartshere /!d;s/.*mytitlestartshere //g;s/.*mylongstartshere //g;s/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
title="$(sed <<< "${2}" '/mytitlestartshere /!d;s/.*mytitlestartshere //g;s/.*mylongstartshere //g;s/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ myaddressstartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
|
||||
address="$(echo "$2" | sed '/myaddressstartshere /!d;s/.*myaddressstartshere //g;s/.*mylongstartshere //g;s/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ mytitlestartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
address="$(sed <<< "${2}" '/myaddressstartshere /!d;s/.*myaddressstartshere //g;s/.*mylongstartshere //g;s/ mykeyboardstartshere.*//g;s/ myfilelocationstartshere.*//g;s/ mylatstartshere.*//g;s/ mytitlestartshere.*//g;s/ mykeyboardendshere.*//g')"
|
||||
|
||||
}
|
||||
if [ "$no_keyboard" != "" ]; then
|
||||
echo "remove_keyboard $mychat $text" > "${TMPDIR:-.}/prova"
|
||||
remove_keyboard "$mychat" "$text"
|
||||
sent=y
|
||||
fi
|
||||
@ -53,12 +52,12 @@ send_message() {
|
||||
send_file "$mychat" "$file" "$text"
|
||||
sent=y
|
||||
fi
|
||||
if [ "$lat" != "" ] && [ "$long" != "" ] && [ "$address" = "" ] && [ "$title" = "" ]; then
|
||||
send_location "$mychat" "$lat" "$long"
|
||||
sent=y
|
||||
fi
|
||||
if [ "$lat" != "" ] && [ "$long" != "" ] && [ "$address" != "" ] && [ "$title" != "" ]; then
|
||||
if [ "$lat" != "" ] && [ "$long" != "" ]; then
|
||||
if [ "$address" != "" ] && [ "$title" != "" ]; then
|
||||
send_venue "$mychat" "$lat" "$long" "$title" "$address"
|
||||
else
|
||||
send_location "$mychat" "$lat" "$long"
|
||||
fi
|
||||
sent=y
|
||||
fi
|
||||
if [ "$sent" != "y" ];then
|
||||
|
Loading…
Reference in New Issue
Block a user