feat: add events module with BridgeEvent, ControlCommand, OwncastState types
Made-with: Cursor
This commit is contained in:
51
src/events.rs
Normal file
51
src/events.rs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
use tokio::sync::oneshot;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub enum Source {
|
||||||
|
Irc,
|
||||||
|
Owncast,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum BridgeEvent {
|
||||||
|
ChatMessage {
|
||||||
|
source: Source,
|
||||||
|
username: String,
|
||||||
|
body: String,
|
||||||
|
id: Option<String>,
|
||||||
|
},
|
||||||
|
StreamStarted {
|
||||||
|
title: String,
|
||||||
|
},
|
||||||
|
StreamStopped,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub enum OwncastState {
|
||||||
|
Online,
|
||||||
|
OfflineChatOpen,
|
||||||
|
Unavailable,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ControlCommand {
|
||||||
|
IrcConnect,
|
||||||
|
IrcDisconnect,
|
||||||
|
IrcReconnect,
|
||||||
|
OwncastConnect,
|
||||||
|
OwncastDisconnect,
|
||||||
|
OwncastReconnect,
|
||||||
|
Status {
|
||||||
|
reply: oneshot::Sender<BridgeStatus>,
|
||||||
|
},
|
||||||
|
Quit,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, serde::Serialize)]
|
||||||
|
pub struct BridgeStatus {
|
||||||
|
pub irc_connected: bool,
|
||||||
|
pub owncast_state: String,
|
||||||
|
pub webhook_listening: bool,
|
||||||
|
pub websocket_connected: bool,
|
||||||
|
pub uptime_secs: u64,
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
mod config;
|
mod config;
|
||||||
|
mod events;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("owncast-irc-bridge");
|
println!("owncast-irc-bridge");
|
||||||
|
|||||||
Reference in New Issue
Block a user