Skip to content

Commit

Permalink
Merge pull request #20 from kiki-kanri/kiki-kanri-feat/http-port-env
Browse files Browse the repository at this point in the history
feat: use TELEGRAM_HTTP_PORT env to set the api server listening port
  • Loading branch information
JrooTJunior authored Oct 20, 2024
2 parents a3e3b4c + bf59a48 commit a405943
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ Enable statistics HTTP endpoint.

Usage: `-e TELEGRAM_STAT=1 -p 8082:8082` and then check that `curl http://<host>:8082` returns server statistic


### `TELEGRAM_FILTER`

"<remainder>/<modulo>". Allow only bots with 'bot_user_id % modulo == remainder'


### `TELEGRAM_MAX_WEBHOOK_CONNECTIONS`

default value of the maximum webhook connections per bot
Expand Down Expand Up @@ -61,6 +59,12 @@ allow the Bot API server to serve local requests

Use the `TELEGRAM_HTTP_IP_ADDRESS: "[::]"` parameter to listen on the ipv6 intranet

### `TELEGRAM_HTTP_PORT`

Set which port the api server should listen to if you want to run the image in network mode as host and want to change the port.

If not set then the api server will listen to port 8081.

## Start with persistent storage

Server working directory is `/var/lib/telegram-bot-api` so if you want to persist the server data you can mount this folder as volume:
Expand Down
9 changes: 8 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ -n "${1}" ]; then
exec "${*}"
fi

DEFAULT_ARGS="--http-port 8081 --dir=${TELEGRAM_WORK_DIR} --temp-dir=${TELEGRAM_TEMP_DIR} --username=${USERNAME} --groupname=${GROUPNAME}"
DEFAULT_ARGS="--dir=${TELEGRAM_WORK_DIR} --temp-dir=${TELEGRAM_TEMP_DIR} --username=${USERNAME} --groupname=${GROUPNAME}"
CUSTOM_ARGS=""

if [ -n "$TELEGRAM_LOG_FILE" ]; then
Expand Down Expand Up @@ -41,6 +41,13 @@ if [ -n "$TELEGRAM_HTTP_IP_ADDRESS" ]; then
CUSTOM_ARGS="${CUSTOM_ARGS} --http-ip-address=$TELEGRAM_HTTP_IP_ADDRESS"
fi

# Set http-port arg
if [ -n "$TELEGRAM_HTTP_PORT" ]; then
CUSTOM_ARGS="${CUSTOM_ARGS} --http-port=$TELEGRAM_HTTP_PORT"
else
CUSTOM_ARGS="${CUSTOM_ARGS} --http-port=8081"
fi

COMMAND="telegram-bot-api ${DEFAULT_ARGS}${CUSTOM_ARGS}"

echo "$COMMAND"
Expand Down

0 comments on commit a405943

Please sign in to comment.