mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2024-11-23 04:31:05 +08:00
更新SendMessage类以支持链式调用
This commit is contained in:
parent
d6443f27bb
commit
db3905eec3
|
@ -38,7 +38,18 @@ class ReplyMessage:
|
|||
|
||||
|
||||
class SendMessage:
|
||||
...
|
||||
@property
|
||||
def content(self) -> str:
|
||||
...
|
||||
@content.setter
|
||||
def content(self, value: str) -> None:
|
||||
...
|
||||
def with_content(self, content: str) -> "SendMessage":
|
||||
"""
|
||||
为了链式调用, 返回自身
|
||||
"""
|
||||
self.content = content
|
||||
return self
|
||||
|
||||
|
||||
class NewMessage:
|
||||
|
@ -64,7 +75,7 @@ class IcaClient:
|
|||
@staticmethod
|
||||
async def send_message_a(client: "IcaClient", message: SendMessage) -> bool:
|
||||
"""
|
||||
仅作占位
|
||||
仅作占位, 不能使用
|
||||
(因为目前来说, rust调用 Python端没法启动一个异步运行时
|
||||
所以只能 tokio::task::block_in_place 转换成同步调用)
|
||||
"""
|
||||
|
|
|
@ -182,6 +182,20 @@ impl SendMessagePy {
|
|||
pub fn __str__(&self) -> String {
|
||||
format!("{:?}", self.msg)
|
||||
}
|
||||
/// 设置消息内容
|
||||
/// 用于链式调用
|
||||
pub fn with_content(&mut self, content: String) -> Self {
|
||||
self.msg.content = content;
|
||||
self.clone()
|
||||
}
|
||||
#[getter]
|
||||
pub fn get_content(&self) -> String {
|
||||
self.msg.content.clone()
|
||||
}
|
||||
#[setter]
|
||||
pub fn set_content(&mut self, content: String) {
|
||||
self.msg.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
impl SendMessagePy {
|
||||
|
|
Loading…
Reference in New Issue
Block a user