lichess_api/api/
bot.rs

1use async_std::stream::StreamExt;
2
3use crate::client::LichessApi;
4use crate::error::Result;
5use crate::model::bot::online::OnlineBot;
6use crate::model::bot::*;
7
8impl LichessApi<reqwest::Client> {
9    pub async fn bot_abort_game(&self, request: impl Into<abort::PostRequest>) -> Result<bool> {
10        self.get_ok(request.into()).await
11    }
12
13    pub async fn bot_stream_game_chat(
14        &self,
15        request: impl Into<chat::GetRequest>,
16    ) -> Result<impl StreamExt<Item = Result<chat::ChatLine>>> {
17        self.get_streamed_models(request.into()).await
18    }
19
20    pub async fn bot_write_in_chat(&self, request: impl Into<chat::PostRequest>) -> Result<bool> {
21        self.get_ok(request.into()).await
22    }
23
24    pub async fn bot_draw_game(&self, request: impl Into<draw::PostRequest>) -> Result<bool> {
25        self.get_ok(request.into()).await
26    }
27
28    pub async fn bot_make_move(&self, request: impl Into<r#move::PostRequest>) -> Result<bool> {
29        self.get_ok(request.into()).await
30    }
31
32    pub async fn bot_get_online(
33        &self,
34        request: impl Into<online::GetRequest>,
35    ) -> Result<impl StreamExt<Item = Result<OnlineBot>>> {
36        self.get_streamed_models(request.into()).await
37    }
38
39    pub async fn bot_resign_game(&self, request: impl Into<resign::PostRequest>) -> Result<bool> {
40        self.get_ok(request.into()).await
41    }
42
43    pub async fn bot_stream_incoming_events(
44        &self,
45        request: impl Into<stream::events::GetRequest>,
46    ) -> Result<impl StreamExt<Item = Result<stream::events::Event>>> {
47        self.get_streamed_models(request.into()).await
48    }
49
50    pub async fn bot_stream_board_state(
51        &self,
52        request: impl Into<stream::game::GetRequest>,
53    ) -> Result<impl StreamExt<Item = Result<stream::game::Event>>> {
54        self.get_streamed_models(request.into()).await
55    }
56
57    pub async fn bot_upgrade_account(
58        &self,
59        request: impl Into<upgrade::PostRequest>,
60    ) -> Result<bool> {
61        self.get_ok(request.into()).await
62    }
63}