Updated bot

This commit is contained in:
Daniil Gentili 2016-04-28 22:06:24 +02:00
parent bab6c19676
commit 5c25d9eb9b
5 changed files with 4764 additions and 31 deletions

View File

@ -280,9 +280,11 @@ process_client() {
# User
USER[ID]=$(echo "$res" | egrep '\["result",0,"message","chat","id"\]' | cut -f 2)
U=$(echo "$res" | egrep '\["result",0,"message","user","id"\]' | cut -f 2)
USER[FIRST_NAME]=$(echo "$res" | egrep '\["result",0,"message","chat","first_name"\]' | cut -f 2 | cut -d '"' -f 2)
USER[LAST_NAME]=$(echo "$res" | egrep '\["result",0,"message","chat","last_name"\]' | cut -f 2 | cut -d '"' -f 2)
USER[USERNAME]=$(echo "$res" | egrep '\["result",0,"message","chat","username"\]' | cut -f 2 | cut -d '"' -f 2)
[ "$U" != "${USER[ID]}" ] && GROUP=y
# Audio
URLS[AUDIO]=$(get_file $(echo "$res" | egrep '\["result",0,"message","audio","file_id"\]' | cut -f 2 | cut -d '"' -f 2))
@ -324,7 +326,7 @@ process_client() {
# source the script with source as param to use functions in other scripts
while [ "$1" == "startbot" ]; do {
res=$(curl -s $UPD_URL$OFFSET | ./JSON.sh -s)
res="$(curl -s $UPD_URL$OFFSET | ./JSON.sh -s)"
# Offset
OFFSET=$(echo "$res" | egrep '\["result",0,"update_id"\]' | cut -f 2)
@ -351,13 +353,13 @@ case "$1" in
;;
"broadcast")
echo "Sending the broadcast $* to $(wc -l count | sed 's/count//g')users."
[ $(wc -l count | sed 's/ count//g') -gt 100 ] && sleep="sleep 1"
[ $(wc -l count | sed 's/ count//g') -gt 100 ] && sleep="sleep 2"
shift
for f in $(cat count);do send_message ${f//COUNT} "$*"; $sleep;done
;;
"start")
tmux kill-session -t $ME&>/dev/null
tmux new-session -d -s $ME "bash $SCRIPT startbot" && echo "Bot started successfully. Tmux session name is $ME" || echo "An error occurred while starting the bot."
tmux new-session -d -s $ME "bash -c \"while :;do bash $SCRIPT startbot&>>o;done\"" && echo "Bot started successfully. Tmux session name is $ME" || echo "An error occurred while starting the bot."
;;
"kill")
tmux kill-session -t $ME &>/dev/null

View File

@ -10,8 +10,8 @@ if [ "$1" = "source" ];then
# Set to .* to allow sending files from all locations
FILE_REGEX='/home/user/allowed/.*'
else
ALLOW="${URLS[PHOTO]} ${URLS[STICKER]} ${URLS[DOCUMENT]}"
if ! tmux ls | grep -v send | grep -q $copname; then
[ ! -z $ALLOW ] && {
send_action ${USER[ID]} typing
if echo "$ALLOW" | grep -qE '.jpg$\|.png$\|.jpeg$'; then
@ -25,32 +25,6 @@ else
res=$(curl -s "$MSG_URL" -d "chat_id=${USER[ID]}" -d "text=$result" -d "reply_to_message_id=$MESSAGE_ID")
return
}
# 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)
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_MSG=$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -6 | head -1)
# Inline examples
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"
fi
if [[ $iQUERY_MSG == sticker ]]; then
answer_inline_query "$iQUERY_ID" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC"
fi
if [[ $iQUERY_MSG == gif ]]; then
answer_inline_query "$iQUERY_ID" "cached_gif" "BQADBAADIwYAAmwsDAABlIia56QGP0YC"
fi
if [[ $iQUERY_MSG == web ]]; then
answer_inline_query "$iQUERY_ID" "article" "Telegram" "https://telegram.org/"
fi
fi
fi
case $MESSAGE in
'/start')
send_message "${USER[ID]}" "This is a bot client for captionbot.ai written in bash.
@ -67,11 +41,13 @@ Contribute to the project: https://github.com/danog/captionbot-clients
Bot written by @topkecleon, Juan Potato (@awkward_potato), Lorenzo Santina (BigNerd95) and Daniil Gentili (@danogentili)
Contribute to the project: https://github.com/topkecleon/telegram-bot-bash
Do check out my other projects @ https://daniil.it and my other bots, @mklwp_bot and @video_dl_bot!
To start, send me a photo.
"
;;
*)
if tmux ls | grep -v send | grep -q $copname;then inproc; else result=$(./captionbot.sh "$MESSAGE" script) && res=$(curl -s "$MSG_URL" -d "chat_id=${USER[ID]}" -d "text=$result" -d "reply_to_message_id=$MESSAGE_ID"); fi
#[ "$GROUP" = "y" ] && result=$(./captionbot.sh "$MESSAGE" script) && res=$(curl -s "$MSG_URL" -d "chat_id=${USER[ID]}" -d "text=$result" -d "reply_to_message_id=$MESSAGE_ID")
;;
esac
fi

View File

@ -189,3 +189,210 @@ COUNT35897945
COUNT74447567
COUNT172985049
COUNT116885101
COUNT102151716
COUNT137403862
COUNT130668426
COUNT184582206
COUNT161066988
COUNT102400442
COUNT63397093
COUNT11805988
COUNT128578628
COUNT40454193
COUNT46145305
COUNT110771442
COUNT52809996
COUNT-1001014225431
COUNT1025072
COUNT7507510
COUNT168753958
COUNT-1001010288163
COUNT103422287
COUNT8179608
COUNT12396778
COUNT198396057
COUNT-1001041839627
COUNT134962481
COUNT-1001037549129
COUNT159131092
COUNT56281886
COUNT4663829
COUNT-1001007236533
COUNT8616489
COUNT-1001048611550
COUNT89431995
COUNT142503025
COUNT24157761
COUNT115825833
COUNT-1001046069576
COUNT145601548
COUNT147642662
COUNT135262894
COUNT65809712
COUNT-146412452
COUNT137393338
COUNT38179208
COUNT9363112
COUNT80981951
COUNT121414901
COUNT77147671
COUNT59108743
COUNT103123222
COUNT140529465
COUNT117955269
COUNT163578079
COUNT93096536
COUNT49895827
COUNT67689842
COUNT155345582
COUNT211699415
COUNT-141314115
COUNT126688919
COUNT60333927
COUNT-1001006315258
COUNT113228944
COUNT24924135
COUNT66980321
COUNT95740039
COUNT59863310
COUNT170654170
COUNT5386770
COUNT145666983
COUNT21200968
COUNT9850154
COUNT151010862
COUNT970783
COUNT107330669
COUNT32090517
COUNT87947835
COUNT65532938
COUNT166940838
COUNT191808329
COUNT170159667
COUNT13646068
COUNT31603247
COUNT149709042
COUNT5628488
COUNT149263650
COUNT141070020
COUNT178939544
COUNT132929380
COUNT39276759
COUNT127541957
COUNT74208897
COUNT144254903
COUNT181947806
COUNT129450690
COUNT65744029
COUNT132161135
COUNT48464848
COUNT152321430
COUNT133433434
COUNT149567276
COUNT18660195
COUNT31129991
COUNT119151872
COUNT19459835
COUNT58317321
COUNT14260144
COUNT164823155
COUNT-1001046178833
COUNT85356629
COUNT361565
COUNT113216540
COUNT81643930
COUNT183796050
COUNT6722095
COUNT96948910
COUNT21751629
COUNT63584800
COUNT127628055
COUNT58716786
COUNT147817245
COUNT144412981
COUNT32197771
COUNT219474624
COUNT60347791
COUNT46542315
COUNT-15090992
COUNT-1001039329757
COUNT168862348
COUNT-1001040352111
COUNT50862938
COUNT109130295
COUNT7525035
COUNT119707972
COUNT119995388
COUNT75243051
COUNT132046223
COUNT94928851
COUNT156244221
COUNT93699492
COUNT-32485233
COUNT104406525
COUNT73252573
COUNT113019166
COUNT208167479
COUNT77626666
COUNT214526488
COUNT128847019
COUNT163327636
COUNT110310027
COUNT210684193
COUNT171462601
COUNT91896111
COUNT-1001042695571
COUNT33612852
COUNT109783055
COUNT101898968
COUNT60208088
COUNT110367207
COUNT51718050
COUNT176619450
COUNT216762776
COUNT178049010
COUNT146990721
COUNT122520076
COUNT149284108
COUNT-144050436
COUNT140639228
COUNT185389569
COUNT171330171
COUNT18230012
COUNT47991050
COUNT132226921
COUNT124474493
COUNT48336144
COUNT172706700
COUNT171482996
COUNT158193741
COUNT129831218
COUNT127452397
COUNT191099793
COUNT205970316
COUNT45516361
COUNT137453456
COUNT199617605
COUNT196566344
COUNT53126669
COUNT100183650
COUNT137857954
COUNT133877526
COUNT28362815
COUNT214523786
COUNT114511188
COUNT78664244
COUNT42221914
COUNT199752993
COUNT48374136
COUNT64010774
COUNT199714087
COUNT43807971
COUNT89121486
COUNT204638453
COUNT-110023981
COUNT205934484
COUNT-113630796
COUNT28187834
COUNT209499097
COUNT-144039502

BIN
bash/file_9909.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

4548
bash/o Normal file

File diff suppressed because it is too large Load Diff