Skip to content

Commit

Permalink
fix: support negative user ids in black- and whitelist (resolve #46)
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Oct 19, 2022
1 parent b7e682d commit 56cc059
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/message-accept.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<img src=".github/message-accept.svg" width="600px">

## 📥 Inlets

Inlets provide a mechanism to pre-process incoming data that comes in a format different from what is normally expected
Expand Down
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
BaseURL = "https://api.telegram.org/bot"
StoreFile = "store.gob"
PollTimeoutSec = 60
UserIdRegex = "(?m)^\\d+$"
UserIdRegex = "(?m)^-?\\d+$"
)

const (
Expand Down

0 comments on commit 56cc059

Please sign in to comment.