telegram-opencode-bridge-bot 0.1.3__tar.gz → 0.1.4__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.
Files changed (27) hide show
  1. {telegram_opencode_bridge_bot-0.1.3/telegram_opencode_bridge_bot.egg-info → telegram_opencode_bridge_bot-0.1.4}/PKG-INFO +6 -9
  2. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/README.md +5 -8
  3. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/bot.py +41 -15
  4. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/handlers/commands.py +512 -295
  5. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/handlers/messages.py +2 -2
  6. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/pyproject.toml +1 -1
  7. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4/telegram_opencode_bridge_bot.egg-info}/PKG-INFO +6 -9
  8. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/.env.example +0 -0
  9. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/MANIFEST.in +0 -0
  10. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/config.py +0 -0
  11. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/handlers/__init__.py +0 -0
  12. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/list_session_models.py +0 -0
  13. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/opencode/__init__.py +0 -0
  14. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/opencode/client.py +0 -0
  15. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/opencode/server.py +0 -0
  16. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/requirements.txt +0 -0
  17. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/sessions/__init__.py +0 -0
  18. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/sessions/manager.py +0 -0
  19. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/setup.cfg +0 -0
  20. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/telegram_opencode_bridge_bot.egg-info/SOURCES.txt +0 -0
  21. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/telegram_opencode_bridge_bot.egg-info/dependency_links.txt +0 -0
  22. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/telegram_opencode_bridge_bot.egg-info/entry_points.txt +0 -0
  23. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/telegram_opencode_bridge_bot.egg-info/requires.txt +0 -0
  24. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/telegram_opencode_bridge_bot.egg-info/top_level.txt +0 -0
  25. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/utils/__init__.py +0 -0
  26. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/utils/formatting.py +0 -0
  27. {telegram_opencode_bridge_bot-0.1.3 → telegram_opencode_bridge_bot-0.1.4}/utils/security.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telegram-opencode-bridge-bot
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: A Telegram bot that bridges messages directly to OpenCode — an AI coding agent running on your machine
5
5
  Author-email: MaheshNagabhairava <maheshnagabhirava12345@gmail.com>
6
6
  License-Expression: MIT
@@ -45,7 +45,7 @@ A lightweight Python bot that bridges your Telegram messages directly to [OpenCo
45
45
 
46
46
  ### Quick Installation:
47
47
  ```bash
48
- pip install telegram-opencode-bridge-bot==0.1.2
48
+ pip install telegram-opencode-bridge-bot==0.1.4
49
49
  telegram-opencode-bot
50
50
  telegram-opencode-bot --env (use --env flag if u want to re-configure later anytime)
51
51
  ```
@@ -76,17 +76,14 @@ Open Telegram, find your bot, and start asking! 🎉
76
76
  | `/start` | Welcome message & connection check |
77
77
  | `/help` | Show all commands |
78
78
  | `/new` | Start a fresh conversation |
79
- | `/sessions` | List your recent sessions |
80
- | `/switch <id>` | Switch to a different session |
81
- | `/model <name>` | Change AI model(ex: /model opencode/deepseek-v4-flash-free) |
79
+ | `/sessions` | List your recent sessions/conversations and to select a session/conversation |
82
80
  | `/mode <plan\|build>` | Toggle plan/build mode |
83
- | `/share` | Share current session (public URL) |
81
+ | `/share` | Share current session/conversation (public URL) |
84
82
  | `/status` | Check connection & session details |
85
83
  | `/id` | Show your Telegram user ID |
86
84
  | `/stop` | Abort active model processing |
87
- | `/models` | List all available models |
88
- | `/project` | To view the current workspace, sub folder workspaces and to change the workspace (ex: /project 2)|
89
- | `/project depth <1to5>` | Depth level recursive check for subfolders (ex: if u give depth 2, only 2 sub folders it will show from root) |
85
+ | `/models` | List all available providers, models and to select the model |
86
+ | `/project` | To view the current workspace, sub folder workspaces and to change the workspace |
90
87
  | `/enable` | To enable the streaming |
91
88
  | `/disable` | To disable the streaming |
92
89
 
@@ -28,7 +28,7 @@ A lightweight Python bot that bridges your Telegram messages directly to [OpenCo
28
28
 
29
29
  ### Quick Installation:
30
30
  ```bash
31
- pip install telegram-opencode-bridge-bot==0.1.2
31
+ pip install telegram-opencode-bridge-bot==0.1.4
32
32
  telegram-opencode-bot
33
33
  telegram-opencode-bot --env (use --env flag if u want to re-configure later anytime)
34
34
  ```
@@ -59,17 +59,14 @@ Open Telegram, find your bot, and start asking! 🎉
59
59
  | `/start` | Welcome message & connection check |
60
60
  | `/help` | Show all commands |
61
61
  | `/new` | Start a fresh conversation |
62
- | `/sessions` | List your recent sessions |
63
- | `/switch <id>` | Switch to a different session |
64
- | `/model <name>` | Change AI model(ex: /model opencode/deepseek-v4-flash-free) |
62
+ | `/sessions` | List your recent sessions/conversations and to select a session/conversation |
65
63
  | `/mode <plan\|build>` | Toggle plan/build mode |
66
- | `/share` | Share current session (public URL) |
64
+ | `/share` | Share current session/conversation (public URL) |
67
65
  | `/status` | Check connection & session details |
68
66
  | `/id` | Show your Telegram user ID |
69
67
  | `/stop` | Abort active model processing |
70
- | `/models` | List all available models |
71
- | `/project` | To view the current workspace, sub folder workspaces and to change the workspace (ex: /project 2)|
72
- | `/project depth <1to5>` | Depth level recursive check for subfolders (ex: if u give depth 2, only 2 sub folders it will show from root) |
68
+ | `/models` | List all available providers, models and to select the model |
69
+ | `/project` | To view the current workspace, sub folder workspaces and to change the workspace |
73
70
  | `/enable` | To enable the streaming |
74
71
  | `/disable` | To disable the streaming |
75
72
 
@@ -24,9 +24,12 @@ from telegram.ext import (
24
24
  ApplicationBuilder,
25
25
  CommandHandler,
26
26
  MessageHandler,
27
+ CallbackQueryHandler,
27
28
  filters,
28
29
  ContextTypes,
29
30
  )
31
+ from telegram.request import HTTPXRequest
32
+ from telegram.error import TimedOut, NetworkError
30
33
  from utils.formatting import format_error
31
34
 
32
35
  from config import config
@@ -38,8 +41,6 @@ from handlers.commands import (
38
41
  help_command,
39
42
  new_command,
40
43
  sessions_command,
41
- switch_command,
42
- model_command,
43
44
  mode_command,
44
45
  share_command,
45
46
  status_command,
@@ -50,6 +51,7 @@ from handlers.commands import (
50
51
  enable_command,
51
52
  disable_command,
52
53
  set_bot_commands,
54
+ callback_handler,
53
55
  )
54
56
  from handlers.messages import handle_message
55
57
 
@@ -62,6 +64,25 @@ logging.basicConfig(
62
64
  logger = logging.getLogger("opencode-telegram-bot")
63
65
 
64
66
 
67
+ class RetryingHTTPXRequest(HTTPXRequest):
68
+ """Custom HTTPXRequest that automatically retries failed requests on connection timeouts/errors."""
69
+ async def do_request(self, *args, **kwargs) -> tuple[int, bytes]:
70
+ max_retries = 3
71
+ for attempt in range(max_retries):
72
+ try:
73
+ return await super().do_request(*args, **kwargs)
74
+ except (TimedOut, NetworkError) as e:
75
+ # Do not retry on Pool timeout errors
76
+ if "Pool timeout" in str(e) or attempt == max_retries - 1:
77
+ raise
78
+
79
+ logger.warning(
80
+ f"⚠️ Telegram request failed (attempt {attempt + 1}/{max_retries}): {e}. "
81
+ f"Retrying in {1.0 * (attempt + 1)}s..."
82
+ )
83
+ await asyncio.sleep(1.0 * (attempt + 1))
84
+
85
+
65
86
  # ── Wrap handlers with auth decorator ──────────────────────
66
87
 
67
88
  def build_authorized_handlers(authorizer: UserAuthorizer, rate_limiter: RateLimiter):
@@ -83,14 +104,6 @@ def build_authorized_handlers(authorizer: UserAuthorizer, rate_limiter: RateLimi
83
104
  async def _sessions(update, context):
84
105
  await sessions_command(update, context)
85
106
 
86
- @authorized(authorizer, rate_limiter)
87
- async def _switch(update, context):
88
- await switch_command(update, context)
89
-
90
- @authorized(authorizer, rate_limiter)
91
- async def _model(update, context):
92
- await model_command(update, context)
93
-
94
107
  @authorized(authorizer, rate_limiter)
95
108
  async def _mode(update, context):
96
109
  await mode_command(update, context)
@@ -127,6 +140,10 @@ def build_authorized_handlers(authorizer: UserAuthorizer, rate_limiter: RateLimi
127
140
  async def _disable(update, context):
128
141
  await disable_command(update, context)
129
142
 
143
+ @authorized(authorizer)
144
+ async def _callback(update, context):
145
+ await callback_handler(update, context)
146
+
130
147
  @authorized(authorizer, rate_limiter)
131
148
  async def _message(update, context):
132
149
  await handle_message(update, context)
@@ -136,8 +153,6 @@ def build_authorized_handlers(authorizer: UserAuthorizer, rate_limiter: RateLimi
136
153
  "help": _help,
137
154
  "new": _new,
138
155
  "sessions": _sessions,
139
- "switch": _switch,
140
- "model": _model,
141
156
  "models": _models,
142
157
  "stop": _stop,
143
158
  "project": _project,
@@ -147,6 +162,7 @@ def build_authorized_handlers(authorizer: UserAuthorizer, rate_limiter: RateLimi
147
162
  "share": _share,
148
163
  "status": _status,
149
164
  "id": _id,
165
+ "callback": _callback,
150
166
  "message": _message,
151
167
  }
152
168
 
@@ -390,9 +406,18 @@ def main():
390
406
  session_mgr = SessionManager(db_path=config.db_path)
391
407
 
392
408
  # ── Build Telegram application ────────────────────────
409
+ request = RetryingHTTPXRequest(
410
+ connect_timeout=15.0,
411
+ read_timeout=20.0,
412
+ write_timeout=20.0,
413
+ pool_timeout=5.0,
414
+ connection_pool_size=512,
415
+ )
416
+
393
417
  application = (
394
418
  ApplicationBuilder()
395
419
  .token(config.telegram_bot_token)
420
+ .request(request)
396
421
  .post_init(post_init)
397
422
  .post_shutdown(post_shutdown)
398
423
  .build()
@@ -415,8 +440,6 @@ def main():
415
440
  application.add_handler(CommandHandler("help", handlers["help"], block=False))
416
441
  application.add_handler(CommandHandler("new", handlers["new"], block=False))
417
442
  application.add_handler(CommandHandler("sessions", handlers["sessions"], block=False))
418
- application.add_handler(CommandHandler("switch", handlers["switch"], block=False))
419
- application.add_handler(CommandHandler("model", handlers["model"], block=False))
420
443
  application.add_handler(CommandHandler("models", handlers["models"], block=False))
421
444
  application.add_handler(CommandHandler("stop", handlers["stop"], block=False))
422
445
  application.add_handler(CommandHandler("project", handlers["project"], block=False))
@@ -427,6 +450,9 @@ def main():
427
450
  application.add_handler(CommandHandler("status", handlers["status"], block=False))
428
451
  application.add_handler(CommandHandler("id", handlers["id"], block=False))
429
452
 
453
+ # ── Register callback query handler ───────────────────
454
+ application.add_handler(CallbackQueryHandler(handlers["callback"], block=False))
455
+
430
456
  # ── Register message handler (catches all text) ───────
431
457
  application.add_handler(
432
458
  MessageHandler(
@@ -440,7 +466,7 @@ def main():
440
466
  logger.info("Starting bot with long polling...")
441
467
  application.run_polling(
442
468
  drop_pending_updates=True,
443
- allowed_updates=["message"],
469
+ allowed_updates=["message", "callback_query"],
444
470
  )
445
471
 
446
472