Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: Telegram 消息段的设计 #6

Closed
j1g5awi opened this issue Dec 31, 2021 · 1 comment
Closed

Breaking: Telegram 消息段的设计 #6

j1g5awi opened this issue Dec 31, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@j1g5awi
Copy link
Member

j1g5awi commented Dec 31, 2021

类 OneBot(当前)

作为消息数组 Message 的成员,纯文本消息与非纯文本消息并列。

def photo(file: str) -> "MessageSegment":
    return MessageSegment("photo", {"file": file})

发送

bot.send(event, MessageSegment.photo(file="image.png"))

其他

Event 提供类原生的 telegram_model 字段

类原生(废弃)

Photo 等非纯文本消息作为 Event 字段与纯文本消息数组 Message 独立

class MessageEvent(Event):
    ...
    photo: Optional[List[PhotoSize]]
    ...

class PhotoSize(BaseModel):
    file_id: str
    file_unique_id: str
    width: int
    height: int
    file_size: Optional[int]

发送

bot.send(event, photo="image.png")

@j1g5awi j1g5awi added the enhancement New feature or request label Dec 31, 2021
@j1g5awi j1g5awi pinned this issue Jan 10, 2022
@j1g5awi j1g5awi changed the title Breaking: 关于 Telegram 消息段的设计 Breaking: Telegram 消息段的设计 Feb 8, 2022
@j1g5awi j1g5awi closed this as completed Mar 16, 2022
@j1g5awi
Copy link
Member Author

j1g5awi commented Jul 8, 2023

#47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant