6 Commits

Author SHA1 Message Date
5178b0066b patch bump 2026-03-25 07:20:16 +00:00
68926fa67b add command timings 2026-03-25 07:20:02 +00:00
d273ca57ca add pre-commit config 2026-03-21 14:18:21 +00:00
ce660fb6c8 add Use section 2026-03-20 09:58:31 +00:00
514dda463a closes #1 2026-02-26 20:29:50 +00:00
cac241a910 remove new_port validation, leave it to pydantic
patch bump
2026-02-25 23:47:05 +00:00
6 changed files with 44 additions and 13 deletions

View File

@@ -30,7 +30,7 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install "virtualenv<21" hatch pip install hatch
- name: Build package - name: Build package
run: hatch build run: hatch build

7
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

View File

@@ -66,6 +66,12 @@ Q3RCON_TUI_RAW=false
Q3RCON_TUI_APPEND=false Q3RCON_TUI_APPEND=false
``` ```
## Use
Type in your Rcon command and press ENTER.
Press `Ctrl+q` to exit from the application.
## Special Thanks ## Special Thanks
- [lapetus-11](https://github.com/Iapetus-11) for writing the [aio-q3-rcon](https://github.com/Iapetus-11/aio-q3-rcon) package. - [lapetus-11](https://github.com/Iapetus-11) for writing the [aio-q3-rcon](https://github.com/Iapetus-11/aio-q3-rcon) package.

View File

@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2026-present onyx-and-iris <code@onyxandiris.online> # SPDX-FileCopyrightText: 2026-present onyx-and-iris <code@onyxandiris.online>
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
__version__ = '0.7.0' __version__ = '0.7.2'

View File

@@ -1,3 +1,5 @@
from typing import Literal
from pydantic import ValidationError from pydantic import ValidationError
from textual.app import ComposeResult from textual.app import ComposeResult
from textual.containers import Horizontal, Vertical from textual.containers import Horizontal, Vertical
@@ -51,15 +53,13 @@ class ConfigScreen(ModalScreen[bool]):
self._clear_field_errors() self._clear_field_errors()
try: try:
new_host = self.query_one('#host-input', Input).value.strip() or 'localhost' new_host: str = (
new_port = self.query_one('#port-input', Input).value self.query_one('#host-input', Input).value.strip() or 'localhost'
new_password = self.query_one('#password-input', Input).value )
new_port: int | Literal[28960] = (
try: self.query_one('#port-input', Input).value or 28960
new_port = int(new_port or '28960') )
except ValueError: new_password: str = self.query_one('#password-input', Input).value
self._show_field_error('port-input', 'Port must be a valid number')
return
self._settings.host = new_host self._settings.host = new_host
self._settings.port = new_port self._settings.port = new_port

View File

@@ -10,6 +10,15 @@ from .writable import Writable
class Q3RconTUI(App): class Q3RconTUI(App):
CSS_PATH = 'q3rcon_tui.tcss' CSS_PATH = 'q3rcon_tui.tcss'
CMD_CONFIG = {
'status': (2, 0.25, False),
'fast_restart': (3, 1, True),
'map_restart': (3, 1, True),
'map': (3, 1, True),
'map_rotate': (3, 1, True),
}
DEFAULT_TIMEOUT = 2
DEFAULT_FRAGMENT_READ_TIMEOUT = 0.25
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@@ -65,11 +74,20 @@ class Q3RconTUI(App):
self.app.bell() self.app.bell()
return return
timeout, fragment_read_timeout, interpret = Q3RconTUI.CMD_CONFIG.get(
cmd.split()[0].lower(),
(Q3RconTUI.DEFAULT_TIMEOUT, Q3RconTUI.DEFAULT_FRAGMENT_READ_TIMEOUT, False),
)
try: try:
async with Client( async with Client(
self._settings.host, self._settings.port, self._settings.password self._settings.host,
self._settings.port,
self._settings.password,
timeout=timeout,
fragment_read_timeout=fragment_read_timeout,
) as client: ) as client:
response = await client.send_command(cmd) response = await client.send_command(cmd, interpret=interpret)
self.query_one('#response', RichLog).write( self.query_one('#response', RichLog).write(
self.writable.parse(cmd, response) self.writable.parse(cmd, response)
) )