Skip to content

Commit

Permalink
if OWNER_TELEGRAM_ID is set, process commands only from this user
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrat555 committed Dec 31, 2021
1 parent 77c31b5 commit 8bd0253
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ All configuration is done through env variables
| DELIVER_WORKERS_NUMBER | no | 1 | The number of workers to deliver updates |
| CLEAN_INTERVAL_SECONDS | no | 3600 | The bot cleans old feed items and feeds without subscriptions every `CLEAN_INTERVAL_SECONDS` seconds |
| CLEAN_WORKERS_NUMBER | no | 1 | The number of workers to remove old data |
| OWNER_TELEGRAM_ID | no | -- | If this value is set, the bot will process commands from the specified chat id |
| OWNER_TELEGRAM_ID | no | -- | If this value is set, the bot will process commands only from the specified user id |
| REQUEST_TIMEOUT | no | 5 | Timeout in seconds for feed syncing requests |
| ADMIN_TELEGRAM_ID | no | -- | If this value is set, `/info` command with stats is available for ADMIN_TELEGRAM_ID |

Expand Down
8 changes: 5 additions & 3 deletions src/bot/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ impl Handler {
Some(message) => message,
};

let chat_id = message.chat.id as i64;
if let Some(owner_id) = Self::owner_telegram_id() {
if message.from.is_none() {
return;
}

if let Some(id) = Self::owner_telegram_id() {
if id != chat_id {
if message.from.as_ref().unwrap().id as i64 != owner_id {
return;
}
}
Expand Down

0 comments on commit 8bd0253

Please sign in to comment.