Skip to content

Commit

Permalink
Fix single user mode in groups
Browse files Browse the repository at this point in the history
Closes: #124
  • Loading branch information
iovxw committed Sep 6, 2020
1 parent a0b488d commit 7be57bc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ mod opml;
pub async fn check_command(owner: Option<i64>, cmd: Arc<Command<Text>>) -> bool {
use tbot::contexts::fields::Message;
let target = &mut MsgTarget::new(cmd.chat.id, cmd.message_id);
if matches!(owner, Some(owner) if owner != cmd.chat().id.0) {
let from = cmd
.from()
.map(|user| user.id.0)
.unwrap_or_else(|| cmd.chat.id.0);
if matches!(owner, Some(owner) if owner != from) {
eprintln!(
"Unauthenticated request from user: {}, command: {}, args: {}",
cmd.chat.id, cmd.command, cmd.text.value
"Unauthenticated request from user/channel: {}, command: {}, args: {}",
from, cmd.command, cmd.text.value
);
return false;
}
Expand Down

0 comments on commit 7be57bc

Please sign in to comment.