implemented replymsg and fixed issue with piping long messages to sed
This commit is contained in:
parent
d5adbdec11
commit
b38b0911df
|
@ -30,9 +30,8 @@ calc_offset() {
|
||||||
getupd() {
|
getupd() {
|
||||||
local offset="$(calc_offset)"
|
local offset="$(calc_offset)"
|
||||||
local update="$(curl -sX GET --keepalive-time 300 "${api_url}getUpdates" -d "offset=${offset}" \
|
local update="$(curl -sX GET --keepalive-time 300 "${api_url}getUpdates" -d "offset=${offset}" \
|
||||||
-d "limit=1" -d "timeout=300"\
|
-d "limit=1" -d "timeout=300")"
|
||||||
| sed 's/{"ok":true,"result":\[\]}\|^{"ok":false.*\|^{"ok":true,"result":\[{\?//g;:a;N;$!ba;s/\n//g;s/}\]}$//g;')"
|
update="$(sed 's/{"ok":true,"result":\[\]}\|^{"ok":false.*\|^{"ok":true,"result":\[{\?//g;:a;N;$!ba;s/\n//g;s/}\]}$//g;' <<< "${update}")"
|
||||||
printf "%s" ${update}
|
|
||||||
[ ! -z "${update}" ] && printf "%s\n" "${update}" >> "${bot_tmpdir}updates.txt"
|
[ ! -z "${update}" ] && printf "%s\n" "${update}" >> "${bot_tmpdir}updates.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,25 +149,31 @@ mkinline_kbd(){
|
||||||
# $2 is text
|
# $2 is text
|
||||||
# $3 is inline keyboard (optional)
|
# $3 is inline keyboard (optional)
|
||||||
sendmsg() {
|
sendmsg() {
|
||||||
|
local sentmsg
|
||||||
[ -z "${3}" ] && sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" \
|
[ -z "${3}" ] && sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" \
|
||||||
-d "text=${2}")" \
|
-d "text=${2}")" \
|
||||||
|| sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" \
|
|| sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" \
|
||||||
-d "text=${2}" \
|
-d "text=${2}" \
|
||||||
-d "reply_markup=${3}")"
|
-d "reply_markup=${3}")"
|
||||||
[ ! -z "${sentmsg}" ] && printf "%s\n" "${sentmsg}"\
|
[ ! -z "${sentmsg}" ] && sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g'\
|
||||||
| sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g'\
|
<<< "${sentmsg}" >> "${bot_tmpdir}sentmsgs.txt"
|
||||||
>> "${bot_tmpdir}sentmsgs.txt"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# $1 is target chat_id
|
||||||
|
# $2 is target msg_id
|
||||||
|
# $3 is text
|
||||||
|
# $4 is inline keyboard (optional)
|
||||||
|
replymsg() {
|
||||||
|
local sentmsg
|
||||||
|
[ -z "${4}" ] &&\
|
||||||
|
sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" -d "reply_to_message_id=${2}"\
|
||||||
|
-d "text=${3}")" ||
|
||||||
|
sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" -d "reply_to_message_id=${2}"\
|
||||||
|
-d "text=${3}" -d "reply_markup=${4}")"
|
||||||
|
[ ! -z "${sentmsg}" ] && sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g'\
|
||||||
|
<<< "${sentmsg}" >> "${bot_tmpdir}sentmsgs.txt"
|
||||||
|
}
|
||||||
# TODO
|
# TODO
|
||||||
#replymsg() {
|
|
||||||
# sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" -d "reply_to_message_id=${2}" \
|
|
||||||
# -d "text=${3}" \
|
|
||||||
# -d 'reply_markup={"inline_keyboard":[[{"text":"url+is+clean","callback_data":"nigger"},{"text":"topnigger","callback_data":"top"}]]}')" \
|
|
||||||
# && [ ! -z "${sentmsg}" ] && printf "%s\n" "${sentmsg}"\
|
|
||||||
# | sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g'\
|
|
||||||
# >> "${bot_tmpdir}sentmsgs.txt"
|
|
||||||
#}
|
|
||||||
#editmsg() {
|
#editmsg() {
|
||||||
# curl -sX GET "${api_url}editMessageText" -d "chat_id=${1}" -d "message_id=${2}" \
|
# curl -sX GET "${api_url}editMessageText" -d "chat_id=${1}" -d "message_id=${2}" \
|
||||||
# -d "text=${3}"
|
# -d "text=${3}"
|
||||||
|
|
Loading…
Reference in New Issue