Tilføjede at botten kan introducere sig selv, hvis spurgt.
This commit is contained in:
parent
ae5ed523d0
commit
7d5bf90c77
27
main.lua
27
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
|
-- Convert svg to png
|
||||||
if url:match '%.svg$' then
|
if url:match '%.svg$' then
|
||||||
local filename_2 = CONFIG.IMGGEN_PATH_OUTPUT..'topic_'..topic.topic..'.'..'png'
|
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
|
filename = filename_2
|
||||||
end
|
end
|
||||||
--
|
--
|
||||||
|
@ -488,6 +488,7 @@ end
|
||||||
|
|
||||||
local FORRIGE_FARVEL = 0
|
local FORRIGE_FARVEL = 0
|
||||||
local FORRIGE_MEME = 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)
|
local function handle_message(bot, user, channel, message, is_slow_channel)
|
||||||
-- Direct commands
|
-- 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)
|
local msg = message:sub(#CONFIG.IRC_NICK+1)
|
||||||
if msg:match '^%s*join%s+(#..-)%s*$' then
|
if msg:match '^%s*join%s+(#..-)%s*$' then
|
||||||
local channel = msg:match '^%s*join%s+(#..-)%s*$'
|
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)
|
join_channel(channel)
|
||||||
else
|
else
|
||||||
bot:sendChat(channel, ERROR_MSG[math.random(#ERROR_MSG)])
|
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
|
||||||
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
|
-- Rest of this function is memes
|
||||||
-- Memes are restricted, a bit.
|
-- Memes are restricted, a bit.
|
||||||
if is_slow_channel then
|
if is_slow_channel then
|
||||||
|
@ -532,18 +541,25 @@ local function handle_message(bot, user, channel, message, is_slow_channel)
|
||||||
return 'BAIT'
|
return 'BAIT'
|
||||||
end
|
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
|
-- Comparison memes
|
||||||
local topics = get_topics_from_comparison_message(message)
|
local topics = get_topics_from_comparison_message(message)
|
||||||
if not topics then return end
|
if not topics then return end
|
||||||
|
|
||||||
|
|
||||||
local topics = fill_in_topics_information(topics)
|
local topics = fill_in_topics_information(topics)
|
||||||
|
|
||||||
local img_link, error_message
|
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)
|
img_link, error_message = choose(GENERATE_COMPARISON_MEME_OF_2)(topics)
|
||||||
else
|
else
|
||||||
|
assert(#topics >= 3)
|
||||||
img_link, error_message = generate_brain_explosion_image(topics)
|
img_link, error_message = generate_brain_explosion_image(topics)
|
||||||
end
|
end
|
||||||
--
|
--
|
||||||
|
@ -552,7 +568,7 @@ local function handle_message(bot, user, channel, message, is_slow_channel)
|
||||||
else
|
else
|
||||||
bot:sendChat(channel, 'Sorry, no can do. '..tostring(error_message)..'.')
|
bot:sendChat(channel, 'Sorry, no can do. '..tostring(error_message)..'.')
|
||||||
end
|
end
|
||||||
return 'BRAIN'
|
return 'COMPAR'
|
||||||
end
|
end
|
||||||
|
|
||||||
local DEBUG_CHANNEL = '#bot-test'
|
local DEBUG_CHANNEL = '#bot-test'
|
||||||
|
@ -603,6 +619,7 @@ local BOT_FAREWELL = {
|
||||||
'Jeg keder mig.'
|
'Jeg keder mig.'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local function shutdown_memebot ()
|
local function shutdown_memebot ()
|
||||||
-- Leave channels
|
-- Leave channels
|
||||||
for channel in pairs(ACTIVE_CHANNELS) do
|
for channel in pairs(ACTIVE_CHANNELS) do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user