lapctl 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lapctl-0.1.1/src/lapctl.egg-info → lapctl-0.1.2}/PKG-INFO +13 -7
- {lapctl-0.1.1 → lapctl-0.1.2}/README.md +11 -5
- {lapctl-0.1.1 → lapctl-0.1.2}/pyproject.toml +2 -2
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/__init__.py +1 -1
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/channels/telegram/handlers.py +4 -1
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/channels/telegram/poller.py +3 -1
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/cli.py +61 -16
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/core/commands.py +6 -4
- lapctl-0.1.2/src/lapctl/core/keyboards.py +226 -0
- lapctl-0.1.2/src/lapctl/drivers/__init__.py +14 -0
- lapctl-0.1.2/src/lapctl/drivers/windows.py +433 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/main.py +2 -2
- {lapctl-0.1.1 → lapctl-0.1.2/src/lapctl.egg-info}/PKG-INFO +13 -7
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl.egg-info/SOURCES.txt +3 -1
- {lapctl-0.1.1 → lapctl-0.1.2}/tests/test_cli.py +29 -1
- {lapctl-0.1.1 → lapctl-0.1.2}/tests/test_registry_and_profiles.py +15 -1
- {lapctl-0.1.1 → lapctl-0.1.2}/tests/test_render_and_driver.py +36 -0
- lapctl-0.1.2/tests/test_windows_driver.py +65 -0
- lapctl-0.1.1/src/lapctl/core/keyboards.py +0 -140
- lapctl-0.1.1/src/lapctl/drivers/__init__.py +0 -1
- {lapctl-0.1.1 → lapctl-0.1.2}/LICENSE +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/setup.cfg +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/channels/__init__.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/channels/telegram/__init__.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/channels/telegram/api.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/channels/telegram/auth.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/channels/telegram/render.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/config.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/core/__init__.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/core/battery.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/core/confirm.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/core/paths.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/core/ratelimit.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/drivers/base.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/drivers/linux_hyprland.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/registry.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl/results.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl.egg-info/dependency_links.txt +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl.egg-info/entry_points.txt +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl.egg-info/requires.txt +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/src/lapctl.egg-info/top_level.txt +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/tests/test_auth_and_config.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/tests/test_confirm.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.2}/tests/test_paths.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lapctl
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Open-source laptop remote control agent via Telegram
|
|
5
|
-
License: MIT
|
|
5
|
+
License-Expression: MIT
|
|
6
6
|
Requires-Python: >=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
License-File: LICENSE
|
|
@@ -12,12 +12,16 @@ Requires-Dist: pytest>=8.0; extra == "dev"
|
|
|
12
12
|
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
13
13
|
Dynamic: license-file
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="docs/image.png" alt="Lapctl" width="640" />
|
|
17
|
+
</p>
|
|
16
18
|
|
|
17
19
|
Agent open source yang berjalan di laptop untuk mengendalikan laptop dari jarak jauh melalui Telegram (kunci layar, screenshot, kamera, kontrol media, cek status, file, dan kontrol daya) tanpa server tambahan dan tanpa membuka port jaringan masuk.
|
|
18
20
|
|
|
19
21
|
## Privasi dan Keamanan
|
|
20
22
|
|
|
23
|
+
- **100% Open Source ([Lisensi MIT](LICENSE)):** seluruh kode sumber terbuka dan dapat diperiksa/diaudit oleh siapa saja.
|
|
24
|
+
- **Berjalan di laptop lokal masing-masing:** agent ini berjalan langsung di laptop/PC milik kamu sendiri menggunakan bot Telegram milikmu sendiri, **bukan di server milik developer**. Developer tidak memiliki akses ke token, perintah, file, maupun laptop kamu.
|
|
21
25
|
- Pesan, screenshot, foto, dan file **melewati server Telegram**. Bot API tidak terenkripsi end-to-end. Pertimbangkan hal ini sebelum memakai fitur sensitif.
|
|
22
26
|
- Lapctl tidak memiliki server, akun, atau telemetri.
|
|
23
27
|
- Panggilan jaringan selain ke `api.telegram.org` hanya terjadi pada fitur eksternal yang diaktifkan sendiri oleh pengguna (TTS via Google Translate, geolokasi IP via `ip-api.com`, atau notifikasi `ntfy`).
|
|
@@ -26,7 +30,7 @@ Agent open source yang berjalan di laptop untuk mengendalikan laptop dari jarak
|
|
|
26
30
|
## Prasyarat
|
|
27
31
|
|
|
28
32
|
- **Python 3.11** atau lebih baru
|
|
29
|
-
- **OS:** Linux (
|
|
33
|
+
- **OS:** Linux (Wayland/Hyprland) dan **Windows 10/11** (driver X11 & macOS direncanakan berikutnya)
|
|
30
34
|
- **pipx** (tool untuk menginstal aplikasi CLI Python secara terisolasi tanpa mengganggu Python sistem)
|
|
31
35
|
|
|
32
36
|
### Cara Pasang `pipx`
|
|
@@ -58,10 +62,10 @@ python -m pipx ensurepath
|
|
|
58
62
|
|
|
59
63
|
## Cara Instalasi
|
|
60
64
|
|
|
61
|
-
### Opsi 1:
|
|
65
|
+
### Opsi 1: Via `pipx` (Direkomendasikan)
|
|
62
66
|
|
|
63
67
|
```bash
|
|
64
|
-
pipx install
|
|
68
|
+
pipx install lapctl
|
|
65
69
|
```
|
|
66
70
|
|
|
67
71
|
Untuk memperbarui ke versi terbaru nanti:
|
|
@@ -109,7 +113,7 @@ pip install .
|
|
|
109
113
|
| `lapctl stop` / `restart` | Hentikan atau mulai ulang service systemd user |
|
|
110
114
|
| `lapctl status` | Cek status service dan koneksi ke Telegram |
|
|
111
115
|
| `lapctl logs` | Lihat log terbaru dari service |
|
|
112
|
-
| `lapctl config` | Lihat atau ubah pengaturan (`--profile`, `--language`, `--device-name`, `--ntfy-topic`) |
|
|
116
|
+
| `lapctl config` | Lihat atau ubah pengaturan (`--change-token`, `--profile`, `--language`, `--device-name`, `--ntfy-topic`) |
|
|
113
117
|
| `lapctl uninstall` | Hapus service dan file konfigurasi |
|
|
114
118
|
| `lapctl --version` | Tampilkan versi |
|
|
115
119
|
|
|
@@ -123,6 +127,8 @@ pip install .
|
|
|
123
127
|
|
|
124
128
|
## Daftar Perintah Telegram
|
|
125
129
|
|
|
130
|
+
`/menu` menampilkan menu kategori ringkas dengan nama perangkat (`device_name`) dan otomatis menghapus pesan tombol sebelumnya saat berpindah kategori atau menekan tombol konfirmasi agar riwayat chat tetap bersih.
|
|
131
|
+
|
|
126
132
|
| Kategori | Perintah | Risiko | Profil minimum |
|
|
127
133
|
|---|---|---|---|
|
|
128
134
|
| Navigasi | `/start`, `/help`, `/menu` | R | aman |
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/image.png" alt="Lapctl" width="640" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
5
|
Agent open source yang berjalan di laptop untuk mengendalikan laptop dari jarak jauh melalui Telegram (kunci layar, screenshot, kamera, kontrol media, cek status, file, dan kontrol daya) tanpa server tambahan dan tanpa membuka port jaringan masuk.
|
|
4
6
|
|
|
5
7
|
## Privasi dan Keamanan
|
|
6
8
|
|
|
9
|
+
- **100% Open Source ([Lisensi MIT](LICENSE)):** seluruh kode sumber terbuka dan dapat diperiksa/diaudit oleh siapa saja.
|
|
10
|
+
- **Berjalan di laptop lokal masing-masing:** agent ini berjalan langsung di laptop/PC milik kamu sendiri menggunakan bot Telegram milikmu sendiri, **bukan di server milik developer**. Developer tidak memiliki akses ke token, perintah, file, maupun laptop kamu.
|
|
7
11
|
- Pesan, screenshot, foto, dan file **melewati server Telegram**. Bot API tidak terenkripsi end-to-end. Pertimbangkan hal ini sebelum memakai fitur sensitif.
|
|
8
12
|
- Lapctl tidak memiliki server, akun, atau telemetri.
|
|
9
13
|
- Panggilan jaringan selain ke `api.telegram.org` hanya terjadi pada fitur eksternal yang diaktifkan sendiri oleh pengguna (TTS via Google Translate, geolokasi IP via `ip-api.com`, atau notifikasi `ntfy`).
|
|
@@ -12,7 +16,7 @@ Agent open source yang berjalan di laptop untuk mengendalikan laptop dari jarak
|
|
|
12
16
|
## Prasyarat
|
|
13
17
|
|
|
14
18
|
- **Python 3.11** atau lebih baru
|
|
15
|
-
- **OS:** Linux (
|
|
19
|
+
- **OS:** Linux (Wayland/Hyprland) dan **Windows 10/11** (driver X11 & macOS direncanakan berikutnya)
|
|
16
20
|
- **pipx** (tool untuk menginstal aplikasi CLI Python secara terisolasi tanpa mengganggu Python sistem)
|
|
17
21
|
|
|
18
22
|
### Cara Pasang `pipx`
|
|
@@ -44,10 +48,10 @@ python -m pipx ensurepath
|
|
|
44
48
|
|
|
45
49
|
## Cara Instalasi
|
|
46
50
|
|
|
47
|
-
### Opsi 1:
|
|
51
|
+
### Opsi 1: Via `pipx` (Direkomendasikan)
|
|
48
52
|
|
|
49
53
|
```bash
|
|
50
|
-
pipx install
|
|
54
|
+
pipx install lapctl
|
|
51
55
|
```
|
|
52
56
|
|
|
53
57
|
Untuk memperbarui ke versi terbaru nanti:
|
|
@@ -95,7 +99,7 @@ pip install .
|
|
|
95
99
|
| `lapctl stop` / `restart` | Hentikan atau mulai ulang service systemd user |
|
|
96
100
|
| `lapctl status` | Cek status service dan koneksi ke Telegram |
|
|
97
101
|
| `lapctl logs` | Lihat log terbaru dari service |
|
|
98
|
-
| `lapctl config` | Lihat atau ubah pengaturan (`--profile`, `--language`, `--device-name`, `--ntfy-topic`) |
|
|
102
|
+
| `lapctl config` | Lihat atau ubah pengaturan (`--change-token`, `--profile`, `--language`, `--device-name`, `--ntfy-topic`) |
|
|
99
103
|
| `lapctl uninstall` | Hapus service dan file konfigurasi |
|
|
100
104
|
| `lapctl --version` | Tampilkan versi |
|
|
101
105
|
|
|
@@ -109,6 +113,8 @@ pip install .
|
|
|
109
113
|
|
|
110
114
|
## Daftar Perintah Telegram
|
|
111
115
|
|
|
116
|
+
`/menu` menampilkan menu kategori ringkas dengan nama perangkat (`device_name`) dan otomatis menghapus pesan tombol sebelumnya saat berpindah kategori atau menekan tombol konfirmasi agar riwayat chat tetap bersih.
|
|
117
|
+
|
|
112
118
|
| Kategori | Perintah | Risiko | Profil minimum |
|
|
113
119
|
|---|---|---|---|
|
|
114
120
|
| Navigasi | `/start`, `/help`, `/menu` | R | aman |
|
|
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "lapctl"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "Open-source laptop remote control agent via Telegram"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
license =
|
|
10
|
+
license = "MIT"
|
|
11
11
|
requires-python = ">=3.11"
|
|
12
12
|
dependencies = [
|
|
13
13
|
"requests>=2.31",
|
|
@@ -156,6 +156,9 @@ class TelegramHandlers:
|
|
|
156
156
|
cb_data: str,
|
|
157
157
|
username: str,
|
|
158
158
|
owner_id: int = 0,
|
|
159
|
+
message_id: int | None = None,
|
|
159
160
|
) -> None:
|
|
160
|
-
"""
|
|
161
|
+
"""Delete previous inline message (unless no-op) and dispatch callback."""
|
|
162
|
+
if message_id is not None and cb_data.strip().lower() != "/none":
|
|
163
|
+
self.client.delete_message(chat_id, message_id)
|
|
161
164
|
self._run_and_render(chat_id, cb_data, owner_id=owner_id)
|
|
@@ -24,7 +24,7 @@ class TelegramPoller:
|
|
|
24
24
|
on_text: Callable[[int | str, str, int | None, str, int], None],
|
|
25
25
|
on_document: Callable[[int | str, str, str, str, int], None],
|
|
26
26
|
on_photo: Callable[[int | str, str, str, str, int], None],
|
|
27
|
-
on_callback: Callable[[int | str, str, str, int], None],
|
|
27
|
+
on_callback: Callable[[int | str, str, str, int, int | None], None],
|
|
28
28
|
on_before_update: Callable[[], None] | None = None,
|
|
29
29
|
max_workers: int = 4,
|
|
30
30
|
) -> None:
|
|
@@ -108,6 +108,7 @@ class TelegramPoller:
|
|
|
108
108
|
|
|
109
109
|
self.client.answer_callback_query(cb["id"])
|
|
110
110
|
username = cb.get("from", {}).get("username", "Unknown")
|
|
111
|
+
message_id = msg.get("message_id")
|
|
111
112
|
self._dispatch(
|
|
112
113
|
async_dispatch,
|
|
113
114
|
self.on_callback,
|
|
@@ -115,6 +116,7 @@ class TelegramPoller:
|
|
|
115
116
|
cb_data,
|
|
116
117
|
username,
|
|
117
118
|
sender_id,
|
|
119
|
+
message_id,
|
|
118
120
|
)
|
|
119
121
|
|
|
120
122
|
def _dispatch(self, async_dispatch: bool, fn: Callable[..., None], *args: Any) -> None:
|
|
@@ -25,15 +25,19 @@ from lapctl.config import (
|
|
|
25
25
|
get_owner_id,
|
|
26
26
|
write_toml_config,
|
|
27
27
|
)
|
|
28
|
+
from lapctl.drivers import get_active_driver
|
|
28
29
|
from lapctl.drivers.linux_hyprland import LinuxHyprlandDriver
|
|
30
|
+
from lapctl.drivers.windows import WindowsDriver
|
|
29
31
|
from lapctl.main import main as run_agent
|
|
30
32
|
|
|
31
33
|
SERVICE_NAME = "lapctl.service"
|
|
32
34
|
|
|
33
35
|
BANNER_PARTS: list[tuple[str, str]] = [
|
|
34
|
-
("
|
|
35
|
-
("
|
|
36
|
-
("
|
|
36
|
+
("░██░░░░░░█████░░██████░░", "░██████░██████░██░░░░░"),
|
|
37
|
+
("░██░░░░░██░░░██░██░░░██░", "██░░░░░░░░██░░░██░░░░░"),
|
|
38
|
+
("░██░░░░░███████░██████░░", "██░░░░░░░░██░░░██░░░░░"),
|
|
39
|
+
("░██░░░░░██░░░██░██░░░░░░", "██░░░░░░░░██░░░██░░░░░"),
|
|
40
|
+
("░██████░██░░░██░██░░░░░░", "░██████░░░██░░░██████░"),
|
|
37
41
|
]
|
|
38
42
|
|
|
39
43
|
|
|
@@ -168,8 +172,21 @@ def _wait_for_owner_message(
|
|
|
168
172
|
return None
|
|
169
173
|
|
|
170
174
|
|
|
171
|
-
def
|
|
172
|
-
"""Create and enable
|
|
175
|
+
def _install_autostart() -> bool:
|
|
176
|
+
"""Create and enable OS-appropriate auto-start service."""
|
|
177
|
+
if WindowsDriver.detect() and shutil.which("schtasks") is not None:
|
|
178
|
+
exe = shutil.which("lapctl") or f'"{sys.executable}" -m lapctl.cli'
|
|
179
|
+
tr = f'"{exe}" start' if " " not in exe else f"{exe} start"
|
|
180
|
+
try:
|
|
181
|
+
subprocess.run(
|
|
182
|
+
["schtasks", "/Create", "/TN", "Lapctl", "/TR", tr, "/SC", "ONLOGON", "/F"],
|
|
183
|
+
check=True,
|
|
184
|
+
timeout=10,
|
|
185
|
+
)
|
|
186
|
+
return True
|
|
187
|
+
except Exception:
|
|
188
|
+
return False
|
|
189
|
+
|
|
173
190
|
if not sys.platform.startswith("linux") or shutil.which("systemctl") is None:
|
|
174
191
|
return False
|
|
175
192
|
|
|
@@ -207,10 +224,9 @@ def cmd_setup() -> int:
|
|
|
207
224
|
"""Interactive setup wizard for first-time configuration."""
|
|
208
225
|
print_banner()
|
|
209
226
|
print(f"Python: {sys.version.split()[0]} | Platform: {sys.platform}")
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
)
|
|
227
|
+
driver = get_active_driver()
|
|
228
|
+
detected = driver.name if driver.detect() else "belum terdeteksi (mode generik)"
|
|
229
|
+
print(f"Driver terdeteksi: {detected}")
|
|
214
230
|
|
|
215
231
|
cfg_path = default_config_path()
|
|
216
232
|
if cfg_path.exists():
|
|
@@ -300,12 +316,12 @@ def cmd_setup() -> int:
|
|
|
300
316
|
write_toml_config(cfg_path, data)
|
|
301
317
|
print(f"\n✅ Konfigurasi disimpan ke {cfg_path} (izin owner-only).")
|
|
302
318
|
|
|
303
|
-
install_svc = input("Pasang auto-start
|
|
319
|
+
install_svc = input("Pasang auto-start otomatis saat login? [Y/n]: ").strip().lower()
|
|
304
320
|
if install_svc not in {"n", "no", "tidak"}:
|
|
305
|
-
if
|
|
306
|
-
print(
|
|
321
|
+
if _install_autostart():
|
|
322
|
+
print("✅ Auto-start berhasil dipasang.")
|
|
307
323
|
else:
|
|
308
|
-
print("⚠️ Gagal memasang
|
|
324
|
+
print("⚠️ Gagal memasang auto-start otomatis. Jalankan manual dengan: lapctl start")
|
|
309
325
|
|
|
310
326
|
client.send_message(owner_id, "Terhubung ✅")
|
|
311
327
|
print("\nSetup selesai! Kirim /menu ke bot Anda di Telegram.")
|
|
@@ -319,13 +335,23 @@ def cmd_doctor() -> int:
|
|
|
319
335
|
f"Python: {sys.version.split()[0]} ({'OK' if sys.version_info >= (3, 11) else 'Perlu >= 3.11'})"
|
|
320
336
|
)
|
|
321
337
|
print(f"Platform: {sys.platform}")
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
338
|
+
if WindowsDriver.detect():
|
|
339
|
+
print("Driver aktif: windows (menggunakan PowerShell/.NET bawaan)")
|
|
340
|
+
else:
|
|
341
|
+
print(
|
|
342
|
+
f"Driver linux_hyprland: {'terdeteksi' if LinuxHyprlandDriver.detect() else 'tidak terdeteksi'}"
|
|
343
|
+
)
|
|
325
344
|
cfg_path = default_config_path()
|
|
326
345
|
print(
|
|
327
346
|
f"Konfigurasi ({cfg_path}): {'ada' if cfg_path.exists() else 'belum ada (jalankan lapctl setup)'}"
|
|
328
347
|
)
|
|
348
|
+
if WindowsDriver.detect():
|
|
349
|
+
has_ffmpeg = shutil.which("ffmpeg") is not None
|
|
350
|
+
has_mpv = shutil.which("mpv") is not None
|
|
351
|
+
print("\nPemeriksaan alat opsional Windows:")
|
|
352
|
+
print(f" - ffmpeg [{'OK' if has_ffmpeg else 'TIDAK ADA'}] Rekam layar (/screenrecord)")
|
|
353
|
+
print(f" - mpv [{'OK' if has_mpv else 'TIDAK ADA'}] TTS (/say)")
|
|
354
|
+
return 0
|
|
329
355
|
print("\nPemeriksaan dependensi alat:")
|
|
330
356
|
|
|
331
357
|
missing = 0
|
|
@@ -408,6 +434,24 @@ def cmd_config(args: argparse.Namespace) -> int:
|
|
|
408
434
|
cfg = tomllib.load(f)
|
|
409
435
|
|
|
410
436
|
changed = False
|
|
437
|
+
if getattr(args, "change_token", False):
|
|
438
|
+
try:
|
|
439
|
+
new_token = getpass.getpass("Masukkan Bot Token baru (input disembunyikan): ").strip()
|
|
440
|
+
except (KeyboardInterrupt, EOFError):
|
|
441
|
+
print("\nDibatalkan.")
|
|
442
|
+
return 1
|
|
443
|
+
if not new_token:
|
|
444
|
+
print("❌ Token tidak boleh kosong.")
|
|
445
|
+
return 1
|
|
446
|
+
client = TelegramClient(new_token)
|
|
447
|
+
info = client.get_me()
|
|
448
|
+
if not info:
|
|
449
|
+
print("❌ Token baru tidak valid atau gagal menghubungi api.telegram.org.")
|
|
450
|
+
return 1
|
|
451
|
+
client.delete_webhook(drop_pending_updates=False)
|
|
452
|
+
cfg.setdefault("telegram", {})["bot_token"] = new_token
|
|
453
|
+
changed = True
|
|
454
|
+
print(f"✅ Token terhubung ke bot @{info.get('username', 'unknown')}.")
|
|
411
455
|
if args.profile:
|
|
412
456
|
cfg.setdefault("general", {})["profile"] = args.profile
|
|
413
457
|
changed = True
|
|
@@ -481,6 +525,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
481
525
|
sub.add_parser("doctor", help="Cek dependensi dan kemampuan driver")
|
|
482
526
|
|
|
483
527
|
cfg_p = sub.add_parser("config", help="Lihat atau ubah pengaturan")
|
|
528
|
+
cfg_p.add_argument("--change-token", action="store_true", help="Ganti Bot Token Telegram")
|
|
484
529
|
cfg_p.add_argument("--profile", choices=["aman", "standar", "lengkap"])
|
|
485
530
|
cfg_p.add_argument("--language", choices=["id", "en"])
|
|
486
531
|
cfg_p.add_argument("--device-name")
|
|
@@ -13,7 +13,7 @@ import requests
|
|
|
13
13
|
|
|
14
14
|
from lapctl.core.confirm import ConfirmationManager
|
|
15
15
|
from lapctl.core.keyboards import (
|
|
16
|
-
|
|
16
|
+
get_menu_content,
|
|
17
17
|
get_start_buttons,
|
|
18
18
|
get_status_buttons,
|
|
19
19
|
)
|
|
@@ -275,10 +275,12 @@ def _cmd_status(ctx: CommandContext) -> CommandOutput:
|
|
|
275
275
|
|
|
276
276
|
|
|
277
277
|
def _cmd_menu(ctx: CommandContext) -> CommandOutput:
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
header, rows = get_menu_content(
|
|
279
|
+
registry=ctx.registry,
|
|
280
|
+
config=ctx.config,
|
|
281
|
+
section=ctx.args,
|
|
281
282
|
)
|
|
283
|
+
return Buttons(text=header, rows=rows)
|
|
282
284
|
|
|
283
285
|
|
|
284
286
|
def _cmd_none(ctx: CommandContext) -> CommandOutput:
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"""Button layout definitions returning Result Button grids."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
|
+
|
|
7
|
+
from lapctl.results import Button
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from lapctl.registry import CommandRegistry
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_start_buttons() -> list[list[Button]]:
|
|
14
|
+
"""Return inline button rows for /start and /help."""
|
|
15
|
+
return [
|
|
16
|
+
[Button(text="🤖 Buka Menu Kontrol", callback_data="/menu")],
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_status_buttons() -> list[list[Button]]:
|
|
21
|
+
"""Return balanced inline button rows attached to /status output."""
|
|
22
|
+
return [
|
|
23
|
+
[
|
|
24
|
+
Button(text="📸 Screenshot", callback_data="/ss"),
|
|
25
|
+
Button(text="📷 Camera", callback_data="/cam"),
|
|
26
|
+
],
|
|
27
|
+
[
|
|
28
|
+
Button(text="🔇 Mute", callback_data="/mute"),
|
|
29
|
+
Button(text="🔒 Lock", callback_data="/lock"),
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
Button(text="🔄 Refresh", callback_data="/status"),
|
|
33
|
+
Button(text="🏠 Menu", callback_data="/menu"),
|
|
34
|
+
],
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _filter_rows(
|
|
39
|
+
rows: list[list[Button]],
|
|
40
|
+
registry: CommandRegistry | None,
|
|
41
|
+
config: dict[str, Any] | None,
|
|
42
|
+
) -> list[list[Button]]:
|
|
43
|
+
if registry is None or config is None:
|
|
44
|
+
return rows
|
|
45
|
+
filtered: list[list[Button]] = []
|
|
46
|
+
for row in rows:
|
|
47
|
+
kept: list[Button] = []
|
|
48
|
+
for btn in row:
|
|
49
|
+
if btn.callback_data is None or btn.callback_data.startswith("/menu"):
|
|
50
|
+
kept.append(btn)
|
|
51
|
+
continue
|
|
52
|
+
cmd = registry.resolve(btn.callback_data.split(maxsplit=1)[0])
|
|
53
|
+
if cmd is not None and registry.is_allowed(cmd, config):
|
|
54
|
+
kept.append(btn)
|
|
55
|
+
if kept:
|
|
56
|
+
filtered.append(kept)
|
|
57
|
+
return filtered
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
_MENU_SECTIONS: dict[str, tuple[str, list[list[Button]]]] = {
|
|
61
|
+
"sistem": (
|
|
62
|
+
"🖥 *Sistem & Jaringan*",
|
|
63
|
+
[
|
|
64
|
+
[
|
|
65
|
+
Button(text="📊 Status", callback_data="/status"),
|
|
66
|
+
Button(text="🩺 Health", callback_data="/health"),
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
Button(text="⚙️ Proses", callback_data="/ps"),
|
|
70
|
+
Button(text="📜 Logs", callback_data="/logs"),
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
Button(text="📡 Network", callback_data="/network"),
|
|
74
|
+
Button(text="🌍 Public IP", callback_data="/ip"),
|
|
75
|
+
],
|
|
76
|
+
[Button(text="📍 Lokasi", callback_data="/location")],
|
|
77
|
+
],
|
|
78
|
+
),
|
|
79
|
+
"media": (
|
|
80
|
+
"🔊 *Audio & Media*",
|
|
81
|
+
[
|
|
82
|
+
[
|
|
83
|
+
Button(text="🔊 Volume", callback_data="/volume"),
|
|
84
|
+
Button(text="🔇 Mute", callback_data="/mute"),
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
Button(text="⏮️ Prev", callback_data="/prev"),
|
|
88
|
+
Button(text="▶️ Play", callback_data="/play"),
|
|
89
|
+
Button(text="⏭️ Next", callback_data="/next"),
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
Button(text="⏸️ Pause", callback_data="/pause"),
|
|
93
|
+
Button(text="🔔 Beep", callback_data="/beep"),
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
Button(text="📺 YouTube", callback_data="/youtube"),
|
|
97
|
+
Button(text="🗣️ Say TTS", callback_data="/say"),
|
|
98
|
+
],
|
|
99
|
+
],
|
|
100
|
+
),
|
|
101
|
+
"capture": (
|
|
102
|
+
"📷 *Kamera & Layar*",
|
|
103
|
+
[
|
|
104
|
+
[
|
|
105
|
+
Button(text="📸 Screenshot", callback_data="/ss"),
|
|
106
|
+
Button(text="📷 Webcam", callback_data="/cam"),
|
|
107
|
+
],
|
|
108
|
+
[
|
|
109
|
+
Button(text="🎥 Video Cam", callback_data="/vid"),
|
|
110
|
+
Button(text="🎙️ Rekam Mic", callback_data="/record"),
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
Button(text="🖥 Screen Record", callback_data="/screenrecord"),
|
|
114
|
+
Button(text="💡 Kecerahan", callback_data="/brightness"),
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
Button(text="💬 Notifikasi", callback_data="/notify"),
|
|
118
|
+
Button(text="🖼️ Wallpaper", callback_data="/wallpaper"),
|
|
119
|
+
],
|
|
120
|
+
],
|
|
121
|
+
),
|
|
122
|
+
"files": (
|
|
123
|
+
"📁 *File & Clipboard*",
|
|
124
|
+
[
|
|
125
|
+
[
|
|
126
|
+
Button(text="📂 Browse", callback_data="/ls"),
|
|
127
|
+
Button(text="🔎 Cari File", callback_data="/find"),
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
Button(text="⬇️ Download", callback_data="/download"),
|
|
131
|
+
Button(text="📋 Clipboard", callback_data="/getclip"),
|
|
132
|
+
],
|
|
133
|
+
[Button(text="⬆️ Upload", callback_data="/upload")],
|
|
134
|
+
],
|
|
135
|
+
),
|
|
136
|
+
"power": (
|
|
137
|
+
"⚡ *Daya & Kunci*",
|
|
138
|
+
[
|
|
139
|
+
[
|
|
140
|
+
Button(text="🔒 Lock", callback_data="/lock"),
|
|
141
|
+
Button(text="💤 Suspend", callback_data="/suspend"),
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
Button(text="🔄 Reboot", callback_data="/reboot"),
|
|
145
|
+
Button(text="⏻ Shutdown", callback_data="/shutdown"),
|
|
146
|
+
],
|
|
147
|
+
[Button(text="📱 Cari HP", callback_data="/carihp")],
|
|
148
|
+
],
|
|
149
|
+
),
|
|
150
|
+
"input": (
|
|
151
|
+
"🐚 *Input & Shell*",
|
|
152
|
+
[
|
|
153
|
+
[
|
|
154
|
+
Button(text="🖱 Mouse", callback_data="/mouse"),
|
|
155
|
+
Button(text="⌨️ Keyboard", callback_data="/keyboard"),
|
|
156
|
+
],
|
|
157
|
+
[Button(text="🐚 Terminal (/cmd)", callback_data="/cmd")],
|
|
158
|
+
],
|
|
159
|
+
),
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def get_menu_content(
|
|
164
|
+
registry: CommandRegistry | None = None,
|
|
165
|
+
config: dict[str, Any] | None = None,
|
|
166
|
+
section: str = "",
|
|
167
|
+
) -> tuple[str, list[list[Button]]]:
|
|
168
|
+
"""Return (header_text, button_rows) for main menu or a specific category."""
|
|
169
|
+
general = (config or {}).get("general", {})
|
|
170
|
+
device_name = (
|
|
171
|
+
general.get("device_name", "My Laptop") if isinstance(general, dict) else "My Laptop"
|
|
172
|
+
)
|
|
173
|
+
profile = (
|
|
174
|
+
general.get("profile", (config or {}).get("profile", "standar"))
|
|
175
|
+
if isinstance(general, dict)
|
|
176
|
+
else "standar"
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
sec = section.strip().lower()
|
|
180
|
+
if sec in _MENU_SECTIONS:
|
|
181
|
+
sec_title, raw_rows = _MENU_SECTIONS[sec]
|
|
182
|
+
rows = _filter_rows(raw_rows, registry, config)
|
|
183
|
+
rows.append([Button(text="⬅️ Kembali ke Menu", callback_data="/menu")])
|
|
184
|
+
return f"🖥 *{device_name}* · {sec_title}", rows
|
|
185
|
+
|
|
186
|
+
quick_row = _filter_rows(
|
|
187
|
+
[
|
|
188
|
+
[
|
|
189
|
+
Button(text="📊 Status", callback_data="/status"),
|
|
190
|
+
Button(text="📸 Screenshot", callback_data="/ss"),
|
|
191
|
+
Button(text="🔒 Lock", callback_data="/lock"),
|
|
192
|
+
]
|
|
193
|
+
],
|
|
194
|
+
registry,
|
|
195
|
+
config,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
cat_rows: list[list[Button]] = [
|
|
199
|
+
[
|
|
200
|
+
Button(text="🖥 Sistem & Jaringan", callback_data="/menu sistem"),
|
|
201
|
+
Button(text="🔊 Audio & Media", callback_data="/menu media"),
|
|
202
|
+
],
|
|
203
|
+
]
|
|
204
|
+
if profile != "aman":
|
|
205
|
+
cat_rows.append(
|
|
206
|
+
[
|
|
207
|
+
Button(text="📷 Kamera & Layar", callback_data="/menu capture"),
|
|
208
|
+
Button(text="📁 File & Clipboard", callback_data="/menu files"),
|
|
209
|
+
]
|
|
210
|
+
)
|
|
211
|
+
power_row = [Button(text="⚡ Daya & Kunci", callback_data="/menu power")]
|
|
212
|
+
if profile == "lengkap":
|
|
213
|
+
power_row.append(Button(text="🐚 Input & Shell", callback_data="/menu input"))
|
|
214
|
+
cat_rows.append(power_row)
|
|
215
|
+
|
|
216
|
+
header = f"🖥 *{device_name}* · Profil: `{profile}`\n\nPilih aksi cepat atau kategori:"
|
|
217
|
+
return header, quick_row + cat_rows
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def get_menu_buttons(
|
|
221
|
+
registry: CommandRegistry | None = None,
|
|
222
|
+
config: dict[str, Any] | None = None,
|
|
223
|
+
) -> list[list[Button]]:
|
|
224
|
+
"""Return main control menu button rows."""
|
|
225
|
+
_, rows = get_menu_content(registry=registry, config=config)
|
|
226
|
+
return rows
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""OS/desktop environment drivers and auto-detection for Lapctl."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from lapctl.drivers.base import BaseDriver
|
|
6
|
+
from lapctl.drivers.linux_hyprland import LinuxHyprlandDriver
|
|
7
|
+
from lapctl.drivers.windows import WindowsDriver
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_active_driver() -> BaseDriver:
|
|
11
|
+
"""Detect and instantiate the matching OS driver."""
|
|
12
|
+
if WindowsDriver.detect():
|
|
13
|
+
return WindowsDriver()
|
|
14
|
+
return LinuxHyprlandDriver()
|