mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 10:33:18 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
41
gateway/server_methods/telegram_send_normalize.py
Normal file
41
gateway/server_methods/telegram_send_normalize.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from oclaw.extensions.telegram import (
|
||||
normalize_telegram_messaging_target,
|
||||
parse_telegram_reply_to_message_id,
|
||||
parse_telegram_target,
|
||||
parse_telegram_thread_id,
|
||||
)
|
||||
|
||||
|
||||
def normalize_transport_target_for_channel(
|
||||
*,
|
||||
channel: str,
|
||||
to: str,
|
||||
params: dict[str, Any],
|
||||
) -> tuple[str, dict[str, Any]]:
|
||||
"""Normalize channel transport target payload for outbound paths."""
|
||||
extra: dict[str, Any] = {}
|
||||
if channel != "telegram":
|
||||
return to, extra
|
||||
|
||||
normalized_target = normalize_telegram_messaging_target(to)
|
||||
parsed_target = parse_telegram_target(normalized_target or to)
|
||||
normalized_to = normalized_target or f"telegram:{parsed_target.chat_id}".lower()
|
||||
reply_to_id = parse_telegram_reply_to_message_id(params.get("replyToId"))
|
||||
thread_id = parse_telegram_thread_id(
|
||||
params.get("threadId") if params.get("threadId") is not None else parsed_target.message_thread_id
|
||||
)
|
||||
|
||||
extra = {
|
||||
"target": {
|
||||
"chatId": parsed_target.chat_id,
|
||||
"chatType": parsed_target.chat_type,
|
||||
**({"messageThreadId": parsed_target.message_thread_id} if parsed_target.message_thread_id is not None else {}),
|
||||
},
|
||||
**({"threadId": thread_id} if thread_id is not None else {}),
|
||||
**({"replyToMessageId": reply_to_id} if reply_to_id is not None else {}),
|
||||
}
|
||||
return normalized_to, extra
|
||||
Loading…
Add table
Add a link
Reference in a new issue