robespierre_models/
bot.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{autumn::Attachment, id::UserId, users::Username};
4
5// https://github.com/revoltchat/api/blob/097f40e37108cd3a1816b1c2cc69a137ae317069/types/Bots.ts#L5-L34
6
7#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
8#[serde(deny_unknown_fields)]
9pub struct Bot {
10    /// Bot ID, matches bot's User ID
11    #[serde(rename = "_id")]
12    pub id: UserId,
13    /// Bot owner's User ID
14    pub owner: UserId,
15    /// Bot authentication token.
16    pub token: String,
17    /// Whether the bot can be added by anyone.
18    pub public: bool,
19
20    /**
21    Interactions endpoint URL
22
23    Required for dynamic interactions such as bot commands and message actions. Events will be sent over HTTP and a response may be generated directly.
24    */
25    #[serde(default, skip_serializing_if = "Option::is_none")]
26    pub interactions_url: Option<String>,
27}
28
29// https://github.com/revoltchat/api/blob/097f40e37108cd3a1816b1c2cc69a137ae317069/types/Bots.ts#L36-L56
30
31#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
32#[serde(deny_unknown_fields)]
33pub struct PublicBot {
34    /// Bot ID, matches bot's User ID
35    #[serde(rename = "_id")]
36    id: UserId,
37
38    /// Bot username
39    username: Username,
40
41    /// Bot avatar
42    #[serde(default, skip_serializing_if = "Option::is_none")]
43    avatar: Option<Attachment>,
44
45    /// Bot description, taken from profile text
46    #[serde(default, skip_serializing_if = "Option::is_none")]
47    description: Option<String>,
48}
49
50/*
51Extra
52*/
53#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
54#[serde(deny_unknown_fields)]
55pub enum BotField {
56    InteractionsURL,
57}