From d3801b48e09177b07e408e6b350d0c29e2a4b963 Mon Sep 17 00:00:00 2001 From: Izwzyzx <184772711+Izwzyzx@users.noreply.github.com> Date: Sun, 10 Nov 2024 22:19:47 -0600 Subject: [PATCH] Added new aliases --- CHANGELOG.md | 1 + Onequestionmark.hx | 58 +++++++++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69045de..d22015d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Release Version 1.2 +- New aliases: `?fineart`, `?artishard`, `?indeed`, `?florida`, `?stop` - Added YouTube search command - Fixed reconnection starting duplicate timers - Added system to prevent MOTD from chosing the same daily result consecutively diff --git a/Onequestionmark.hx b/Onequestionmark.hx index 92f9f28..6269959 100644 --- a/Onequestionmark.hx +++ b/Onequestionmark.hx @@ -10,7 +10,7 @@ import izzcomlib.IzzComLib.*; using StringTools; class Onequestionmark { - // Initialize vars + // Initialize vars static var Bot:DiscordClient; static var settings:Dynamic; static var botInfo:Dynamic; @@ -27,7 +27,7 @@ class Onequestionmark { static var timerInit:Bool = false; - static function main() { + static function main() { Sys.println('[${timestamp()}] Starting onequestionmark-chat'); @@ -78,17 +78,17 @@ class Onequestionmark { saveSystem(); // Start the bot - Bot = new DiscordClient(settings.token, [3276799], settings.debug); - Bot.onReady = onReady; - Bot.onMessageCreate = onMessageCreate; + Bot = new DiscordClient(settings.token, [3276799], settings.debug); + Bot.onReady = onReady; + Bot.onMessageCreate = onMessageCreate; Bot.connect(); - } + } /** * The `onReady()` function is run upon a successful `Bot.connect()` */ - public static function onReady() { + public static function onReady() { Sys.sleep(1); Sys.println('[${timestamp()}] Bot is online'); @@ -103,16 +103,16 @@ class Onequestionmark { timerInit = true; startMotd(); } - } + } /** * 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) { + public static function onMessageCreate(m:Message) { // DevMode check - if ((!settings.devmode) || (m.guild_id == settings.devserver)) { + if ((!settings.devmode) || (m.guild_id == settings.devserver)) { var msg = m.content; var sender:String; if (m.getMember().nick == null) {sender = m.author.global_name;} else {sender = m.getMember().nick;} @@ -311,6 +311,16 @@ class Onequestionmark { m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1147590229960691742/communism.gif"}, false); case "opinions": m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1147983375701921892/opinions.jpg"}, false); + case "fineart": + m.reply({content:"https://cdn.discordapp.com/attachments/270113422232911883/423323629116325898/unknown.png"}, false); + case "artishard": + m.reply({content:"https://cdn.discordapp.com/attachments/270113422232911883/356638565834424330/tumblr_nrxhzoF0KM1t75ioqo2_250.jpg"}, false); + case "indeed": + m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1305252892491649145/indeed.gif"}, false); + case "florida": + m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1305253566348529696/florida.gif"}, false); + case "stop": + m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1305253985036275712/stop.jpg"}, false); // Image database commands case "hug": if (hugDB.length > 0) { @@ -369,7 +379,7 @@ class Onequestionmark { if ((iceRegex.match(msg)) && (m.author.id != botInfo.id)) {m.reply({content:"Did some carbon-based lifeform just say **I C E**?"});} if ((m.mention_everyone == true) && (msg.charAt(0) != "?")) {m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1147598637241741343/at_everyone.jpg"}, true);} } - } + } /** @@ -398,7 +408,7 @@ class Onequestionmark { // Start the looped MOTD timer motdTimer = new Timer(86400000); - motdTimer.run = function() { + motdTimer.run = function() { settings.motd.date = datestamp(); postMotd(); saveQueue.push("settings"); @@ -472,16 +482,16 @@ class Onequestionmark { /** - * This function performs a YouTube search and replies with the first result. - * @param m The message data. - * @param query The string to search. - */ + * This function performs a YouTube search and replies with the first result. + * @param m The message data. + * @param query The string to search. + */ public static function ytlookup(m:Message,query:String) { var http = new haxe.Http('https://www.youtube.com/results?search_query=${query.urlEncode()}'); - Sys.println('[${timestamp()}] ytlookup: URL - https://www.youtube.com/results?search_query=${query.urlEncode()}'); + Sys.println('[${timestamp()}] ytlookup: URL - https://www.youtube.com/results?search_query=${query.urlEncode()}'); http.onData = function (request) { - File.saveContent("export/ytlookup_result.txt", request); + File.saveContent("export/ytlookup_result.txt", request); var data = new HtmlDocument(request); var search = data.find("script"); // YouTube obfuscates everything into JS garbage so we have to check every