Skip to content

Commit

Permalink
Merge pull request #674 from AndrzejkaNowicki/ban_unban_member
Browse files Browse the repository at this point in the history
add only_if_banned flag to banMemer
  • Loading branch information
fabio-ivona authored Dec 2, 2024
2 parents 8fb147c + 55126f3 commit 7b9a9ab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/14.models/2.telegraph-chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ use DefStudio\Telegraph\Models\TelegraphChat;

/** @var TelegraphChat $telegraphChat */

$telegraphChat->unbanMember($userId)->send();
$telegraphChat->unbanMember($userId, true)->send();
```

## `restrictMember()`
Expand Down
4 changes: 2 additions & 2 deletions src/Concerns/HasBotsAndChats.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,14 @@ public function andRevokeMessages(): Telegraph
return $telegraph;
}

public function unbanChatMember(string $userId): Telegraph
public function unbanChatMember(string $userId, bool $onlyIfBanned = true): Telegraph
{
$telegraph = clone $this;

$telegraph->endpoint = self::ENDPOINT_UNBAN_CHAT_MEMBER;
$telegraph->data['chat_id'] = $telegraph->getChatId();
$telegraph->data['user_id'] = $userId;
$telegraph->data['only_if_banned'] = true;
$telegraph->data['only_if_banned'] = $onlyIfBanned;

return $telegraph;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Models/TelegraphChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ public function banMember(string $userId): Telegraph
return TelegraphFacade::chat($this)->banChatMember($userId);
}

public function unbanMember(string $userId): Telegraph
public function unbanMember(string $userId, bool $onlyIfBanned = true): Telegraph
{
return TelegraphFacade::chat($this)->unbanChatMember($userId);
return TelegraphFacade::chat($this)->unbanChatMember($userId, $onlyIfBanned);
}

/**
Expand Down

0 comments on commit 7b9a9ab

Please sign in to comment.