Merge branch 'master' of https://gitfub.space/Jmaa/memebot
This commit is contained in:
commit
311ac33807
29
main.lua
29
main.lua
|
@ -8,6 +8,8 @@ local CONFIG = require 'config'
|
||||||
if CONFIG.LUA_EXTRA_PATH then package.path = package.path .. CONFIG.LUA_EXTRA_PATH end
|
if CONFIG.LUA_EXTRA_PATH then package.path = package.path .. CONFIG.LUA_EXTRA_PATH end
|
||||||
if CONFIG.LUA_EXTRA_CPATH then package.cpath = package.cpath .. CONFIG.LUA_EXTRA_CPATH end
|
if CONFIG.LUA_EXTRA_CPATH then package.cpath = package.cpath .. CONFIG.LUA_EXTRA_CPATH end
|
||||||
|
|
||||||
|
local FARVEL_INTERVAL = 90
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Meme utils
|
-- Meme utils
|
||||||
|
|
||||||
|
@ -299,11 +301,23 @@ local function reverse (l0)
|
||||||
return l
|
return l
|
||||||
end
|
end
|
||||||
|
|
||||||
local COMP_SENTENCES = {
|
local COMP_SENTENCES do
|
||||||
'{A} er bedre end {B}',
|
local ORD_MED_ATTITYDE = {
|
||||||
'{A} er meget bedre end {B}',
|
bedre = 'positiv',
|
||||||
'{B} er dårligere end {A}',
|
dårligere = 'negativ'
|
||||||
}
|
hurtigere = 'positiv'
|
||||||
|
langsommere = 'negativt'
|
||||||
|
robust = 'positivt'
|
||||||
|
}
|
||||||
|
local COMP_SENTENCES = {}
|
||||||
|
for ord, attityde in pairs(ORD_MED_ATTITYDE) do
|
||||||
|
local first, second = '{A}', '{B}'
|
||||||
|
if attityde == 'negativ' then first, second = second, first end
|
||||||
|
for _, fmt in ipairs { '%s er %s end %s', '%s er mere %s end %s', '%s er meget %s end %s', '%s %s end %s' } do
|
||||||
|
table.insert(COMP_SENTENCES, fmt:format(first, ord, second))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for sentence_i, sentence in ipairs(COMP_SENTENCES) do
|
for sentence_i, sentence in ipairs(COMP_SENTENCES) do
|
||||||
local A_pos, B_pos = sentence:find '{A}', sentence:find '{B}'
|
local A_pos, B_pos = sentence:find '{A}', sentence:find '{B}'
|
||||||
|
@ -376,6 +390,8 @@ local function escape_pattern (text)
|
||||||
return text:gsub('[+-?*]', '%%%1')
|
return text:gsub('[+-?*]', '%%%1')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local FORRIGE_FARVEL = 0
|
||||||
|
|
||||||
local function handle_message(bot, user, channel, message)
|
local function handle_message(bot, user, channel, message)
|
||||||
-- Direct commands
|
-- Direct commands
|
||||||
if message:lower():match('^'..escape_pattern(BOT_NICK)..'%f[%A]') then
|
if message:lower():match('^'..escape_pattern(BOT_NICK)..'%f[%A]') then
|
||||||
|
@ -398,6 +414,7 @@ local function handle_message(bot, user, channel, message)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Farvel msg
|
-- Farvel msg
|
||||||
|
if FORRIGE_FARVEL + FARVEL_INTERVAL < os.time() then
|
||||||
for farvel_fmt, possible_answeres in pairs(FARVEL) do
|
for farvel_fmt, possible_answeres in pairs(FARVEL) do
|
||||||
if message:match('%f[%a]'..farvel_fmt..'%f[%A]') then
|
if message:match('%f[%a]'..farvel_fmt..'%f[%A]') then
|
||||||
human_delay()
|
human_delay()
|
||||||
|
@ -405,9 +422,11 @@ local function handle_message(bot, user, channel, message)
|
||||||
.. (math.random() < 0.5 and ', '..user.nick or '')
|
.. (math.random() < 0.5 and ', '..user.nick or '')
|
||||||
.. (math.random() < 0.5 and '!' or '')
|
.. (math.random() < 0.5 and '!' or '')
|
||||||
bot:sendChat(channel, answer)
|
bot:sendChat(channel, answer)
|
||||||
|
FORRIGE_FARVEL = os.time()
|
||||||
return 'SES'
|
return 'SES'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Comparison memes
|
-- Comparison memes
|
||||||
local topics = get_topics_from_comparison_message(message)
|
local topics = get_topics_from_comparison_message(message)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user