Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
feat: add proxy_url parameter to all Telegram API functions
ReWiGbaf0b8a9527a
diff --git a/modules/im/telegram_api.py b/modules/im/telegram_api.pyindex 45b60a38c..015ec0967 100644--- a/modules/im/telegram_api.py+++ b/modules/im/telegram_api.py@@ -24,52 +24,59 @@ async def call_api(*,timeout_seconds: int = 60,form: Optional[aiohttp.FormData] = None,+ proxy_url: Optional[str] = None,) -> dict[str, Any]:timeout = aiohttp.ClientTimeout(total=timeout_seconds)- async with aiohttp.ClientSession(timeout=timeout) as session:+ connector = None+ if proxy_url:+ connector = aiohttp.TCPConnector()+ async with aiohttp.ClientSession(timeout=timeout, connector=connector) as session:if form is not None:- async with session.post(_api_url(bot_token, method), data=form) as resp:+ async with session.post(_api_url(bot_token, method), data=form, proxy=proxy_url) as resp:data = await resp.json()else:- async with session.post(_api_url(bot_token, method), json=payload or {}) as resp:+ async with session.post(_api_url(bot_token, method), json=payload or {}, proxy=proxy_url) as resp:data = await resp.json()if not data.get("ok"):raise RuntimeError(data.get("description") or f"Telegram API call failed: {method}")return data-async def get_me(bot_token: str) -> dict[str, Any]:- return await call_api(bot_token, "getMe")+async def get_me(bot_token: str, proxy_url: Optional[str] = None) -> dict[str, Any]:+ return await call_api(bot_token, "getMe", proxy_url=proxy_url)-async def create_forum_topic(bot_token: str, chat_id: str, name: str) -> dict[str, Any]:- return await call_api(bot_token, "createForumTopic", {"chat_id": chat_id, "name": name})+async def create_forum_topic(bot_token: str, chat_id: str, name: str, proxy_url: Optional[str] = None) -> dict[str, Any]:+ return await call_api(bot_token, "createForumTopic", {"chat_id": chat_id, "name": name}, proxy_url=proxy_url)-async def get_updates(bot_token: str, offset: Optional[int], timeout_seconds: int = 30) -> dict[str, Any]:+async def get_updates(bot_token: str, offset: Optional[int], timeout_seconds: int = 30, proxy_url: Optional[str] = None) -> dict[str, Any]:payload: dict[str, Any] = {"timeout": timeout_seconds,"allowed_updates": ["message", "callback_query", "my_chat_member", "chat_member"],}if offset is not None:payload["offset"] = offset- return await call_api(bot_token, "getUpdates", payload, timeout_seconds=timeout_seconds + 10)+ return await call_api(bot_token, "getUpdates", payload, timeout_seconds=timeout_seconds + 10, proxy_url=proxy_url)-async def download_file(bot_token: str, file_path: str, *, timeout_seconds: int = 60) -> bytes:+async def download_file(bot_token: str, file_path: str, *, timeout_seconds: int = 60, proxy_url: Optional[str] = None) -> bytes:timeout = aiohttp.ClientTimeout(total=timeout_seconds)- async with aiohttp.ClientSession(timeout=timeout) as session:- async with session.get(_file_url(bot_token, file_path)) as resp:+ connector = None+ if proxy_url:+ connector = aiohttp.TCPConnector()+ async with aiohttp.ClientSession(timeout=timeout, connector=connector) as session:+ async with session.get(_file_url(bot_token, file_path), proxy=proxy_url) as resp:resp.raise_for_status()return await resp.read()-async def get_file(bot_token: str, file_id: str) -> dict[str, Any]:- return await call_api(bot_token, "getFile", {"file_id": file_id})+async def get_file(bot_token: str, file_id: str, proxy_url: Optional[str] = None) -> dict[str, Any]:+ return await call_api(bot_token, "getFile", {"file_id": file_id}, proxy_url=proxy_url)-async def delete_message(bot_token: str, chat_id: str, message_id: str) -> dict[str, Any]:- return await call_api(bot_token, "deleteMessage", {"chat_id": chat_id, "message_id": int(message_id)})+async def delete_message(bot_token: str, chat_id: str, message_id: str, proxy_url: Optional[str] = None) -> dict[str, Any]:+ return await call_api(bot_token, "deleteMessage", {"chat_id": chat_id, "message_id": int(message_id)}, proxy_url=proxy_url)async def set_message_reaction(@@ -79,6 +86,7 @@ async def set_message_reaction(emoji: str,*,is_big: bool = False,+ proxy_url: Optional[str] = None,) -> dict[str, Any]:payload = {"chat_id": chat_id,@@ -86,16 +94,16 @@ async def set_message_reaction("reaction": [{"type": "emoji", "emoji": emoji}],"is_big": is_big,}- return await call_api(bot_token, "setMessageReaction", payload)+ return await call_api(bot_token, "setMessageReaction", payload, proxy_url=proxy_url)-async def clear_message_reaction(bot_token: str, chat_id: str, message_id: str) -> dict[str, Any]:+async def clear_message_reaction(bot_token: str, chat_id: str, message_id: str, proxy_url: Optional[str] = None) -> dict[str, Any]:payload = {"chat_id": chat_id,"message_id": int(message_id),"reaction": [],}- return await call_api(bot_token, "setMessageReaction", payload)+ return await call_api(bot_token, "setMessageReaction", payload, proxy_url=proxy_url)async def send_multipart_file(@@ -104,6 +112,7 @@ async def send_multipart_file(payload: dict[str, Any],file_path: str,field_name: str,+ proxy_url: Optional[str] = None,) -> dict[str, Any]:form = aiohttp.FormData()for key, value in payload.items():@@ -115,4 +124,4 @@ async def send_multipart_file(form.add_field(key, str(value))path = Path(file_path)form.add_field(field_name, path.read_bytes(), filename=path.name)- return await call_api(bot_token, method, form=form)+ return await call_api(bot_token, method, form=form, proxy_url=proxy_url)