2024-03-02 09:44:09 -05:00
|
|
|
use std::sync::Arc;
|
|
|
|
use tokio::sync::RwLock;
|
2023-12-28 06:02:55 -05:00
|
|
|
|
2024-03-02 09:44:09 -05:00
|
|
|
use casual_logger::{Extension, Level, Log};
|
2024-02-24 22:31:12 -05:00
|
|
|
|
2024-03-02 10:06:26 -05:00
|
|
|
use bot_lib::core::botinstance::BotInstance;
|
|
|
|
use bot_lib::core::botlog;
|
2024-03-02 09:44:09 -05:00
|
|
|
use bot_lib::core::botmodules;
|
2024-02-04 14:28:37 -05:00
|
|
|
|
2024-02-12 01:25:12 -05:00
|
|
|
pub type BotAR = Arc<RwLock<BotInstance>>;
|
2023-12-19 20:38:20 -05:00
|
|
|
|
2024-03-02 09:44:09 -05:00
|
|
|
// God I love anime girls
|
2024-03-17 17:40:15 -04:00
|
|
|
// fr fr
|
2024-02-25 12:49:07 -05:00
|
|
|
|
2023-10-22 08:35:09 -04:00
|
|
|
#[tokio::main]
|
|
|
|
pub async fn main() {
|
2024-02-13 07:54:35 -05:00
|
|
|
Log::set_file_ext(Extension::Log);
|
|
|
|
Log::set_level(Level::Trace);
|
2024-03-20 20:43:57 -04:00
|
|
|
Log::set_retention_days(2);
|
2024-02-25 10:40:54 -05:00
|
|
|
// Log::set_level(Level::Notice);
|
2024-02-13 07:54:35 -05:00
|
|
|
|
2024-03-20 20:43:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-12 02:34:32 -05:00
|
|
|
let bot = BotInstance::init().await;
|
|
|
|
|
2024-03-02 09:44:09 -05:00
|
|
|
{
|
2024-03-02 12:21:18 -05:00
|
|
|
botlog::trace("Reading bot actions", Some("main()".to_string()), None);
|
2024-03-02 09:44:09 -05:00
|
|
|
|
|
|
|
let actsdb = Arc::clone(&bot.botmodules.botactions);
|
|
|
|
let actsdb_lock = actsdb.read().await;
|
|
|
|
|
|
|
|
for acts in (*actsdb_lock).values() {
|
|
|
|
for act in acts {
|
|
|
|
let outstr = match act {
|
|
|
|
botmodules::BotAction::C(b) => {
|
2024-03-02 12:21:18 -05:00
|
|
|
format!("bot actions > Command : {}", b.command)
|
2024-03-02 09:44:09 -05:00
|
|
|
}
|
|
|
|
botmodules::BotAction::L(l) => {
|
2024-03-02 12:21:18 -05:00
|
|
|
format!("bot actions > Listener : {}", l.name)
|
2024-03-02 09:44:09 -05:00
|
|
|
}
|
|
|
|
_ => "Not a valid match??".to_string(),
|
|
|
|
};
|
|
|
|
|
|
|
|
botlog::info(outstr.as_str(), Some("main()".to_string()), None);
|
2024-02-12 02:34:32 -05:00
|
|
|
}
|
|
|
|
}
|
2024-02-25 10:40:54 -05:00
|
|
|
}
|
2024-02-12 02:34:32 -05:00
|
|
|
|
2024-03-02 09:44:09 -05:00
|
|
|
botlog::notice("Starting Bot Runner", Some("main()".to_string()), None);
|
2024-02-13 10:11:49 -05:00
|
|
|
println!("Starting Bot Runner");
|
2024-02-13 07:54:35 -05:00
|
|
|
|
|
|
|
Log::flush();
|
2023-12-19 20:38:20 -05:00
|
|
|
|
2024-02-12 01:25:12 -05:00
|
|
|
bot.runner().await;
|
2024-02-04 14:28:37 -05:00
|
|
|
|
2024-03-02 10:06:26 -05:00
|
|
|
let pstr = botlog::fatal("ERROR : EXIT Game loop", Some("main()".to_string()), None);
|
2024-03-02 09:44:09 -05:00
|
|
|
panic!("{}", pstr);
|
2024-02-25 10:40:54 -05:00
|
|
|
}
|
2024-03-20 20:43:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
|