1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use async_std::stream::StreamExt;

use crate::client::LichessApi;
use crate::error::Result;
use crate::model::bot::online::OnlineBot;
use crate::model::bot::*;

impl LichessApi<reqwest::Client> {
    pub async fn bot_abort_game(&self, request: abort::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }

    pub async fn bot_stream_game_chat(
        &self,
        request: chat::GetRequest,
    ) -> Result<impl StreamExt<Item = Result<chat::ChatLine>>> {
        self.get_streamed_models(request).await
    }

    pub async fn bot_write_in_chat(&self, request: chat::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }

    pub async fn bot_draw_game(&self, request: draw::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }

    pub async fn bot_make_move(&self, request: r#move::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }

    pub async fn bot_get_online(
        &self,
        request: online::GetRequest,
    ) -> Result<impl StreamExt<Item = Result<OnlineBot>>> {
        self.get_streamed_models(request).await
    }

    pub async fn bot_resign_game(&self, request: resign::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }

    pub async fn bot_stream_incoming_events(
        &self,
        request: stream::events::GetRequest,
    ) -> Result<impl StreamExt<Item = Result<stream::events::Event>>> {
        self.get_streamed_models(request).await
    }

    pub async fn bot_stream_board_state(
        &self,
        request: stream::game::GetRequest,
    ) -> Result<impl StreamExt<Item = Result<stream::game::Event>>> {
        self.get_streamed_models(request).await
    }

    pub async fn bot_upgrade_account(&self, request: upgrade::PostRequest) -> Result<bool> {
        self.get_ok(request).await
    }
}