Add help and term commands
This commit is contained in:
33
konata.sh
33
konata.sh
@@ -10,11 +10,25 @@ user=$(jq -r '.message.from.username' <<< $input)
|
|||||||
|
|
||||||
sendmsg(){
|
sendmsg(){
|
||||||
# Escape any special characters first, see https://0x0.st/NO7J.
|
# Escape any special characters first, see https://0x0.st/NO7J.
|
||||||
fmt=$(sed 's/[][`~!@#$%^&*()-_=+{}\|;:",<.>/?'"'"']/\\&/g' <<< $1 | sed 's/\t//g')
|
fmt=$(sed 's/[][~!@#$%^&*()-_=+{}\|;:",<.>/?'"'"']/\\&/g' <<< $1 | sed 's/\t//g')
|
||||||
curl -X POST "https://api.telegram.org/bot$token/sendMessage" \
|
curl -X POST "https://api.telegram.org/bot$token/sendMessage" \
|
||||||
-d "chat_id=$chat" -d "parse_mode=markdownv2" -d "text=$fmt"
|
-d "chat_id=$chat" -d "parse_mode=markdownv2" -d "text=$fmt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
help(){
|
||||||
|
sendmsg "Hiya! I'm @ghnou's personal bot, Konata.
|
||||||
|
Currently I have the following features:
|
||||||
|
- /alive - Check whether I'm running.
|
||||||
|
- /cv [country] - Check COVID-19 stats.
|
||||||
|
- /id - Get the current chat's ID.
|
||||||
|
- /help - Show this help message.
|
||||||
|
Admin only commands:
|
||||||
|
- /stat - Uptime, memory, storage stats.
|
||||||
|
- /term - Execute a command on the system.
|
||||||
|
|
||||||
|
And a lot more to come!"
|
||||||
|
}
|
||||||
|
|
||||||
alive(){
|
alive(){
|
||||||
sendmsg "Alive and well!"
|
sendmsg "Alive and well!"
|
||||||
}
|
}
|
||||||
@@ -33,6 +47,11 @@ stat(){
|
|||||||
$(df -h / | tail -n1 | awk '{print $3}') of storage."
|
$(df -h / | tail -n1 | awk '{print $3}') of storage."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
term(){
|
||||||
|
admin
|
||||||
|
sendmsg "\`$(echo $args | bash - 2>&1)\`"
|
||||||
|
}
|
||||||
|
|
||||||
cv(){
|
cv(){
|
||||||
stats=$(curl -sL corona.lmao.ninja/v2/countries/$args)
|
stats=$(curl -sL corona.lmao.ninja/v2/countries/$args)
|
||||||
country=$(jq -r '.country' <<< $stats)
|
country=$(jq -r '.country' <<< $stats)
|
||||||
@@ -57,9 +76,11 @@ admin(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
/alive*) alive ;;
|
/start*|/help*) help ;;
|
||||||
/stat*) stat ;;
|
/alive*) alive ;;
|
||||||
/cv*|/corona*) cv ;;
|
/stat*) stat ;;
|
||||||
/id*) id ;;
|
/cv*|/corona*) cv ;;
|
||||||
@konatasanbot*) hiya ;;
|
/id*) id ;;
|
||||||
|
/term*) term ;;
|
||||||
|
*@konatasanbot*) hiya ;;
|
||||||
esac
|
esac
|
||||||
|
Reference in New Issue
Block a user