mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
refac
This commit is contained in:
1 parent
571fc4b433
commit
d95d6192fe
2 files changed
+24
-23
No files matched your search
@@ -240,7 +240,7 @@ class TelegramAdapter(BaseAdapter):
|
||||
text = message.get("text") or message.get("caption") or ""
|
||||
|
||||
# Collect attachments from media types
|
||||
attachments: list = []
|
||||
attachments: list[Attachment] = []
|
||||
|
||||
# Photos — Telegram sends multiple sizes, pick the largest
|
||||
if message.get("photo"):
|
||||
@@ -286,7 +286,6 @@ class TelegramAdapter(BaseAdapter):
|
||||
audio = message["audio"]
|
||||
file_data = await self._download_file(audio["file_id"])
|
||||
if file_data:
|
||||
from cptr.utils.bridge import Attachment
|
||||
fname = audio.get("file_name", "audio.mp3")
|
||||
attachments.append(Attachment(
|
||||
type="audio",
|
||||
|
||||
@@ -68,18 +68,19 @@ def _find_claude_desktop_command() -> str | None:
|
||||
localappdata = os.environ.get("LOCALAPPDATA")
|
||||
packages_dir = os.path.join(localappdata, "Packages") if localappdata else None
|
||||
if packages_dir and os.path.isdir(packages_dir):
|
||||
for name in os.listdir(packages_dir):
|
||||
if name.startswith("Claude_"):
|
||||
roots.append(
|
||||
os.path.join(
|
||||
packages_dir,
|
||||
name,
|
||||
"LocalCache",
|
||||
"Roaming",
|
||||
"Claude",
|
||||
"claude-code",
|
||||
with suppress(OSError):
|
||||
for name in os.listdir(packages_dir):
|
||||
if name.startswith("Claude_"):
|
||||
roots.append(
|
||||
os.path.join(
|
||||
packages_dir,
|
||||
name,
|
||||
"LocalCache",
|
||||
"Roaming",
|
||||
"Claude",
|
||||
"claude-code",
|
||||
)
|
||||
)
|
||||
)
|
||||
relative_paths = (("claude.exe",),)
|
||||
else:
|
||||
roots = [
|
||||
@@ -100,16 +101,17 @@ def _find_claude_desktop_command() -> str | None:
|
||||
for root in roots:
|
||||
if not os.path.isdir(root):
|
||||
continue
|
||||
for name in os.listdir(root):
|
||||
version_dir = os.path.join(root, name)
|
||||
version = _parse_version_tuple(name)
|
||||
if version is None or not os.path.isdir(version_dir):
|
||||
continue
|
||||
for relative_path in relative_paths:
|
||||
candidate = os.path.join(version_dir, *relative_path)
|
||||
if os.path.isfile(candidate) and os.access(candidate, os.X_OK):
|
||||
candidates.append((version, candidate))
|
||||
break
|
||||
with suppress(OSError):
|
||||
for name in os.listdir(root):
|
||||
version_dir = os.path.join(root, name)
|
||||
version = _parse_version_tuple(name)
|
||||
if version is None or not os.path.isdir(version_dir):
|
||||
continue
|
||||
for relative_path in relative_paths:
|
||||
candidate = os.path.join(version_dir, *relative_path)
|
||||
if os.path.isfile(candidate) and os.access(candidate, os.X_OK):
|
||||
candidates.append((version, candidate))
|
||||
break
|
||||
return max(candidates, key=lambda item: item[0])[1] if candidates else None
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user