[][src]Module mirai::session

This mod provides a way to communicate with a mirai-api-http server.

MiraiServer

First, you should construct a MiraiServer, it contains a [base_url] property which is the address to the server.

use mirai::session::MiraiServer;

let server = MiraiServer::new("http://localhost:8080");

You can use MiraiServer::about function to get the server status.

Session

Second, you can use MiraiServer::auth to authorize, the auth key can be found in mirai-console output when it starts.

let session = server.auth("auth_key_should_be_kept_secret");

After authorization, you can bind your session with a bot that is logged in the server.

let account = "QQ Account".parse().unwrap();
session.verify(account);

You can send and get messages now!

After these, you should release the connection which your session to a bot.

session.release(account);

If not, the useless bot will continue to receive messages, this will bring memory leak.

Structs

AboutData
AboutResponse
MiraiServer

MiraiServer

Session

Session