2016-04-17 20:00:37 +02:00
#!/bin/bash
# Edit your commands in this file.
2016-04-19 11:49:35 +02:00
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
2016-04-18 12:05:31 +02:00
if [ " $1 " = "source" ] ; then
2016-05-13 17:45:56 +02:00
# Place the token in the token file
TOKEN = $( cat token)
2016-04-19 11:49:35 +02:00
# Set INLINE to 1 in order to receive inline queries.
2016-04-18 12:05:31 +02:00
# To enable this option in your bot, send the /setinline command to @BotFather.
INLINE = 0
# Set to .* to allow sending files from all locations
2016-06-04 22:34:44 +02:00
FILE_REGEX = '.*'
2016-04-18 12:05:31 +02:00
else
if ! tmux ls | grep -v send | grep -q $copname ; then
[ ! -z ${ URLS [*] } ] && {
2016-04-17 20:00:37 +02:00
curl -s ${ URLS [*] } -o $NAME
2016-04-18 12:05:31 +02:00
send_file " ${ USER [ID] } " " $NAME " " $CAPTION "
rm " $NAME "
}
[ ! -z ${ LOCATION [*] } ] && send_location " ${ USER [ID] } " " ${ LOCATION [LATITUDE] } " " ${ LOCATION [LONGITUDE] } "
2016-04-19 11:49:35 +02:00
# Inline
2016-04-18 12:05:31 +02:00
if [ $INLINE = = 1 ] ; then
2016-04-17 20:00:37 +02:00
# 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)
2016-04-19 11:49:35 +02:00
2016-04-17 20:00:37 +02:00
# 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
2016-04-19 11:49:35 +02:00
2016-04-17 20:00:37 +02:00
if [ [ $iQUERY_MSG = = sticker ] ] ; then
answer_inline_query " $iQUERY_ID " "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC"
fi
2016-04-19 11:49:35 +02:00
2016-04-17 20:00:37 +02:00
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
2016-04-18 12:05:31 +02:00
fi
case $MESSAGE in
2016-04-17 20:00:37 +02:00
'/info' )
send_message " ${ USER [ID] } " "This is bashbot, the Telegram bot written entirely in bash."
; ;
'/start' )
2016-06-04 22:34:44 +02:00
send_message " ${ USER [ID] } " " This bot can be used to edit the id3 tags of audio files.
2016-04-17 20:00:37 +02:00
Available commands:
2016-06-04 22:34:44 +02:00
• /start: Start bot and start editing process.
2016-04-19 11:49:35 +02:00
• /cancel: Cancel any currently running interactive chats.
2016-06-04 22:34:44 +02:00
Written Daniil Gentili ( @danogentili) .
http://github.com/danog/id3bot
2016-04-17 20:00:37 +02:00
"
2016-06-04 22:34:44 +02:00
startproc "./question"
2016-04-17 20:00:37 +02:00
; ;
'/cancel' )
if tmux ls | grep -q $copname ; then killproc && send_message " ${ USER [ID] } " "Command canceled." ; else send_message " ${ USER [ID] } " "No command is currently running." ; fi
; ;
*)
if tmux ls | grep -v send | grep -q $copname ; then inproc; else send_message " ${ USER [ID] } " " $MESSAGE " "safe" ; fi
; ;
2016-04-18 12:05:31 +02:00
esac
2016-04-19 11:49:35 +02:00
fi