diff --git a/.github/message-accept.svg b/.github/message-accept.svg new file mode 100644 index 0000000..be7b281 --- /dev/null +++ b/.github/message-accept.svg @@ -0,0 +1 @@ +
Yes
Yes
No
Yes
No
No
Incoming message
chat_id blacklisted?
Discard message
chat_id whitelisted?
Accept message
whitelist empty?
\ No newline at end of file diff --git a/README.md b/README.md index fae8a0d..a6fcf2d 100644 --- a/README.md +++ b/README.md @@ -117,14 +117,19 @@ For self-signed certificates, you'll need to pass your public key to Telegram's * `-certPath` (`string`) – Path of your SSL certificate when using webhook mode with `useHttp`. Default to none. * `-keyPath` (`string`) – Path of your private SSL key when using webhook mode with `useHttp`. Default to none. * `-dataDir` (`string`) – File system location where to store persistent data. Defaults to `.`. -* `-blacklist` (`string`) – Path to a user id blacklist file (send `/help` to get your id). Defaults to `blacklist.txt`. -* `-whitelist` (`string`) – Path to a user id whitelist file (send `/help` to get your id). Defaults to `whitelist.txt`. +* `-blacklist` (`string`) – Path to a line-separated blacklist file containing user IDs (send `/help` to get your id). Defaults to `blacklist.txt`. +* `-whitelist` (`string`) – Path to a line-separated whitelist file containing user IDs (send `/help` to get your id). Defaults to `whitelist.txt`. * `-rateLimit` (`int`) – Maximum number of messages to be delivered to each recipient per hour. Defaults to `100`. * `-metrics` (`bool`) – Whether to expose [Prometheus](https://prometheus.io) metrics under `/metrics`. Defaults to `false`. When using the Docker image, you can alternatively set most of the above config options via **environment variables** (passed to `docker run` using `-e`), e.g. `APP_USE_HTTPS=true`, `APP_CERT_PATH=/etc/telepush.crt`, etc. For details, see [`entrypoint.sh`](docker/entrypoint.sh). +### Whitelist vs. Blacklist +(aka. allow-list vs. block-list) + + + ## 📥 Inlets Inlets provide a mechanism to pre-process incoming data that comes in a format different from what is normally expected diff --git a/api/api.go b/api/api.go index 5f52123..cfd24c2 100644 --- a/api/api.go +++ b/api/api.go @@ -169,7 +169,7 @@ func processUpdate(update model.TelegramUpdate) { } if !checkWhitelist(chatId) { - log.Printf("update not from whitelisted chat id '%d'\n", chatId) + log.Printf("got update not from whitelisted chat id '%d'\n", chatId) return } diff --git a/config/config.go b/config/config.go index 47c2492..6982c03 100644 --- a/config/config.go +++ b/config/config.go @@ -18,7 +18,7 @@ const ( BaseURL = "https://api.telegram.org/bot" StoreFile = "store.gob" PollTimeoutSec = 60 - UserIdRegex = "(?m)^\\d+$" + UserIdRegex = "(?m)^-?\\d+$" ) const (