Convert k.command to /command

This commit is contained in:
2021-01-09 06:08:33 +01:00
parent f1b03d2135
commit e71f8c25e5

View File

@@ -9,17 +9,20 @@ printf "Content-Type: text/plain\n\n"
# Parse incoming messages
input=$(cat /dev/stdin)
msg=$(jq -r '.message.text' <<< $input)
icmd=$(cut -d" " -f1 <<< $msg)
cmd=$(cut -d" " -f1 <<< $msg)
args=$(cut -d" " -f2- <<< $msg)
chat=$(jq -r '.message.chat.id' <<< $input)
user=$(jq -r '.message.from.username' <<< $input)
# Append bot's tag to any command without one
if ! grep -q "/.*@" <<< $icmd
if ! grep -q "/.*@" <<< $cmd
then
cmd=${icmd}@$bot
else
cmd=$icmd
cmd=${cmd}@$bot
fi
# Convert k.command to /command
if grep -q "k\." <<< $cmd
then
cmd=$(sed "s/k\./\//g" <<< $cmd)
fi
# Functions for outgoing messages