Skip to content

Commit

Permalink
Return temp_ban and result as a bool and not str and add type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
cemathey committed May 28, 2024
1 parent 847decc commit edd4090
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
21 changes: 12 additions & 9 deletions rcon/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,16 +633,19 @@ def kick(self, player_name: str, reason: str) -> bool:
@_escape_params
def temp_ban(
self,
player_name=None,
player_id=None,
duration_hours=2,
reason="",
admin_name="",
) -> str:
player_name: str | None = None,
player_id: str | None = None,
duration_hours: int = 2,
reason: str = "",
admin_name: str = "",
) -> bool:
reason = convert_tabs_to_spaces(reason)
return self._str_request(
f'tempban "{player_id or player_name}" {duration_hours} "{reason}" "{admin_name}"',
log_info=True,
return (
self._str_request(
f'tempban "{player_id or player_name}" {duration_hours} "{reason}" "{admin_name}"',
log_info=True,
)
== SUCCESS
)

@_escape_params
Expand Down
9 changes: 7 additions & 2 deletions rcon/rcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,8 +1149,13 @@ def kick(self, player_name, reason, by, player_id: str | None = None) -> bool:
return res

def temp_ban(
self, player_name=None, player_id=None, duration_hours=2, reason="", by=""
) -> str:
self,
player_name: str | None = None,
player_id: str | None = None,
duration_hours: int = 2,
reason: str = "",
by: str = "",
) -> bool:
with invalidates(Rcon.get_players, Rcon.get_temp_bans):
if player_name and re.match(r"\d+", player_name):
info = self.get_player_info(player_name)
Expand Down

0 comments on commit edd4090

Please sign in to comment.