Merge pull request #5 from danog/patch-1

Added documentation
This commit is contained in:
Drew 2016-01-19 15:01:09 -05:00
commit fce86d0884
2 changed files with 36 additions and 15 deletions

View File

@ -102,15 +102,28 @@ You can read incoming data using the following variables:
### Usage ### Usage
To send messages use the ```send_message``` function: To send messages use the ```send_message``` function:
``` ```
send_message "$TARGET" "lol" send_message "${USER[ID]}" "lol"
``` ```
To send images use the ```send_photo``` function: To send images, videos, voice files, photos ecc use the ```send_photo``` function:
``` ```
send_photo "$TARGET" "/home/user/doge.jpg" send_file "${USER[ID]}" "/home/user/doge.jpg" "Lool"
``` ```
To send custom keyboards use the ```send_keyboard``` function or the ```send_message``` function: To send custom keyboards use the ```send_keyboard``` function:
``` ```
send_keyboard "$TARGET" "Text that will appear in chat?" "Yep" "No" send_keyboard "${USER[ID]}" "Text that will appear in chat?" "Yep" "No"
```
To send locations use the ```send_location``` function:
```
send_location "${USER[ID]}" "Latitude" "Longitude"
```
To forward messages use the ```forward``` function:
```
forward "${USER[ID]}" "from_chat_id" "message_id"
```
To send a chat action use the ```send_action``` function.
Allowed values: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for locations.
```
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 substitute ./question @ line 49 with the command you usually use to start the script.
@ -119,13 +132,17 @@ To open up a keyboard in an interactive script, print out the keyboard layout in
``` ```
echo "Text that will appear in chat? mykeyboardstartshere Yep No" echo "Text that will appear in chat? mykeyboardstartshere Yep No"
``` ```
Same goes for images: Same goes for files:
``` ```
echo "Text that will appear in chat? myimagelocationstartshere /home/user/doge.jpg" echo "Text that will appear in chat? myfilelocationstartshere /home/user/doge.jpg"
``` ```
Or both: And locations:
``` ```
echo "Text that will appear in chat? mykeyboardstartshere Yep No myimagelocationstartshere /home/user/doge.jpg" echo "Text that will appear in chat. mylatstartshere 45 mylongstartshere 45"
```
You can combine them:
```
echo "Text that will appear in chat? mykeyboardstartshere Yep No myfilelocationstartshere /home/user/doge.jpg mylatstartshere 45 mylongstartshere 45"
``` ```

View File

@ -12,7 +12,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.
# If you're in Europe, and public domain does not exist, then haha. # If you're in Europe, and public domain does not exist, then haha.
TOKEN='179533649:AAHR470oLFSDD8WXy8L87uZFofxM6IDp5oU' TOKEN='tokenhere'
URL='https://api.telegram.org/bot'$TOKEN URL='https://api.telegram.org/bot'$TOKEN
FORWARD_URL=$URL'/forwardMessage' FORWARD_URL=$URL'/forwardMessage'
@ -155,7 +155,7 @@ startproc() {
} }
inproc() { inproc() {
tmux send-keys -t $copname "$MESSAGE tmux send-keys -t $copname "$MESSAGE ${URLS[*]}
" "
ps aux | grep -v grep | grep -q "$copid" || { rm -r $copname; }; ps aux | grep -v grep | grep -q "$copid" || { rm -r $copname; };
} }
@ -199,10 +199,12 @@ process_client() {
copid="$(cat $copidname 2>/dev/null)" copid="$(cat $copidname 2>/dev/null)"
if [ "$copid" = "" ]; then if [ "$copid" = "" ]; then
[ "${URLS[*]}" != "" ] && {
curl -s ${URLS[*]} -o $NAME curl -s ${URLS[*]} -o $NAME
send_file "${USER[ID]}" "$NAME" "$CAPTION" send_file "${USER[ID]}" "$NAME" "$CAPTION"
rm "$NAME" rm "$NAME"
send_location "${USER[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}" }
[ "${LOCATION[*]}" != "" ] && send_location "${USER[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}"
case $MESSAGE in case $MESSAGE in
'/question') '/question')
startproc& startproc&
@ -224,6 +226,8 @@ Written by @topkecleon, Juan Potato (@awkward_potato), Lorenzo Santina (BigNerd9
Contribute to the project: https://github.com/topkecleon/telegram-bot-bash Contribute to the project: https://github.com/topkecleon/telegram-bot-bash
" "
;; ;;
'')
;;
*) *)
send_message "${USER[ID]}" "$MESSAGE" send_message "${USER[ID]}" "$MESSAGE"
esac esac