mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-05-28 16:00:52 +00:00
allow overwriting of standard commands
This commit is contained in:
parent
25c9b62a76
commit
68bee46383
17
commands.sh
17
commands.sh
|
@ -5,7 +5,7 @@
|
||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.80-18-g6b88656
|
#### $$VERSION$$ v0.80-23-g25c9b62
|
||||||
#
|
#
|
||||||
|
|
||||||
# adjust your language setting here, e.g.when run from other user or cron.
|
# adjust your language setting here, e.g.when run from other user or cron.
|
||||||
|
@ -68,7 +68,14 @@ if [ "${1}" != "source" ];then
|
||||||
# your commands are in mycommands()
|
# your commands are in mycommands()
|
||||||
else
|
else
|
||||||
|
|
||||||
case "${MESSAGE}" in
|
###################
|
||||||
|
# user defined commands must plaed in mycommands
|
||||||
|
! _is_function mycommands || mycommands # return true if not exist!
|
||||||
|
|
||||||
|
# run commands if true (0) is returned or if mycommands dose not exist
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if [ "$?" = "0" ]; then
|
||||||
|
case "${MESSAGE}" in
|
||||||
################################################
|
################################################
|
||||||
# GLOBAL commands start here, edit messages only
|
# GLOBAL commands start here, edit messages only
|
||||||
'/info'*)
|
'/info'*)
|
||||||
|
@ -105,8 +112,8 @@ if [ "${1}" != "source" ];then
|
||||||
;;
|
;;
|
||||||
*) # forward messages to optional dispatcher
|
*) # forward messages to optional dispatcher
|
||||||
_is_function send_interactive && send_interactive "${CHAT[ID]}" "${MESSAGE}"
|
_is_function send_interactive && send_interactive "${CHAT[ID]}" "${MESSAGE}"
|
||||||
_is_function mycommands && mycommands
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# files: mycommands.sh.dist
|
# files: mycommands.sh.dist
|
||||||
# copy to mycommands.sh and add all your commands and functions here ...
|
# copy to mycommands.sh and add all your commands and functions here ...
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.80-18-g6b88656
|
#### $$VERSION$$ v0.80-23-g25c9b62
|
||||||
#
|
#
|
||||||
|
|
||||||
# uncomment the following lines to overwrite info and help messages
|
# uncomment the following lines to overwrite info and help messages
|
||||||
|
@ -26,6 +26,8 @@ if [ "$1" != "source" ];then
|
||||||
mycommands() {
|
mycommands() {
|
||||||
|
|
||||||
case "${MESSAGE}" in
|
case "${MESSAGE}" in
|
||||||
|
##################
|
||||||
|
# example commands, replace thm by your own
|
||||||
'/echo'*) # example echo command
|
'/echo'*) # example echo command
|
||||||
send_normal_message "${CHAT[ID]}" "$MESSAGE"
|
send_normal_message "${CHAT[ID]}" "$MESSAGE"
|
||||||
;;
|
;;
|
||||||
|
@ -56,6 +58,16 @@ if [ "$1" != "source" ];then
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
##########
|
||||||
|
# command overwrite examples
|
||||||
|
'info'*) # output date in front of regular info
|
||||||
|
send_normal_message "${CHAT[ID]}" "$(date)"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
'/kickme'*) # this will replace the /kickme command
|
||||||
|
send_markdown_mesage "${CHAT[ID]}" "*This bot will not kick you!*"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user