From 7d5bf90c77ba0b2f4c219aca9382e075c8019b7c Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sat, 9 Jun 2018 15:34:38 +0200 Subject: [PATCH] =?UTF-8?q?Tilf=C3=B8jede=20at=20botten=20kan=20introducer?= =?UTF-8?q?e=20sig=20selv,=20hvis=20spurgt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.lua | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/main.lua b/main.lua index 705b988..3224261 100644 --- a/main.lua +++ b/main.lua @@ -175,7 +175,7 @@ local function paste_topic_onto_image (target, topic, x, y, w, h, bg_color, font -- Convert svg to png if url:match '%.svg$' then local filename_2 = CONFIG.IMGGEN_PATH_OUTPUT..'topic_'..topic.topic..'.'..'png' - os.execute('convert -density 1200 -resize 400x400 '..filename..' '..filename_2) + os.execute('convert -density "1200" -resize 400x400 "'..filename..'" "'..filename_2..'"') filename = filename_2 end -- @@ -488,6 +488,7 @@ end local FORRIGE_FARVEL = 0 local FORRIGE_MEME = 0 +local BOT_INTRODUCTION = [[Jeg er %s, en eksperimentel meme-robot, designet til at sprede memes. Er dog lidt sky, så kan ikke aflsøre mine memes, du må bare lede.]] local function handle_message(bot, user, channel, message, is_slow_channel) -- Direct commands @@ -495,7 +496,7 @@ local function handle_message(bot, user, channel, message, is_slow_channel) local msg = message:sub(#CONFIG.IRC_NICK+1) if msg:match '^%s*join%s+(#..-)%s*$' then local channel = msg:match '^%s*join%s+(#..-)%s*$' - bot:sendChat(channel, "Will do! I'll join "..tostring(channel)) + bot:sendChat(channel, "Det kan du tro! Jeg skal nok lige kigge indenom "..tostring(channel)) join_channel(channel) else bot:sendChat(channel, ERROR_MSG[math.random(#ERROR_MSG)]) @@ -518,6 +519,14 @@ local function handle_message(bot, user, channel, message, is_slow_channel) end end + -- Bot introduction + if message:lower():match('%f[%a]hvem%f[%A]') and (message:lower():match('%f[%a]'..escape_pattern(CONFIG.IRC_NICK)..'%f[%A]') or message:lower():match '%f[%a]du%f[%A]') then + human_delay() + local msg = BOT_INTRODUCTION:format(CONFIG.IRC_NICK) + bot:sendChat(channel, msg) + return 'INTRO' + end + -- Rest of this function is memes -- Memes are restricted, a bit. if is_slow_channel then @@ -532,18 +541,25 @@ local function handle_message(bot, user, channel, message, is_slow_channel) return 'BAIT' end + -- Meme machine + if message:match '%f[%a]meme%s+machine%f[%A]' then + human_delay() + bot:sendChat(channel, 'https://www.youtube.com/watch?v=wl-LeTFM8zo') + return 'MACHINE' + end + -- Comparison memes local topics = get_topics_from_comparison_message(message) if not topics then return end - local topics = fill_in_topics_information(topics) local img_link, error_message -- - if #topics == 2 and math.random() <= 0.7 then + if #topics == 2 then img_link, error_message = choose(GENERATE_COMPARISON_MEME_OF_2)(topics) else + assert(#topics >= 3) img_link, error_message = generate_brain_explosion_image(topics) end -- @@ -552,7 +568,7 @@ local function handle_message(bot, user, channel, message, is_slow_channel) else bot:sendChat(channel, 'Sorry, no can do. '..tostring(error_message)..'.') end - return 'BRAIN' + return 'COMPAR' end local DEBUG_CHANNEL = '#bot-test' @@ -603,6 +619,7 @@ local BOT_FAREWELL = { 'Jeg keder mig.' } + local function shutdown_memebot () -- Leave channels for channel in pairs(ACTIVE_CHANNELS) do