mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-04-11 08:31:51 +00:00
add examples for background and checkproc to commands.sh
This commit is contained in:
parent
b181234bb9
commit
e5d0b5d216
29
commands.sh
29
commands.sh
@ -49,8 +49,32 @@ else
|
|||||||
fi
|
fi
|
||||||
case "$MESSAGE" in
|
case "$MESSAGE" in
|
||||||
'/question')
|
'/question')
|
||||||
startproc "./question"
|
checkproc
|
||||||
|
if [ $res -gt 0 ] ; then
|
||||||
|
startproc "./question"
|
||||||
|
else
|
||||||
|
send_normal_message "${CHAT[ID]}" "$MESSAGE already running ..."
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
'/run-notify')
|
||||||
|
myback="notify"; checkback "$myback"
|
||||||
|
if [ $res -gt 0 ] ; then
|
||||||
|
background "./notify 60" "$myback" # notify every 60 seconds
|
||||||
|
else
|
||||||
|
send_normal_message "${CHAT[ID]}" "Background command $myback already running ..."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
'/stop-notify')
|
||||||
|
myback="notify"; checkback "$myback"
|
||||||
|
if [ $res -eq 0 ] ; then
|
||||||
|
killback "$myback"
|
||||||
|
send_normal_message "${CHAT[ID]}" "Background command $myback canceled."
|
||||||
|
else
|
||||||
|
send_normal_message "${CHAT[ID]}" "No background command $myback is currently running.."
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
'/info')
|
'/info')
|
||||||
send_markdown_message "${CHAT[ID]}" "This is bashbot, the *Telegram* bot written entirely in *bash*."
|
send_markdown_message "${CHAT[ID]}" "This is bashbot, the *Telegram* bot written entirely in *bash*."
|
||||||
;;
|
;;
|
||||||
@ -82,7 +106,8 @@ Get the code in my [GitHub](http://github.com/topkecleon/telegram-bot-bash)
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
'/cancel')
|
'/cancel')
|
||||||
if tmux ls | grep -q $copname; then killproc && send_message "${CHAT[ID]}" "Command canceled.";else send_message "${CHAT[ID]}" "No command is currently running.";fi
|
checkprog
|
||||||
|
if [ $res -eq 0 ] ; then killproc && send_message "${CHAT[ID]}" "Command canceled.";else send_message "${CHAT[ID]}" "No command is currently running.";fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if tmux ls | grep -v send | grep -q $copname;then inproc; else send_message "${CHAT[ID]}" "$MESSAGE" "safe";fi
|
if tmux ls | grep -v send | grep -q $copname;then inproc; else send_message "${CHAT[ID]}" "$MESSAGE" "safe";fi
|
||||||
|
19
notify
Executable file
19
notify
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This file is public domain in the USA and all free countries.
|
||||||
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
|
|
||||||
|
# check if $1 is a number
|
||||||
|
re='^[0-9]+$'
|
||||||
|
if [[ $1 =~ $re ]] ; then
|
||||||
|
SLEEP="$1"
|
||||||
|
else
|
||||||
|
SLEEP=10 # time between time notifications
|
||||||
|
fi
|
||||||
|
|
||||||
|
# output current time every $1 seconds
|
||||||
|
while sleep $SLEEP
|
||||||
|
do
|
||||||
|
date "+* It's %k:%M:%S o' clock ..."
|
||||||
|
done
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user