mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-22 15:35:09 +00:00
provide a clean mycommánds.sh file
This commit is contained in:
parent
bf8a9117aa
commit
a5975d93c4
14
commands.sh
14
commands.sh
@ -8,14 +8,14 @@
|
|||||||
# | |__/ / |_| | | | | | |_| | |__ | |____( (_| | | |__ _
|
# | |__/ / |_| | | | | | |_| | |__ | |____( (_| | | |__ _
|
||||||
# |_____/ \___/ |_| |_|\___/ \___) |_______)____|_|\___)_|
|
# |_____/ \___/ |_| |_|\___/ \___) |_______)____|_|\___)_|
|
||||||
#
|
#
|
||||||
# this file *MUST* not edited! palce your config and commands in
|
# this file *MUST* not be edited! palce your config and commands in
|
||||||
# the provided mycommnds.sh. a clean version is avalible as mycommands.clean
|
# the file "mycommnds.sh". a clean version is provided as "mycommands.clean"
|
||||||
#
|
#
|
||||||
|
|
||||||
# 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.94-dev3-1-g8a119f8
|
#### $$VERSION$$ v0.94-dev3-2-gbf8a911
|
||||||
#
|
#
|
||||||
|
|
||||||
# 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.
|
||||||
@ -29,7 +29,7 @@ unset IFS
|
|||||||
|
|
||||||
#
|
#
|
||||||
# this file *MUST* not edited!
|
# this file *MUST* not edited!
|
||||||
# copy "mycommands,sh,dist" to "mycommnds,sh" and change the strings there
|
# copy "mycommands.sh.dist" to "mycommnds.sh" and change the strings there
|
||||||
bashbot_info='This is bashbot, the Telegram bot written entirely in bash.
|
bashbot_info='This is bashbot, the Telegram bot written entirely in bash.
|
||||||
It features background tasks and interactive chats, and can serve as an interface for CLI programs.
|
It features background tasks and interactive chats, and can serve as an interface for CLI programs.
|
||||||
It currently can send, recieve and forward messages, custom keyboards, photos, audio, voice, documents, locations and video files.
|
It currently can send, recieve and forward messages, custom keyboards, photos, audio, voice, documents, locations and video files.
|
||||||
@ -37,7 +37,7 @@ It currently can send, recieve and forward messages, custom keyboards, photos, a
|
|||||||
|
|
||||||
#
|
#
|
||||||
# this file *MUST* not edited!
|
# this file *MUST* not edited!
|
||||||
# copy "mycommands,sh,dist" to "mycommnds,sh" and change the strings there
|
# copy "mycommands.sh.dist" to "mycommnds.sh" and change the strings there
|
||||||
bashbot_help='*Available commands*:
|
bashbot_help='*Available commands*:
|
||||||
*• /start*: _Start bot and get this message_.
|
*• /start*: _Start bot and get this message_.
|
||||||
*• /help*: _Get this message_.
|
*• /help*: _Get this message_.
|
||||||
@ -61,7 +61,7 @@ fi
|
|||||||
|
|
||||||
#
|
#
|
||||||
# this file *MUST* not edited!
|
# this file *MUST* not edited!
|
||||||
# copy "mycommands,sh,dist" to "mycommnds,sh" and change the values there
|
# copy "mycommands.sh.dist" to "mycommnds.sh" and change the values there
|
||||||
# defaults to no inline and nonsense home dir
|
# defaults to no inline and nonsense home dir
|
||||||
export INLINE="0"
|
export INLINE="0"
|
||||||
export FILE_REGEX='/home/user/allowed/.*'
|
export FILE_REGEX='/home/user/allowed/.*'
|
||||||
@ -93,7 +93,7 @@ if [ "${1}" = "" ] || [[ "${1}" == *"debug"* ]];then
|
|||||||
case "${MESSAGE}" in
|
case "${MESSAGE}" in
|
||||||
################################################
|
################################################
|
||||||
# this file *MUST* not edited!
|
# this file *MUST* not edited!
|
||||||
# copy "mycommands,sh,dist" to "mycommnds,sh" and change the values and add your commands there
|
# copy "mycommands.sh.dist" to "mycommnds.sh" and change the values and add your commands there
|
||||||
#
|
#
|
||||||
# GLOBAL commands start here, edit messages only
|
# GLOBAL commands start here, edit messages only
|
||||||
'/info'*)
|
'/info'*)
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# files: mycommands.sh.dist
|
#########
|
||||||
# copy to mycommands.sh and add all your commands and functions here ...
|
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.94-dev3-0-geef955a
|
# files: mycommands.sh.dist
|
||||||
|
#
|
||||||
|
# this is an out of the box test and example file to show what you can do in mycommands.ah
|
||||||
|
#
|
||||||
|
# #### if you start to develop you own bot, use the clean version of this file:
|
||||||
|
# #### mycommands.clean
|
||||||
|
#
|
||||||
|
#### $$VERSION$$ v0.94-dev3-2-gbf8a911
|
||||||
#
|
#
|
||||||
|
|
||||||
# uncomment the following lines to overwrite info and help messages
|
# uncomment the following lines to overwrite info and help messages
|
||||||
|
98
mycommands.sh.clean
Normal file
98
mycommands.sh.clean
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
########
|
||||||
|
#
|
||||||
|
# files: mycommands.sh.clean
|
||||||
|
# copy to mycommands.sh and add all your commands and functions here ...
|
||||||
|
#
|
||||||
|
#### $$VERSION$$ v0.94-dev3-2-gbf8a911
|
||||||
|
#
|
||||||
|
|
||||||
|
##########
|
||||||
|
# edit the following lines to fit your bot usage
|
||||||
|
|
||||||
|
bashbot_info='This is bashbot, the Telegram bot written entirely in bash.
|
||||||
|
'
|
||||||
|
|
||||||
|
bashbot_help='*Available commands*:
|
||||||
|
'
|
||||||
|
res=""
|
||||||
|
|
||||||
|
# Set INLINE to 1 in order to receive inline queries.
|
||||||
|
# To enable this option in your bot ypu must also send the /setinline command to @BotFather.
|
||||||
|
export INLINE="0"
|
||||||
|
|
||||||
|
# NOTE: this is a regex, not shell globbing! you must use a valid egex,
|
||||||
|
# '.' matches any charater and '.*' matches all remaining charatcers!
|
||||||
|
# additionally you must escape special charaters with '\', e.g. '\. \? \[ \*" to match them literally
|
||||||
|
# do NOT set to .* as this allow sending files from all locations!
|
||||||
|
export FILE_REGEX='^/home/user/allowed/.*'
|
||||||
|
|
||||||
|
########
|
||||||
|
# special network setups may require to provide additional ARGS to curl
|
||||||
|
#
|
||||||
|
# example: run bashbot over TOR or SOCKS proxy
|
||||||
|
# export BASHBOT_CURL_ARGS="--socks5-hostname 127.0.0.1:9050" # TOR
|
||||||
|
# export BASHBOT_CURL_ARGS="--socks5-hostname 127.0.0.1" # regular SOCKS
|
||||||
|
|
||||||
|
if [ "$1" != "source" ];then
|
||||||
|
# your additional bahsbot commands
|
||||||
|
# NOTE: command can have @botname attached, you must add * in case tests...
|
||||||
|
mycommands() {
|
||||||
|
|
||||||
|
case "${MESSAGE}" in
|
||||||
|
##################
|
||||||
|
# example command, replace them by your own
|
||||||
|
'/echo'*) # example echo command
|
||||||
|
send_normal_message "${CHAT[ID]}" "$MESSAGE"
|
||||||
|
;;
|
||||||
|
|
||||||
|
##########
|
||||||
|
# command overwrite examples
|
||||||
|
# return 0 -> run default command afterwards
|
||||||
|
# return 1 -> skip possible default commands
|
||||||
|
'/info'*) # output date in front of regular info
|
||||||
|
send_normal_message "${CHAT[ID]}" "$(date)"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
'/kickme'*) # this will replace the /kickme command
|
||||||
|
send_markdown_mesage "${CHAT[ID]}" "*This bot will not kick you!*"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
myinlines() {
|
||||||
|
#######################
|
||||||
|
# this fuinction is called only if you has set INLINE=1 !!
|
||||||
|
# shellcheck disable=SC2128
|
||||||
|
iQUERY="${iQUERY,,}"
|
||||||
|
|
||||||
|
|
||||||
|
case "${iQUERY}" in
|
||||||
|
##################
|
||||||
|
# example inline command, replace it by your own
|
||||||
|
"image "*) # search images with yahoo
|
||||||
|
local search="${iQUERY#* }"
|
||||||
|
answer_inline_multi "${iQUERY[ID]}" "$(my_image_search "${search}")"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# place your processing functions here
|
||||||
|
|
||||||
|
# example inline processing function, not really useful
|
||||||
|
# $1 search parameter
|
||||||
|
my_image_search(){
|
||||||
|
local image result sep="" count="1"
|
||||||
|
result="$(wget --user-agent 'Mozilla/5.0' -qO - "https://images.search.yahoo.com/search/images?p=$1" | sed 's/</\n</g' | grep "<img src=")"
|
||||||
|
while read -r image; do
|
||||||
|
[ "$count" -gt "20" ] && break
|
||||||
|
image="${image#* src=\'}"; image="${image%%&pid=*}"
|
||||||
|
[[ "${image}" = *"src="* ]] && continue
|
||||||
|
echo "${sep}"; inline_query_compose "$RANDOM" "photo" "${image}"; sep=","
|
||||||
|
count=$(( count + 1 ))
|
||||||
|
done <<<"${result}"
|
||||||
|
}
|
||||||
|
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user