Convert k.command to /command
This commit is contained in:
13
konata.sh
13
konata.sh
@@ -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
|
||||
|
Reference in New Issue
Block a user