#![doc(alias = "automod.message")]
use super::{AutomodCategory, EventSubscription, EventType};
use crate::types;
use serde_derive::{Deserialize, Serialize};
pub mod hold;
pub mod update;
#[doc(inline)]
pub use hold::{AutomodMessageHoldV1, AutomodMessageHoldV1Payload};
#[doc(inline)]
pub use hold::{AutomodMessageHoldV2, AutomodMessageHoldV2Payload};
#[doc(inline)]
pub use update::{AutomodMessageUpdateV1, AutomodMessageUpdateV1Payload};
#[doc(inline)]
pub use update::{AutomodMessageUpdateV2, AutomodMessageUpdateV2Payload};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
pub enum AutomodMessageStatus {
Approved,
Denied,
Expired,
Invalid,
#[serde(untagged)]
Unknown(String),
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AutomodMessage {
pub text: String,
pub fragments: Vec<AutomodMessageFragment>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
#[non_exhaustive]
pub enum AutomodMessageFragment {
Cheermote {
text: String,
cheermote: AutomodMessageCheermote,
},
Emote {
text: String,
emote: AutomodMessageEmote,
},
Text {
text: String,
},
}
impl AutomodMessageFragment {
pub fn text(&self) -> &str {
match self {
Self::Cheermote { text, .. } => text,
Self::Emote { text, .. } => text,
Self::Text { text } => text,
}
}
}
pub type AutomodMessageCheermote = crate::eventsub::channel::chat::Cheermote;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct AutomodMessageEmote {
pub id: types::EmoteId,
pub emote_set_id: types::EmoteSetId,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "reason", rename_all = "snake_case")]
#[non_exhaustive]
pub enum AutomodHeldReason {
#[serde(with = "crate::eventsub::enum_field_as_inner")]
Automod(AutomodMessageInfo),
#[serde(with = "crate::eventsub::enum_field_as_inner")]
BlockedTerm(AutomodBlockedTermInfo),
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct AutomodMessageInfo {
pub category: AutomodCategory,
pub level: u8,
pub boundaries: Vec<AutomodMessageBoundary>,
}
impl crate::eventsub::NamedField for AutomodMessageInfo {
const NAME: &'static str = "automod";
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct AutomodBlockedTermInfo {
pub terms_found: Vec<AutomodBlockedTerm>,
}
impl crate::eventsub::NamedField for AutomodBlockedTermInfo {
const NAME: &'static str = "blocked_term";
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct AutomodMessageBoundary {
pub start_pos: usize,
pub end_pos: usize,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct AutomodBlockedTermsInfo {
pub terms_found: Vec<AutomodBlockedTerm>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct AutomodBlockedTerm {
pub term_id: types::BlockedTermId,
pub boundary: AutomodMessageBoundary,
pub owner_broadcaster_user_id: types::UserId,
pub owner_broadcaster_user_login: types::UserName,
pub owner_broadcaster_user_name: types::DisplayName,
}