interplane.Get Omega
Read in your language

aien-sovereign-core

Autonomous sovereign intelligence engine and runtime core for NVIDIA DGX Spark

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core / crates / spark-discord-hub / src / gideon_bot.rs

58 lines · 2207 bytes Raw Blame History
1use reqwest::Client;
2use tracing::{error, info};
3
4use crate::models::{CreateMessagePayload, MessageReference};
5use crate::vault::get_vault_secret;
6
7pub struct GideonBot {
8 pub client: Client,
9 pub token: String,
10}
11
12impl GideonBot {
13 pub fn new(token: String) -> Self {
14 Self {
15 client: Client::builder().build().unwrap_or_default(),
16 token,
17 }
18 }
19
20 pub async fn handle_command(&self, channel_id: &str, message_id: &str, command: &str, author_name: &str) {
21 info!("[GideonBot] Processing command from {}: {}", author_name, command);
22
23 let reply_text = match command {
24 "!gideon status" | "!status" => {
25 let torn_key_status = if get_vault_secret("TORN_API_KEY").is_some() { "ARMED (TPM)" } else { "MISSING" };
26 format!("G.I.D.E.O.N. Sovereign Core: ONLINE\nArchitecture: Native Rust (GB10 SparkOS)\nTorn API Vault: {}\nRoles: Deterministic Ledger Active", torn_key_status)
27 }
28 "!verify" | "!link" => {
29 "To verify your Torn membership, use the native verification modal or link your Torn ID directly with Gideon.".to_string()
30 }
31 "!help" => {
32 "G.I.D.E.O.N. Commands:\n- - Check sovereign bot and vault status\n- - Torn membership verification\n- - Command listing".to_string()
33 }
34 _ => {
35 format!("G.I.D.E.O.N. command not recognized: {}. Try .", command)
36 }
37 };
38
39 let discord_url = format!("https://discord.com/api/v10/channels/{}/messages", channel_id);
40 let payload = CreateMessagePayload {
41 content: reply_text,
42 message_reference: Some(MessageReference {
43 message_id: message_id.to_string(),
44 }),
45 };
46
47 if let Err(e) = self.client.post(&discord_url)
48 .header("Authorization", format!("Bot {}", self.token))
49 .json(&payload)
50 .send()
51 .await
52 {
53 error!("[GideonBot] Failed to send Discord reply: {}", e);
54 } else {
55 info!("[GideonBot] Replied to {} in channel {}", author_name, channel_id);
56 }
57 }
58}