mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2024-11-23 12:41:05 +08:00
更新类型定义和回调函数签名***
***更新类型定义和回调函数签名
This commit is contained in:
parent
c366f6a735
commit
3ed0f5af1e
|
@ -1,6 +1,16 @@
|
||||||
# Python 兼容版本 3.8+
|
# Python 兼容版本 3.8+
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional, Callable
|
||||||
|
|
||||||
|
"""
|
||||||
|
pub type RoomId = i64;
|
||||||
|
pub type UserId = i64;
|
||||||
|
pub type MessageId = String;
|
||||||
|
"""
|
||||||
|
|
||||||
|
RoomId = int
|
||||||
|
UserId = int
|
||||||
|
MessageId = str
|
||||||
|
|
||||||
|
|
||||||
class IcaStatus:
|
class IcaStatus:
|
||||||
|
@ -11,7 +21,7 @@ class IcaStatus:
|
||||||
def online(self) -> bool:
|
def online(self) -> bool:
|
||||||
...
|
...
|
||||||
@property
|
@property
|
||||||
def self_id(self) -> Optional[bool]:
|
def self_id(self) -> Optional[UserId]:
|
||||||
...
|
...
|
||||||
@property
|
@property
|
||||||
def nick_name(self) -> Optional[str]:
|
def nick_name(self) -> Optional[str]:
|
||||||
|
@ -58,10 +68,13 @@ class NewMessage:
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
...
|
...
|
||||||
@property
|
@property
|
||||||
|
def id(self) -> MessageId:
|
||||||
|
...
|
||||||
|
@property
|
||||||
def content(self) -> str:
|
def content(self) -> str:
|
||||||
...
|
...
|
||||||
@property
|
@property
|
||||||
def sender_id(self) -> int:
|
def sender_id(self) -> UserId:
|
||||||
...
|
...
|
||||||
@property
|
@property
|
||||||
def is_from_self(self) -> bool:
|
def is_from_self(self) -> bool:
|
||||||
|
@ -82,12 +95,19 @@ class IcaClient:
|
||||||
def send_message(self, message: SendMessage) -> bool:
|
def send_message(self, message: SendMessage) -> bool:
|
||||||
...
|
...
|
||||||
def debug(self, message: str) -> None:
|
def debug(self, message: str) -> None:
|
||||||
...
|
"""向日志中输出调试信息"""
|
||||||
def info(self, message: str) -> None:
|
def info(self, message: str) -> None:
|
||||||
...
|
"""向日志中输出信息"""
|
||||||
def warn(self, message: str) -> None:
|
def warn(self, message: str) -> None:
|
||||||
...
|
"""向日志中输出警告信息"""
|
||||||
|
|
||||||
|
|
||||||
def on_message(msg: NewMessage, client: IcaClient) -> None:
|
on_load = Callable[[IcaClient], None]
|
||||||
...
|
# def on_load(client: IcaClient) -> None:
|
||||||
|
# ...
|
||||||
|
|
||||||
|
on_message = Callable[[NewMessage, IcaClient], None]
|
||||||
|
# def on_message(msg: NewMessage, client: IcaClient) -> None:
|
||||||
|
# ...
|
||||||
|
|
||||||
|
on_delete_message = Callable[[int, IcaClient], None]
|
||||||
|
|
|
@ -5,6 +5,7 @@ use tracing::{debug, info, warn};
|
||||||
|
|
||||||
use crate::client::send_message;
|
use crate::client::send_message;
|
||||||
use crate::data_struct::messages::{NewMessage, ReplyMessage, SendMessage};
|
use crate::data_struct::messages::{NewMessage, ReplyMessage, SendMessage};
|
||||||
|
use crate::data_struct::MessageId;
|
||||||
use crate::ClientStatus;
|
use crate::ClientStatus;
|
||||||
|
|
||||||
#[pyclass]
|
#[pyclass]
|
||||||
|
@ -126,7 +127,10 @@ impl NewMessagePy {
|
||||||
pub fn __str__(&self) -> String {
|
pub fn __str__(&self) -> String {
|
||||||
format!("{:?}", self.msg)
|
format!("{:?}", self.msg)
|
||||||
}
|
}
|
||||||
|
#[getter]
|
||||||
|
pub fn get_id(&self) -> MessageId {
|
||||||
|
self.msg.msg_id.clone()
|
||||||
|
}
|
||||||
#[getter]
|
#[getter]
|
||||||
pub fn get_content(&self) -> String {
|
pub fn get_content(&self) -> String {
|
||||||
self.msg.content.clone()
|
self.msg.content.clone()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user