Moved customizable settings into commands.sh

This commit is contained in:
Daniil Gentili 2016-04-18 12:05:31 +02:00
parent aebbff855c
commit dfd4bc6fa6
3 changed files with 26 additions and 20 deletions

View File

@ -70,7 +70,7 @@ Clone the repository:
git clone https://github.com/topkecleon/telegram-bot-bash
```
Paste the token on line 15 (instead of tokenhere).
Paste the token on line 6 of commands.sh (instead of tokenhere).
Then start editing the commands.
### Receive data
@ -115,7 +115,7 @@ This function also allows a third parameter that disables additional function pa
```
send_message "${USER[ID]}" "lol" "safe"
```
To send images, videos, voice files, photos ecc use the ```send_photo``` function (remember to change the safety Regex @ line 94 to allow sending files only from certain directories):
To send images, videos, voice files, photos ecc use the ```send_photo``` function (remember to change the safety Regex @ line 11 of command.sh to allow sending files only from certain directories):
```
send_file "${USER[ID]}" "/home/user/doge.jpg" "Lool"
```
@ -167,7 +167,7 @@ Please note that you can either send a location or a venue, not both. To send a
The following commands allows users to interact with your bot via *inline queries*.
In order to enable **inline mode**, send `/setinline` command to [@BotFather](https://telegram.me/botfather) and provide the placeholder text that the user will see in the input field after typing your bots name.
Also, edit line 21 from `bashbot.sh` putting a "1".
Also, edit line 9 from `commands.sh` putting a "1".
Note that you can't modify the first two parameters of the function `answer_inline_query`, only the ones after them.
To send messsages or links through an *inline query*:

8
bashbot.sh Executable file → Normal file
View File

@ -12,13 +12,9 @@
# 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.
TOKEN='tokenhere'
TOKEN='197476763:AAGj-kg10J97h7t57DawEJYs_ljxKFuKaJ0'
source commands.sh source
URL='https://api.telegram.org/bot'$TOKEN
# Set INLINE to 1 in order to receive inline queries.
# To enable this option in your bot, send the /setinline command to @BotFather.
INLINE=0
SCRIPT="$0"
MSG_URL=$URL'/sendMessage'
@ -196,7 +192,7 @@ send_file() {
[ "$2" = "" ] && return
local chat_id=$1
local file=$2
echo "$file" | grep -qE '/home/allowed/.*' || return
echo "$file" | grep -qE $FILE_REGEX || return
local ext="${file##*.}"
case $ext in
"mp3")

18
commands.sh Executable file → Normal file
View File

@ -1,7 +1,16 @@
#!/bin/bash
# Edit your commands in this file.
if ! tmux ls | grep -v send | grep -q $copname; then
if [ "$1" = "source" ];then
# Edit the token in here
TOKEN='tokenhere'
# Set INLINE to 1 in order to receive inline queries.
# To enable this option in your bot, send the /setinline command to @BotFather.
INLINE=0
# Set to .* to allow sending files from all locations
FILE_REGEX='/home/user/allowed/.*'
else
if ! tmux ls | grep -v send | grep -q $copname; then
[ ! -z ${URLS[*]} ] && {
curl -s ${URLS[*]} -o $NAME
send_file "${USER[ID]}" "$NAME" "$CAPTION"
@ -34,8 +43,8 @@ if ! tmux ls | grep -v send | grep -q $copname; then
answer_inline_query "$iQUERY_ID" "article" "Telegram" "https://telegram.org/"
fi
fi
fi
case $MESSAGE in
fi
case $MESSAGE in
'/question')
startproc "./question"
;;
@ -62,4 +71,5 @@ Contribute to the project: https://github.com/topkecleon/telegram-bot-bash
*)
if tmux ls | grep -v send | grep -q $copname;then inproc; else send_message "${USER[ID]}" "$MESSAGE" "safe";fi
;;
esac
esac
fi