mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-25 08:47:34 +00:00
fix sync with JSON
This commit is contained in:
parent
b27017f6c9
commit
432f0bcf51
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,3 +2,6 @@
|
|||||||
count
|
count
|
||||||
token
|
token
|
||||||
*.save
|
*.save
|
||||||
|
*.log
|
||||||
|
JSON.sh/*
|
||||||
|
tmp-bot-bash/
|
||||||
|
@ -445,4 +445,4 @@ No - its not more or less insecure as any other Bot written in any other languag
|
|||||||
|
|
||||||
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
|
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
|
||||||
|
|
||||||
#### $$VERSION$$ v0.49-1-g851be83
|
#### $$VERSION$$ v0.49-4-g8e08c1f
|
||||||
|
@ -7,7 +7,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.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.49-2-g0a90edb
|
#### $$VERSION$$ v0.49-4-g8e08c1f
|
||||||
|
|
||||||
|
|
||||||
SHELL=/bin/sh
|
SHELL=/bin/sh
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# description: Start or stop telegram-bash-bot
|
# description: Start or stop telegram-bash-bot
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.49-2-g0a90edb
|
#### $$VERSION$$ v0.49-4-g8e08c1f
|
||||||
#
|
#
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: bashbot
|
# Provides: bashbot
|
||||||
|
14
bashbot.sh
14
bashbot.sh
@ -10,7 +10,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.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.49-4-g8e08c1f
|
#### $$VERSION$$ v0.49-9-gb27017f
|
||||||
|
|
||||||
# get location of bashbot.sh an change to bashbot dir
|
# get location of bashbot.sh an change to bashbot dir
|
||||||
SCRIPT="./$(basename $0)"
|
SCRIPT="./$(basename $0)"
|
||||||
@ -458,17 +458,17 @@ process_client() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Audio
|
# Audio
|
||||||
URLS[AUDIO]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","audio","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")"
|
URLS[AUDIO]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","audio","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")"
|
||||||
# Document
|
# Document
|
||||||
URLS[DOCUMENT]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","document","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")"
|
URLS[DOCUMENT]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","document","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")"
|
||||||
# Photo
|
# Photo
|
||||||
URLS[PHOTO]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","photo",.*,"file_id"\]' | cut -f 2 | cut -d '"' -f 2 | sed -n '$p')")"
|
URLS[PHOTO]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","photo",.*,"file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")"
|
||||||
# Sticker
|
# Sticker
|
||||||
URLS[STICKER]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","sticker","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")"
|
URLS[STICKER]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","sticker","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")"
|
||||||
# Video
|
# Video
|
||||||
URLS[VIDEO]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","video","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")"
|
URLS[VIDEO]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","video","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")"
|
||||||
# Voice
|
# Voice
|
||||||
URLS[VOICE]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","voice","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")"
|
URLS[VOICE]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","voice","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")"
|
||||||
|
|
||||||
# Contact
|
# Contact
|
||||||
CONTACT[NUMBER]="$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","contact","phone_number"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")"
|
CONTACT[NUMBER]="$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","contact","phone_number"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")"
|
||||||
|
37
commands.sh
37
commands.sh
@ -4,25 +4,28 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.49-1-g851be83
|
#### $$VERSION$$ v0.49-4-g8e08c1f
|
||||||
|
|
||||||
# adjust your language setting here, e.g.when run from other user or cron.
|
# adjust your language setting here, e.g.when run from other user or cron.
|
||||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||||
export LC_ALL=C.UTF-8
|
export 'LC_ALL=C.UTF-8'
|
||||||
export LANG=C.UTF-8
|
export 'LANG=C.UTF-8'
|
||||||
export LANGUAGE=C.UTF-8
|
export 'LANGUAGE=C.UTF-8'
|
||||||
|
|
||||||
|
unset IFS
|
||||||
|
# set -f # if you are paranoid use set -f to disable globbing
|
||||||
|
|
||||||
if [ "$1" = "source" ];then
|
if [ "$1" = "source" ];then
|
||||||
# Place the token in the token file
|
# Place the token in the token file
|
||||||
TOKEN=$(cat token)
|
TOKEN="$(cat token)"
|
||||||
# Set INLINE to 1 in order to receive inline queries.
|
# Set INLINE to 1 in order to receive inline queries.
|
||||||
# To enable this option in your bot, send the /setinline command to @BotFather.
|
# To enable this option in your bot, send the /setinline command to @BotFather.
|
||||||
INLINE=0
|
INLINE="0"
|
||||||
# Set to .* to allow sending files from all locations
|
# Set to .* to allow sending files from all locations
|
||||||
FILE_REGEX='/home/user/allowed/.*'
|
FILE_REGEX='/home/user/allowed/.*'
|
||||||
else
|
else
|
||||||
if ! tmux ls | grep -v send | grep -q $copname; then
|
if ! tmux ls | grep -v send | grep -q "$copname"; then
|
||||||
[ ! -z ${URLS[*]} ] && {
|
[ ! -z "${URLS[*]}" ] && {
|
||||||
curl -s ${URLS[*]} -o $NAME
|
curl -s ${URLS[*]} -o $NAME
|
||||||
send_file "${CHAT[ID]}" "$NAME" "$CAPTION"
|
send_file "${CHAT[ID]}" "$NAME" "$CAPTION"
|
||||||
rm -f "$NAME"
|
rm -f "$NAME"
|
||||||
@ -32,25 +35,25 @@ else
|
|||||||
# Inline
|
# Inline
|
||||||
if [ $INLINE == 1 ]; then
|
if [ $INLINE == 1 ]; then
|
||||||
# inline query data
|
# inline query data
|
||||||
iUSER[FIRST_NAME]=$(echo "$res" | sed 's/^.*\(first_name.*\)/\1/g' | cut -d '"' -f3 | tail -1)
|
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)
|
iUSER[LAST_NAME]="$(echo "$res" | sed 's/^.*\(last_name.*\)/\1/g' | cut -d '"' -f3)"
|
||||||
iUSER[USERNAME]=$(echo "$res" | sed 's/^.*\(username.*\)/\1/g' | cut -d '"' -f3 | tail -1)
|
iUSER[USERNAME]="$(echo "$res" | sed 's/^.*\(username.*\)/\1/g' | cut -d '"' -f3 | tail -1)"
|
||||||
iQUERY_ID=$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -1)
|
iQUERY_ID="$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -1)"
|
||||||
iQUERY_MSG=$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -6 | head -1)
|
iQUERY_MSG="$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -6 | head -1)"
|
||||||
|
|
||||||
# Inline examples
|
# Inline examples
|
||||||
if [[ $iQUERY_MSG == photo ]]; then
|
if [[ "$iQUERY_MSG" == "photo" ]]; then
|
||||||
answer_inline_query "$iQUERY_ID" "photo" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg"
|
answer_inline_query "$iQUERY_ID" "photo" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $iQUERY_MSG == sticker ]]; then
|
if [[ "$iQUERY_MSG" == "sticker" ]]; then
|
||||||
answer_inline_query "$iQUERY_ID" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC"
|
answer_inline_query "$iQUERY_ID" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $iQUERY_MSG == gif ]]; then
|
if [[ "$iQUERY_MSG" == "gif" ]]; then
|
||||||
answer_inline_query "$iQUERY_ID" "cached_gif" "BQADBAADIwYAAmwsDAABlIia56QGP0YC"
|
answer_inline_query "$iQUERY_ID" "cached_gif" "BQADBAADIwYAAmwsDAABlIia56QGP0YC"
|
||||||
fi
|
fi
|
||||||
if [[ $iQUERY_MSG == web ]]; then
|
if [[ "$iQUERY_MSG" == "web" ]]; then
|
||||||
answer_inline_query "$iQUERY_ID" "article" "GitHub" "http://github.com/topkecleon/telegram-bot-bash"
|
answer_inline_query "$iQUERY_ID" "article" "GitHub" "http://github.com/topkecleon/telegram-bot-bash"
|
||||||
fi
|
fi
|
||||||
fi &
|
fi &
|
||||||
|
2
notify
2
notify
@ -2,7 +2,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.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#### $$VERSION$$ v0.49-3-g6f1c328
|
#### $$VERSION$$ v0.49-4-g8e08c1f
|
||||||
|
|
||||||
# adjust your language setting here
|
# adjust your language setting here
|
||||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||||
|
2
question
2
question
@ -3,7 +3,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.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
|
|
||||||
#### $$VERSION$$ v0.49-2-g0a90edb
|
#### $$VERSION$$ v0.49-4-g8e08c1f
|
||||||
|
|
||||||
# adjust your language setting here
|
# adjust your language setting here
|
||||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||||
|
Loading…
Reference in New Issue
Block a user