From c96cc8a4a75829c8a1d685b014187a2b763e8d60 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 15 Apr 2016 19:32:21 +0200 Subject: [PATCH] Reduced interactive command timeout, added command to print last newline and made startproc call command in args --- README.md | 2 +- bashbot.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8649f77..278eab7 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ Allowed values: typing for text messages, upload_photo for photos, record_video send_action "${USER[ID]}" "action" ``` -To create interactive chats, write (or edit the question script) a normal bash (or C or python) script, chmod +x it and then substitute ./question @ line 49 with the command you usually use to start the script. +To create interactive chats, write (or edit the question script) a normal bash (or C or python) script, chmod +x it and then change the argument of the startproc function to match the command you usually use to start the script. The text that the script will output will be sent in real time to the user, and all user input will be sent to the script (as long as it's running or until the user kills it with /cancel). To open up a keyboard in an interactive script, print out the keyboard layout in the following way: ``` diff --git a/bashbot.sh b/bashbot.sh index 8f96806..0c2ddeb 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -152,7 +152,7 @@ startproc() { tmux kill-session -t $copname)2>/dev/null mkfifo $copname - TMUX= tmux new-session -d -s $copname "./question &>$copname; sleep 10; rm -r $copname" + TMUX= tmux new-session -d -s $copname "$* &>$copname; echo >$copname; sleep 5; rm -r $copname" while [ -p "$copname" ];do read -t 10 line [ "$line" != "" ] && send_message "${USER[ID]}" "$line" @@ -210,7 +210,7 @@ process_client() { [ ! -z ${LOCATION[*]} ] && send_location "${USER[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}" case $MESSAGE in '/question') - startproc& + startproc "./question"& ;; '/info') send_message "${USER[ID]}" "This is bashbot, the Telegram bot written entirely in bash."