mirror of
https://github.com/danog/telegram-bot-bash.git
synced 2024-11-30 04:29:19 +01:00
Moved customizable settings into commands.sh
This commit is contained in:
parent
aebbff855c
commit
dfd4bc6fa6
@ -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 bot’s 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
8
bashbot.sh
Executable file → Normal 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")
|
||||
|
32
commands.sh
Executable file → Normal file
32
commands.sh
Executable file → Normal file
@ -1,16 +1,25 @@
|
||||
#!/bin/bash
|
||||
# Edit your commands in this file.
|
||||
|
||||
if ! tmux ls | grep -v send | grep -q $copname; then
|
||||
[ ! -z ${URLS[*]} ] && {
|
||||
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"
|
||||
rm "$NAME"
|
||||
}
|
||||
[ ! -z ${LOCATION[*]} ] && send_location "${USER[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}"
|
||||
send_file "${USER[ID]}" "$NAME" "$CAPTION"
|
||||
rm "$NAME"
|
||||
}
|
||||
[ ! -z ${LOCATION[*]} ] && send_location "${USER[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}"
|
||||
|
||||
# Inline
|
||||
if [ $INLINE == 1 ]; then
|
||||
# Inline
|
||||
if [ $INLINE == 1 ]; then
|
||||
# inline query data
|
||||
iUSER[FIRST_NAME]=$(echo "$res" | sed 's/^.*\(first_name.*\)/\1/g' | cut -d '"' -f3 | tail -1)
|
||||
iUSER[LAST_NAME]=$(echo "$res" | sed 's/^.*\(last_name.*\)/\1/g' | cut -d '"' -f3)
|
||||
@ -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
|
Loading…
Reference in New Issue
Block a user