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
|
# Parse incoming messages
|
||||||
input=$(cat /dev/stdin)
|
input=$(cat /dev/stdin)
|
||||||
msg=$(jq -r '.message.text' <<< $input)
|
msg=$(jq -r '.message.text' <<< $input)
|
||||||
icmd=$(cut -d" " -f1 <<< $msg)
|
cmd=$(cut -d" " -f1 <<< $msg)
|
||||||
args=$(cut -d" " -f2- <<< $msg)
|
args=$(cut -d" " -f2- <<< $msg)
|
||||||
chat=$(jq -r '.message.chat.id' <<< $input)
|
chat=$(jq -r '.message.chat.id' <<< $input)
|
||||||
user=$(jq -r '.message.from.username' <<< $input)
|
user=$(jq -r '.message.from.username' <<< $input)
|
||||||
|
|
||||||
# Append bot's tag to any command without one
|
# Append bot's tag to any command without one
|
||||||
if ! grep -q "/.*@" <<< $icmd
|
if ! grep -q "/.*@" <<< $cmd
|
||||||
then
|
then
|
||||||
cmd=${icmd}@$bot
|
cmd=${cmd}@$bot
|
||||||
else
|
fi
|
||||||
cmd=$icmd
|
# Convert k.command to /command
|
||||||
|
if grep -q "k\." <<< $cmd
|
||||||
|
then
|
||||||
|
cmd=$(sed "s/k\./\//g" <<< $cmd)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Functions for outgoing messages
|
# Functions for outgoing messages
|
||||||
|
Reference in New Issue
Block a user