no aliases in commands.sh, move cancel to mycommands.dist

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-06-02 12:15:59 +02:00
parent 6302ef4795
commit 6128c8956f
2 changed files with 25 additions and 25 deletions

View File

@ -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.90-0-g7029f7f #### $$VERSION$$ v0.90-4-g6302ef4
# #
# 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.
@ -37,7 +37,7 @@ Get the code in my [GitHub](http://github.com/topkecleon/telegram-bot-bash)
' '
# load modues on startup and always on on debug # load modues on startup and always on on debug
if [[ "${1}" = *"debug"* ]] ; then if [ "${1}" = "source" ] || [[ "${1}" = *"debug"* ]] ; then
# load all readable modules # load all readable modules
for modules in ${MODULEDIR:-.}/*.sh ; do for modules in ${MODULEDIR:-.}/*.sh ; do
# shellcheck source=./modules/aliases.sh # shellcheck source=./modules/aliases.sh
@ -72,42 +72,38 @@ if [ "${1}" != "source" ];then
# run commands if true (0) is returned or if mycommands dose not exist # run commands if true (0) is returned or if mycommands dose not exist
# shellcheck disable=SC2181 # shellcheck disable=SC2181
if [ "$?" = "0" ] && [ "${CMD}" != "" ]; then if [ "$?" = "0" ]; then
case "${CMD}" in case "${MESSAGE}" in
################################################ ################################################
# GLOBAL commands start here, edit messages only # GLOBAL commands start here, edit messages only
'/info') '/info'*)
_markdown_message "${bashbot_info}" send_markdown_message "${bashbot_info}"
;; ;;
'/start') '/start'*)
send_action "${CHAT[ID]}" "typing" send_action "${CHAT[ID]}" "typing"
_is_botadmin && _markdown_message "You are *BOTADMIN*." user_is_botadmin "${USER[ID]}" && send_markdown_message "${CHAT[ID]}" "You are *BOTADMIN*."
if _is_botadmin || _is_allowed "start" ; then if _is_botadmin || _is_allowed "start" ; then
_markdown_message "${bashbot_help}" send_markdown_message "${CHAT[ID]}" "${bashbot_help}"
else else
_message "You are not allowed to start Bot." send_normal_message "${CHAT[ID]}" "You are not allowed to start Bot."
fi fi
;; ;;
'/help') '/help'*)
_markdown_message "${bashbot_help}" send_markdown_message "${CHAT[ID]}" "${bashbot_help}"
;; ;;
'/leavechat') # bot leave chat if user is admin in chat '/leavechat'*) # bot leave chat if user is admin in chat
if _is_admin ; then if user_is_botadmin "${USER[ID]}" ; then
_markdown_message "*LEAVING CHAT...*" send_markdown_message "${CHAT[ID]}" "*LEAVING CHAT...*"
_leave leave_chat "${CHAT[ID]}"
fi fi
;; ;;
'/kickme') '/kickme'*)
_kick_user "${USER[ID]}" kick_chat_member "${CHAT[ID]}" "${USER[ID]}"
_unban_user "${USER[ID]}" unban_chat_member "${CHAT[ID]}" "${USER[ID]}"
;; ;;
'/cancel')
checkproc
if [ "$res" -eq 0 ] ; then killproc && _message "Command canceled.";else _message "No command is currently running.";fi
;;
*) # forward messages to optional dispatcher *) # forward messages to optional dispatcher
_exec_if_function send_interactive "${CHAT[ID]}" "${MESSAGE}" _exec_if_function send_interactive "${CHAT[ID]}" "${MESSAGE}"
;; ;;

View File

@ -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.90-0-g7029f7f #### $$VERSION$$ v0.90-4-g6302ef4
# #
# uncomment the following lines to overwrite info and help messages # uncomment the following lines to overwrite info and help messages
@ -40,6 +40,10 @@ if [ "$1" != "source" ];then
fi fi
;; ;;
'/cancel'*) # cancel interactive command
checkproc
if [ "$res" -gt 0 ] ;then killproc && _message "Command canceled.";else _message "No command is currently running.";fi
;;
'/run_notify'*) # start notify background job '/run_notify'*) # start notify background job
myback="notify"; checkback "$myback" myback="notify"; checkback "$myback"
if [ "$res" -gt 0 ] ; then if [ "$res" -gt 0 ] ; then
@ -60,7 +64,7 @@ if [ "$1" != "source" ];then
########## ##########
# command overwrite examples # command overwrite examples
'info'*) # output date in front of regular info '/info'*) # output date in front of regular info
send_normal_message "${CHAT[ID]}" "$(date)" send_normal_message "${CHAT[ID]}" "$(date)"
return 0 return 0
;; ;;