From fb9c9923a90eb3c3e09cced5c7e1a871c334783a Mon Sep 17 00:00:00 2001 From: BigNerd95 Date: Sat, 26 Dec 2015 02:47:10 +0100 Subject: [PATCH 1/2] multitasking added process_client to manage multi client at same time fixed function to work with nohup --- bashbot.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index 2c0c288..df9cae9 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -17,14 +17,25 @@ PHO_URL=$URL'/sendPhoto' UPD_URL=$URL'/getUpdates?offset=' OFFSET=0 -function send_message { +send_message() { res=$(curl "$MSG_URL" -F "chat_id=$1" -F "text=$2") } -function send_photo() { +send_photo() { res=$(curl "$PHO_URL" -F "chat_id=$1" -F "photo=@$2") } +process_client() { + local MESSAGE=$1 + local TARGET=$2 + local msg="" + case $MESSAGE in + '/info') msg="This is bashbot, the Telegram bot written entirely in bash.";; + *) msg="$MESSAGE";; + esac + send_message "$TARGET" "$msg" +} + while true; do { res=$(curl $UPD_URL$OFFSET) @@ -36,11 +47,7 @@ while true; do { OFFSET=$((OFFSET+1)) if [ $OFFSET != 1 ]; then - case $MESSAGE in - '/info') msg="This is bashbot, the Telegram bot written entirely in bash.";; - *) msg="$MESSAGE";; - esac - send_message "$TARGET" "$msg" + process_client "$MESSAGE" "$TARGET" & fi } &>/dev/null; done From ff80d139e4d25fe4e70a3effdeee81ea045a8516 Mon Sep 17 00:00:00 2001 From: BigNerd95 Date: Sat, 26 Dec 2015 02:58:54 +0100 Subject: [PATCH 2/2] added contributor --- bashbot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashbot.sh b/bashbot.sh index df9cae9..8b4ae76 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -1,5 +1,5 @@ # bashbot, the Telegram bot written in bash. -# Written by @topkecleon and Juan Potato (@awkward_potato) +# Written by @topkecleon, Juan Potato (@awkward_potato) and Lorenzo Santina (BigNerd95) # http://github.com/topkecleon/bashbot # Depends on JSON.sh (http://github.com/dominictarr/JSON.sh),