Struct awr::client::Client

source ·
pub struct Client { /* private fields */ }
Expand description

QQ 无头客户端。

Examples

client = await Dynamic().login(12345678, "./bots")

friend_list = client.get_friend_list()
for friend in friend_list.friends():
    print(friend.nickname())

await client.alive()

Python

class Client: ...

Implementations§

等待并保持客户端连接,期间会自动进行断线重连。

多次调用此方法时,后续的调用将直接返回。

Examples
client = await awr.Dynamic().login(12345678, "./bots")
await client.alive()
print("客户端已退出~")
Python
async def alive(self) -> None: ...

客户端 QQ 号。

Examples
client = await awr.Dynamic().login(12345678, "./bots")
assert client.uin == 12345678
Python
@property
def uin(self) -> int: ...

是否在线。

Python
def is_online(self) -> bool: ...

构造好友选择器。

参考 FriendSelector

Examples
await client.friend(12345678).poke()
Python
def friend(self, uin: int) -> FriendSelector: ...

获取账号信息。

参考 AccountInfo

Examples
info = await client.get_account_info()
print("nickname:", info.nickname)
print("age:", info.age)
print("gender:", info.gender)
Python
async def get_account_info(self) -> AccountInfo: ...

获取好友列表。

参考 FriendList

Examples
friend_list = await client.get_friend_list()
for friend in friend_list.friends():
    print(friend.nickname)
Python
async def friend_list(self) -> FriendList: ...

获取遍历好友信息的迭代器。

参考 Friend

Examples
for friend in await client.get_friends():
    print(friend.nickname)
Python
async def get_friends(self) -> Iterator[Friend]:

查找指定的好友。

参考 Friend

Examples
friend = await client.get_friend(12345678)
if friend:
    print(friend.nickname)
else:
    print("未找到好友 12345678")
Python
async def get_friend(self, uin: int) -> Friend | None:

获取群。

参考 Group

Examples
group = await client.get_group(12345678)
print(group.name)
Python
async def get_group(self, group_id: int) -> Group: ...

批量获取群,返回 { 群号: 群对象 } 的字典。

当给出的群号不存在,或者未加入这个群时,将不会在返回值中出现。这意味着返回值长度可能会小于参数长度。

参考 Group

Examples
groups = await client.get_groups([12345678, 87654321])
if 12345678 in groups:
    print(groups[12345678].name)
else:
    print("未加入群 12345678 或群不存在")
Python
async def get_groups(self, group_ids: Sequence[int]) -> dict[int, Group]: ...

获取群列表。

参考 Group

Examples
group_list = await client.get_group_list()
for group in group_list:
    print(group.name)
Note

此方法获取到的 last_msg_seq 不可用,如需要此字段请使用 get_groupget_groups

Python
async def get_group_list() -> list[Group]: ...

Trait Implementations§

Performs the conversion.
Whether the pyclass is frozen. Read more
Class doc string
#[pyclass(subclass)]
#[pyclass(extends=…)]
#[pyclass(mapping)]
#[pyclass(sequence)]
Layout
Base class
This handles following two situations: Read more
Immutable or mutable
Specify this class has #[pyclass(dict)] or not.
Specify this class has #[pyclass(weakref)] or not.
The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Utility type to make Py::as_ref work.
Class name.
Module name, if any.
Returns the PyTypeObject instance for this type.
Returns the safe abstraction over the type object.
Checks if object is an instance of this type or a subclass of this type.
Checks if object is an instance of this type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Arguments for exception
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more