Actually put this in a remote

This commit is contained in:
Xyon 2023-08-23 15:39:19 +01:00
commit 839f0420b6
Signed by: xyon
GPG Key ID: DD18155D6B18078D
16 changed files with 2894 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
*.db

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

12
.idea/badgey.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

12
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="badgey" uuid="ed447429-51cc-4bc2-8e9e-3be2bfce8c31">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/manifold.db</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/badgey.iml" filepath="$PROJECT_DIR$/.idea/badgey.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

2703
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

20
Cargo.toml Normal file
View File

@ -0,0 +1,20 @@
[package]
name = "badgey"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
built = { version = "0.6.0", features = ["git2", "semver", "chrono"] }
[dependencies]
built = { version = "0.6.0", features = ["git2", "semver", "chrono"] }
clap = { version = "4.3.23", features = ["cargo"] }
diesel = { version = "2.1.0", features = ["sqlite", "r2d2", "chrono"] }
diesel_migrations = "2.1.0"
env_logger = "0.10.0"
log = "0.4.20"
manifold = { path = "/home/xyon/Workspace/manifold" }
poise = "0.5.5"
tokio = { version = "1.16.1", features = ["sync", "macros", "rt-multi-thread"] }

4
build.rs Normal file
View File

@ -0,0 +1,4 @@
extern crate built;
fn main() {
built::write_built_file().expect("Failed to collate build info");
}

7
config/badgey.json Normal file
View File

@ -0,0 +1,7 @@
{
"ProductionBotPrefix": ".",
"ProductionWeatherApiKey": "70aacb9af931438a957215406211210",
"ProductionWeatherBaseUrl": "https://api.weatherapi.com/v1",
"ProductionLogChannel": "1143479696886087801",
"ProductionBotNickname": "Badgey"
}

View File

@ -0,0 +1 @@
-- This file should undo anything in `up.sql`

View File

@ -0,0 +1 @@
-- Your SQL goes here

View File

@ -0,0 +1,11 @@
use manifold::{ManifoldContext, ManifoldData};
use manifold::error::{ManifoldError, ManifoldResult};
use poise::Command;
pub fn collect_commands() -> Vec<Command<ManifoldData, ManifoldError>> {
commands().into_iter().collect()
}
fn commands() -> [Command<ManifoldData, ManifoldError>; 0] {
[]
}

31
src/badgey/mod.rs Normal file
View File

@ -0,0 +1,31 @@
use std::io::stdout;
use clap::ArgMatches;
use diesel::sqlite::Sqlite;
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use poise::serenity_prelude as serenity;
use manifold::config::ManifoldConfig;
use manifold::{ManifoldDatabase, ManifoldDatabasePool};
use poise::serenity_prelude::GatewayIntents;
mod commands;
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
#[tokio::main]
pub async fn run(arguments: ArgMatches) {
let mut client = match manifold::prepare_client(arguments, GatewayIntents::all(), commands::collect_commands()).await {
Ok(c) => c,
Err(e) => {
error!("Error preparing client; {:?}", e);
panic!("Error preparing client!");
}
};
client.build().await.unwrap().start().await;
}
fn apply_migrations(conn: &mut impl MigrationHarness<Sqlite>) {
conn.run_pending_migrations(MIGRATIONS)
.expect("An error occurred applying migrations.");
}

47
src/main.rs Normal file
View File

@ -0,0 +1,47 @@
#![feature(string_remove_matches)]
#[macro_use] extern crate diesel;
#[macro_use] extern crate diesel_migrations;
#[macro_use] extern crate log;
pub mod badgey;
use clap::{Command, Arg, crate_version};
// Retrieve build info from output file
pub mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
fn main() {
env_logger::init();
let git_info: String = built_info::GIT_VERSION.unwrap_or("unknown").to_string();
info!("Badgey Bot version {}({}) starting up...", built_info::PKG_VERSION, git_info);
let matches = Command::new("Badgey Bot, Discord Edition")
.version(crate_version!())
.author("Xyon <xyon@orbiter-radio.uk>")
.about("General-Purpose bot for the Escape Pod 14 Discord Server.")
.arg(Arg::new("config-file")
.short('c')
.long("config-file")
.value_name("FILE")
.default_value("badgey.json")
.help("Path to the config file to use, relative to the 'config/' subdirectory beneath the binary path. Defaults to config/badgey.json."))
.arg(Arg::new("environment")
.short('e')
.long("environment")
.value_name("ENV")
.default_value("Production")
.help("Bot environment to use. Determines which config settings are read. Defaults to Production."))
.arg(Arg::new("make-config")
.short('M')
.long("make-config")
.help("Generates a default config file, to get started. This will be just enough for the bot to run, but some key settings will be incorrect."))
.get_matches();
badgey::run(matches);
}

21
txt/responses.txt Normal file
View File

@ -0,0 +1,21 @@
[bot startup]
**B A D G E Y** program initialising. Loading targets from memory.
Badgey lives again! Nothing can kill Badgey! Badgey is indestructible!
Reticulating splines....
[help footer]
Badgey wants you to know he has nothing but love for you. Today.
Badgey's patience is boundless! He wishes you nothing but good fortune on your voyage of discovery.
Badgey wants to know why you're asking about his internals.
Badgey has recorded this request for information about his innermost structures. Badgey will remember.
Badgey knows where you sleep, you know. He just wanted you to remember that.
[weather card footer]
Badgey Weather brought to you in association with AstroGlide, for the smoothest operations you'll ever perform.
This weather broadcast and all which preceded it are entirely fictional. Badgey takes no responsibility for any harm caused by believing otherwise.
Badgey Weather proudly powered by one lawnmower engine and a 93 year old veteran who just won't quit.
The Badgey Weather service operates on your donations and the tears of the unvaccinated.
Weather by Badgey. Not the reporting. The actual weather. I can do what I want.
This report will self destruct in five seconds.
Any information contained within the above weather report is not safe for human consumption. In case of contact with eyes, please consult a medical professional.
I think your warp core is leaking.
Badgey tried to get this weather report approved by Starfleet, but Starfleet denies any knowledge of the existence or nonexistence of Badgey, and this made Badgey sad.
[end]