mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-21 23:25:08 +00:00
final adjustments for v1.5
This commit is contained in:
parent
41e6883817
commit
8adca9beea
@ -11,7 +11,7 @@
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 27.01.2021 13:42
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#### $$VERSION$$ v1.45-dev-85-g41e6883
|
||||
#===============================================================================
|
||||
# shellcheck disable=SC2059
|
||||
|
||||
@ -76,7 +76,7 @@ bot_init() {
|
||||
[ -n "${INTERACTIVE}" ] && read -r runuser
|
||||
fi
|
||||
# check if mycommands exist
|
||||
if [ ! -r "${BASHBOT_ETC:-.}/mycommands.sh" ]; then
|
||||
if [[ ! -r "${BASHBOT_ETC:-.}/mycommands.sh" && -r ${BASHBOT_ETC:-.}/mycommands.sh.dist ]]; then
|
||||
printf "Mycommands.sh not found, copy ${GREY}<C>lean file, <E>xamples or <N>one${NC} to mycommands.sh? (c/e/N) N\b"
|
||||
read -r ANSWER
|
||||
[[ "${ANSWER}" =~ ^[cC] ]] && cp -f "${BASHBOT_ETC:-.}/mycommands.sh.clean" "${BASHBOT_ETC:-.}/mycommands.sh"
|
||||
|
@ -7,7 +7,7 @@
|
||||
#
|
||||
# Options: --notest - skip tests
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-84-gae525c4
|
||||
#### $$VERSION$$ v1.45-dev-85-g41e6883
|
||||
##############################################################
|
||||
|
||||
#shellcheck disable=SC1090
|
||||
@ -20,7 +20,7 @@ DISTDIR="./DIST/${DISTNAME}"
|
||||
DISTMKDIR="data-bot-bash logs bin bin/logs addons"
|
||||
|
||||
DISTFILES="bashbot.sh commands.sh mycommands.sh.clean bin doc examples scripts modules LICENSE README.md README.txt README.html"
|
||||
DISTFILESDEV="dev/make-standalone.sh dev/make-standalone.sh.include dev/inject-json.sh dev/make-html.sh dev/obfuscate.sh"
|
||||
DISTFILESDEV="dev/make-standalone.sh dev/inject-json.sh dev/make-html.sh dev/obfuscate.sh"
|
||||
DISTFILESDIST="mycommands.sh mycommands.conf bashbot.rc $(echo "addons/"*.sh)"
|
||||
|
||||
# run tests first!
|
||||
|
@ -7,6 +7,7 @@ bashbot.rc
|
||||
mycommands.sh
|
||||
mycommands.conf
|
||||
awk-patch.sh
|
||||
make-standalone.sh.include
|
||||
*.jssh*
|
||||
botacl
|
||||
*.flock
|
||||
|
@ -11,7 +11,7 @@
|
||||
# If you your bot is finished you can use make-standalone.sh to create the
|
||||
# the old all-in-one bashbot: bashbot.sh and commands.sh only!
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-84-gae525c4
|
||||
#### $$VERSION$$ v1.45-dev-85-g41e6883
|
||||
###################################################################
|
||||
|
||||
# include git config and change to base dir
|
||||
@ -37,11 +37,13 @@ fi
|
||||
#DISTNAME="telegram-bot-bash"
|
||||
DISTDIR="./STANDALONE"
|
||||
DISTMKDIR="data-bot-bash logs bin/logs addons"
|
||||
DISTFILES="bashbot.sh bashbot.rc commands.sh mycommands.sh modules scripts LICENSE README.* doc botacl botconfig.jssh addons"
|
||||
DISTFILES="bashbot.sh commands.sh mycommands.sh modules scripts LICENSE README.* doc addons"
|
||||
DISTBINFILES="bin/bashbot_env.inc.sh bin/bashbot_stats.sh bin/process_batch.sh bin/process_update.sh bin/send_broadcast.sh bin/send_message.sh"
|
||||
|
||||
# add extra files
|
||||
DISTFILES+=" $(cat "${BASE_DIR}/dev/${0##*/}.include")"
|
||||
# add extra files, minimum mycommands.conf
|
||||
extrafile="${BASE_DIR}/dev/${0##*/}.include"
|
||||
[ ! -f "${extrafile}" ] && printf "bashbot.rc\nbotacl\nbotconfig.jssh\nmycommands.conf\ndev/obfuscate.sh\n" >"${extrafile}"
|
||||
DISTFILES+=" $(<"${extrafile}")"
|
||||
|
||||
# create dir for distribution and copy files
|
||||
printf "Create directories and copy files\n"
|
||||
|
@ -1 +1,5 @@
|
||||
bashbot.rc
|
||||
botacl
|
||||
botconfig.jssh
|
||||
mycommands.conf
|
||||
dev/obfuscate.sh
|
||||
|
@ -127,7 +127,7 @@ bin/send_message.sh "CHAT[ID]" "Hey, I just wanted to let you know that the bot'
|
||||
To replace a message already sent to one user or chat run the following command:
|
||||
|
||||
```bash
|
||||
bin/send_edit_message.sh "CHAT[ID]" "12345" "Done!"
|
||||
bin/edit_message.sh "CHAT[ID]" "12345" "Done!"
|
||||
|
||||
["OK"] "true"
|
||||
["ID"] "12345"
|
||||
@ -150,9 +150,14 @@ Note: to get help about a script in bin/ run `scriptname.sh --help`
|
||||
Evertime a Telegram update is received, you can read incoming data using the following variables:
|
||||
In case you need other update values, the array `UPD` contains complete Telegram response.
|
||||
|
||||
### Regular Messages
|
||||
### Processing Messages
|
||||
|
||||
These Variables are always present in regular messages:
|
||||
If an update is received from Telegram, the message is pre processed by Bashbot and the following bash variables are set for use in `mycommands.sh`.
|
||||
|
||||
These variables are always present if a message is pre processed:
|
||||
|
||||
* `${ME}`: Name of your bot
|
||||
* `${BOTADMIN}`: User id of bot administrator
|
||||
|
||||
* `${MESSAGE}`: Current message text
|
||||
* `${MESSAGE[ID]}`: ID of current message
|
||||
@ -215,11 +220,10 @@ The following variables are set if the message contains optional parts:
|
||||
|
||||
### Service Messages
|
||||
|
||||
Service Messages are regular messages not itended for end users, instead they signal special events to the
|
||||
client, e.g. new users.
|
||||
Service Messages are updates not itended for end users, instead they signal special events in a chat, e.g. new users.
|
||||
|
||||
If a service message is received bashbot sets MESSAGE to the service message type as a command,
|
||||
e.g. if a new user joins a chat MESSAGE is set to "/_new_chat_user".
|
||||
If a service message is received bashbot pre processing sets `${MESSAGE}` according to the service message type,
|
||||
e.g. if a new user joins a chat MESSAGE is set to `/_new_chat_user ...`.
|
||||
|
||||
* `$SERVICE`: This array contains info about received service messages.
|
||||
* `${SERVICE}`: "yes" if service message is received
|
||||
@ -255,10 +259,17 @@ e.g. if a new user joins a chat MESSAGE is set to "/_new_chat_user".
|
||||
|
||||
|
||||
### Inline query messages
|
||||
Inline query messages are special messages used for interaction with the user,
|
||||
they contain the following variables only:
|
||||
Inline query messages are special messages for direct interaction with your bot.
|
||||
If an user starts an inline conversation an inline query is sent after each user keystroke.
|
||||
|
||||
* `${iQUERY}`: Current inline query
|
||||
To receive inline messages you must set `inline=1` in `mycommands.conf` and in botfather.
|
||||
THe message contatains all characters so far typed from the user.
|
||||
|
||||
An received inline query must be anserwered with `answer_inline_query`, see also (Inline Query)[6_reference.md#inline-query]
|
||||
|
||||
If an inline query is received only the following variables are available:
|
||||
|
||||
* `${iQUERY}`: Inline message typed so far by user
|
||||
* `$iQUERY`: This array contains the ID, First name, last name, username and user id of the sender of the current inline query.
|
||||
* `${iQUERY[ID]}`: Inline query ID
|
||||
* `${iQUERY[USER_ID]}`: User's id
|
||||
@ -266,9 +277,9 @@ they contain the following variables only:
|
||||
* `${iQUERY[LAST_NAME]}`: User's last name
|
||||
|
||||
|
||||
|
||||
### Callback button messages
|
||||
Callback button messages special messages swedn from callback buttons,
|
||||
they contain the following variables only:
|
||||
Callback button messages special messages swend from callback buttons, they contain the following variables only:
|
||||
|
||||
* `$iBUTTON`: This array contains the ID, First name, last name, username and user id of the user clicked on the button
|
||||
* `${iBUTTON[ID]}`: Callback query ID
|
||||
@ -287,6 +298,8 @@ they contain the following variables only:
|
||||
After every `send_xxx` `get_xxx` call the array BOTSENT contains the most important values from Telegram response.
|
||||
In case you need other response values , the array `UPD` contains complete Telegram response.
|
||||
|
||||
You can use the array values to check if a commands was successful and get returned values from Telegram.
|
||||
|
||||
### BOTSENT array
|
||||
|
||||
* `$BOTSENT`: This array contains the parsed results from the last transmission to telegram.
|
||||
@ -377,5 +390,5 @@ send_action "${CHAT[ID]}" "action"
|
||||
#### [Prev Create Bot](1_firstbot.md)
|
||||
#### [Next Advanced Usage](3_advanced.md)
|
||||
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#### $$VERSION$$ v1.45-dev-85-g41e6883
|
||||
|
||||
|
@ -826,7 +826,7 @@ fi
|
||||
|
||||
----
|
||||
|
||||
### Inline Queries - answer direct queries to bot
|
||||
### Inline Query
|
||||
Inline Queries allows users to interact with your bot directly without sending extra commands.
|
||||
As an answer to an inline query you can send back one or more results to the Telegram client.
|
||||
The Telegram client will then show the results to the user and let him select one.
|
||||
@ -1673,5 +1673,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca
|
||||
#### [Prev Best Practice](5_practice.md)
|
||||
#### [Next Notes for Developers](7_develop.md)
|
||||
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#### $$VERSION$$ v1.45-dev-85-g41e6883
|
||||
|
||||
|
@ -9,8 +9,7 @@ If your server is reachable from the Internet its possible to use the method des
|
||||
|
||||
Prerequisite for receiving Telegram updates with webhook is a valid SSL certificate, a self signed certificate will not be sufficient.
|
||||
|
||||
*Note:* You need at least sudo rights to setup webhook.
|
||||
|
||||
Webhook processing require special setup on server and Telegram side, therefore it's implemented as separate scripts and you need at least sudo rights to setup.
|
||||
|
||||
#### Setup Apache webhook
|
||||
|
||||
@ -99,5 +98,5 @@ webhook updates only over secure TLS connections with a valid SSL certificate ch
|
||||
`socat` looks like a tool to listen for Telegram updates from bash scripts, let's see ...
|
||||
|
||||
|
||||
#### $$VERSION$$ v1.45-dev-77-g235f26a
|
||||
#### $$VERSION$$ v1.45-dev-85-g41e6883
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
# File: processUpdates.sh
|
||||
# Note: DO NOT EDIT! this file will be overwritten on update
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#### $$VERSION$$ v1.45-dev-85-g41e6883
|
||||
##################################################################
|
||||
|
||||
##############
|
||||
@ -296,9 +296,12 @@ start_bot() {
|
||||
DEBUGMSG="Start BASHBOT updates in Mode \"${1:-normal}\" =========="
|
||||
log_update "${DEBUGMSG}"
|
||||
# redirect to Debug.log
|
||||
if [[ "$1" == *"debug" ]]; then
|
||||
# shellcheck disable=SC2153
|
||||
[[ "$1" == *"debug" ]] && exec &>>"${DEBUGLOG}"
|
||||
log_debug "${DEBUGMSG}"; DEBUGMSG="$1"
|
||||
exec &>>"${DEBUGLOG}"
|
||||
log_debug "${DEBUGMSG}";
|
||||
fi
|
||||
DEBUGMSG="$1"
|
||||
[[ "${DEBUGMSG}" == "xdebug"* ]] && set -x
|
||||
# cleaup old pipes and empty logfiles
|
||||
find "${DATADIR}" -type p -not -name "webhook-fifo-*" -delete
|
||||
|
Loading…
Reference in New Issue
Block a user