diff --git a/CHANGELOG.md b/CHANGELOG.md index 46ae36d..17a4c23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,17 @@ # Changelog +## Release Version 1.2 +- General purpose functions have been split off into IzzComLib +- Improved fallbacks for file-reading commands +- Data files for the official instance have been split into a separate repo + ## Release Version 1.1 - Echobox - - Check whether the message is already in the database - - Make sure it doesn't say what was just added - - Prevent adding `@everyone` or other mentions to the echobox -- Change shutdown message to reaction -- Update MOTD to support exact dates + - Checks whether the message is already in the database + - Makes sure it doesn't say what was just added + - Prevents adding `@everyone` or other mentions to the echobox +- Changed shutdown message to reaction +- Updated MOTD to support exact dates - Optional startup message supplied by program args - New aliases - `?illuminati` @@ -21,10 +26,9 @@ - `?dice` - Rolls a 6-sided die (default) or takes input on size - `?coin` - Flips a coin (default) or takes input on number of coins to flip - `?8ball` - Standard "fortune telling" - - Fix issue if user doesn't have a nickname set -- Add new file saving queue system -- Update `?help` with new features - - Use Embed Builder for nicer-looking display + - Fixed issue if user doesn't have a nickname set +- Added new file saving queue system +- Updated `?help` with new features, using Embed Builder for nicer-looking display ## Release Version 1.0 (Minimum Viable Product) - Save / Load settings from file diff --git a/Onequestionmark.hx b/Onequestionmark.hx index de44fea..62b146f 100644 --- a/Onequestionmark.hx +++ b/Onequestionmark.hx @@ -76,6 +76,10 @@ class Onequestionmark { Bot.connect(); } + + /** + * The `onReady()` function is run upon a successful `Bot.connect()` + */ public static function onReady() { Sys.sleep(1); Sys.println('[${timestamp()}] Bot is online'); @@ -91,6 +95,10 @@ class Onequestionmark { MainLoop.add(saveSystem); } + + /** + * The `onMessageCreate()` event provides the bulk of onequestionmark's functionality. This is what triggers when a new Discord message is received, and contains the bot's command processor. + */ public static function onMessageCreate(m:Message) { // DevMode check if ((!settings.devmode) || (m.guild_id == settings.devserver)) { @@ -155,8 +163,6 @@ class Onequestionmark { } // Basic response commands case "help": - /*m.reply({content:' - **onequestionmark bot commands**\n`?chk`: ack\n`?slap `: The classic mIRC troutslap.\n`?hug `: Posts randomized hug image.\n`?yes` and `?no`: Posts randomized yes/no.\n`?angery`\n`?subway`\n`?motd`: Enables MOTD for current channel (requires auth)\n`?devmode`: Toggles Dev Mode (requires auth)\n`?quit`: Shutdown command (requires auth)\n**Non-command bot functions:**\n*MOTD*: Bot will post a randomized *Meme of the Day* in enabled channels.\n*Icce*: Bot provides users with ice cuboids.\n*Meteor*: Bot reacts to falling rocks in the chat.'}, false);*/ m.reply({embeds: [ { "color": 13733022, @@ -336,7 +342,10 @@ class Onequestionmark { } } - // MOTD system + + /** + * This function controls the "Meme of the Day" system. + */ public static function motd() { if (settings.motd.date != datestamp()) { settings.motd.date = datestamp(); @@ -375,7 +384,12 @@ class Onequestionmark { } } - // Filesystem operations + + /** + * The `saveSystem()` function handles all filesystem writes. When the bot needs to save a file, it pushes data to the `saveQueue` array. + * The save system checks the queue regularly and operates on the first entry provided. + * This throttles filesystem access, to prevent multiple commands from writing to the drive at the same time. + */ public static function saveSystem() { if (saveTimer != Date.now().getMinutes()) { // We only want to run this once a minute @@ -394,14 +408,26 @@ class Onequestionmark { } } + + /** + * Writes the modified `settings.json` from memory back to the drive. + */ public static function saveSettings() { File.saveContent("settings.json", Json.stringify(settings, "\t")); } + + /** + * Writes the modified `echobox-db.json` from memory back to the drive. + */ public static function saveEchoboxDB() { File.saveContent("echobox-db.json", Json.stringify(echoboxDB, "\t")); } + + /** + * Performs a clean shutdown of the bot, after saving relevant files to the disk. + */ public static function shutdown() { saveSettings(); saveEchoboxDB();