macro_rules! login { ($uin: expr, password = $password: expr, protocol = $protocol: expr, data_folder = $data_folder: expr $(,)?) => { ... }; ($uin: expr, password = $password: expr, protocol = $protocol: expr $(,)?) => { ... }; ($uin: expr, password_md5 = $password_md5: expr, protocol = $protocol: expr, data_folder = $data_folder: expr $(,)?) => { ... }; ($uin: expr, password_md5 = $password_md5: expr, protocol = $protocol: expr $(,)?) => { ... }; ($uin: expr, show_qrcode = $show_qrcode: expr, data_folder = $data_folder: expr $(,)?) => { ... }; ($uin: expr, show_qrcode = $show_qrcode: expr $(,)?) => { ... }; }
Expand description
登录。
在 Rust 中,使用宏模拟了函数重载和默认参数。
更多信息请参考 login
模块。
Examples
Rust
use libawr::{login, Protocol};
// 密码登录
let (client, alive) = login!(12345678, password="xxxxxx", protocol=Protocol::IPad).await?;
// 密码 MD5 登录
let (client, alive) = login!(
12345678,
password_md5 = &hex::decode("bed09fdb1471ef51")?,
protocol = Protocol::IPad
).await?;
// 扫码登录(手表协议)
let (client, alive) = login!(12345678, show_qrcode=|_| { unimplemented!() }).await?;
// 指定配置文件目录
let (client, alive) = login!(
12345678,
password = "xxxxxx",
protocol = Protocol::IPad,
data_folder = "./bots"
).await?;
Python
## 密码登录
client, alive = await awr.login(12345678, password="xxxxxx", protocol=awr.Protocol.IPAD)
## 密码 MD5 登录
client, alive = await awr.login(
12345678,
password_md5 = bytes.fromhex("bed09fdb1471ef51"),
protocol = awr.Protocol.IPAD
)
## 扫码登录(手表协议)
client, alive = await awr.login(12345678, show_qrcode=lambda _: None)
## 指定配置文件目录
client, alive = await awr.login(
12345678,
password = "xxxxxx",
protocol = awr.Protocol.IPAD,
data_folder = "./bots"
)
Python
@overload
async def login(
uin: int,
*,
password: str,
protocol: Protocol,
data_folder = "./bots"
) -> Tuple[Client, AliveHandle]: ...
@overload
async def login(
uin: int,
*,
password_md5: str,
protocol: Protocol,
data_folder = "./bots"
) -> Tuple[Client, AliveHandle]: ...
@overload
async def login(
uin: int,
*,
show_qrcode: Callable[[bytes], None],
data_folder = "./bots"
) -> Tuple[Client, AliveHandle]: ...