(gordon) Fix parsing

mio 2022-08-30 03:08:54 +00:00
parent cdf8bcade0
commit d157788de9
6 changed files with 29 additions and 22 deletions

View File

@ -1,5 +1,5 @@
grammar = { grammar = {
meatset = { meat_set = {
"360 Burger with a large patty, tomatos, cheddar and onions in a Dijon mustard sauce", "360 Burger with a large patty, tomatos, cheddar and onions in a Dijon mustard sauce",
"Bada Boom cheeseburger with a juicy steak, cheddar, onions and tomatos", "Bada Boom cheeseburger with a juicy steak, cheddar, onions and tomatos",
"Bag Baguette featuring two patties and Emmental cheese in a long crusty baguette", "Bag Baguette featuring two patties and Emmental cheese in a long crusty baguette",
@ -23,14 +23,14 @@ grammar = {
"Super Bacon burger", "Super Bacon burger",
"Vast Veggie burger with a veggie patty and Emmental cheese", "Vast Veggie burger with a veggie patty and Emmental cheese",
}, },
veggieset = { veggie_set = {
"Veggie Thing overflowing with a spicy sauce", "Veggie Thing overflowing with a spicy sauce",
}, },
meatside = { meat_side = {
"chicken fries", "chicken fries",
"house fries with a mayonnaise dip", "house fries with a mayonnaise dip",
}, },
veggieside = { veggie_side = {
"chips deluged with potato sauce", "chips deluged with potato sauce",
"onion rings", "onion rings",
}, },
@ -40,11 +40,11 @@ grammar = {
"set of 3 petit pancakes topped with hazelnut cocoa or strawberry cream", "set of 3 petit pancakes topped with hazelnut cocoa or strawberry cream",
}, },
origin = { origin = {
"Here, have a #meatset# !", "Here, have a #meat_set#!",
"Here, have a #veggieset# !", "Here, have a #veggie_set#!",
"Here, have a #meatset# served with a side of #meatside# !", "Here, have a #meat_set# served with a side of #meat_side#!",
"Here, have a #meatset# served with a side of #veggieside# !", "Here, have a #meat_set# served with a side of #veggie_side#!",
"Here, have a #veggieset# served with a side of #veggieside# !", "Here, have a #veggie_set# served with a side of #veggie_side#!",
"Here, have a #meatset# served with a #dessert# !", "Here, have a #meat_set# served with a #dessert#!",
} }
} }

View File

@ -54,7 +54,7 @@ function folia.output(key)
end end
local output_str = util.pick(foils[key]["origin"])[1] local output_str = util.pick(foils[key]["origin"])[1]
local pattern = "#(%w+)#" local pattern = "#(%w+_*%-*%w+)#"
util.debug("output", "level 1: " .. output_str, folia.debug) util.debug("output", "level 1: " .. output_str, folia.debug)
-- Check for expansion objects and replace them until none are found -- Check for expansion objects and replace them until none are found
while string.find(output_str, pattern) ~= nil do while string.find(output_str, pattern) ~= nil do

View File

@ -4,26 +4,21 @@ local folia = require("folia")
itte_config = { itte_config = {
debug = false, debug = false,
messages = { messages = {
help = "Casa's Kitchen commands: {{codes}}", help = "Don't just stand there like a big f—ing muffin! " ..
quit = "Machef under maintenance.", "Order something! Your Casa's Kitchen commands are: {{codes}}",
quit = "Master Chef under maintenance.",
reload = "Config reloaded.", reload = "Config reloaded.",
}, },
} }
itte_handlers = {} itte_handlers = {}
folia.foils_dir = "/home/mio/bin/itte/examples/gordon/commands" folia.foils_dir = os.getenv("PWD") .. "/commands"
local gordon = {} local gordon = {}
-- Show help message
function itte_handlers.botland(cxt, msg)
irc._h.help(cxt, msg)
end
-- Create handlers for each foil -- Create handlers for each foil
function gordon.generate_handlers(handlers, foils_dir) function gordon.generate_handlers(handlers, foils_dir)
local foils = folia.get_foils(foils_dir) local foils = folia.get_foils(foils_dir)
@ -32,6 +27,18 @@ function gordon.generate_handlers(handlers, foils_dir)
irc.message(cxt, { msg.reply_to }, folia.output(key)) irc.message(cxt, { msg.reply_to }, folia.output(key))
end end
end end
-- Add aliases
if folia.output("burger") ~= nil then
itte_handlers.borgar = function (cxt, msg)
irc.message(cxt, { msg.reply_to }, folia.output("burger"))
end
end
if folia.output("coffee") ~= nil then
itte_handlers.cofe = function (cxt, msg)
irc.message(cxt, { msg.reply_to }, folia.output("coffee"))
end
end
end end

View File

@ -54,7 +54,7 @@ function folia.output(key)
end end
local output_str = util.pick(foils[key]["origin"])[1] local output_str = util.pick(foils[key]["origin"])[1]
local pattern = "#(%w+)#" local pattern = "#(%w+_*%-*%w+)#"
util.debug("output", "level 1: " .. output_str, folia.debug) util.debug("output", "level 1: " .. output_str, folia.debug)
-- Check for expansion objects and replace them until none are found -- Check for expansion objects and replace them until none are found
while string.find(output_str, pattern) ~= nil do while string.find(output_str, pattern) ~= nil do

View File

@ -16,7 +16,7 @@ itte_config = {
itte_handlers = {} itte_handlers = {}
folia.foils_dir = "/home/mio/bin/itte/examples/hachi/foils" folia.foils_dir = os.getenv("PWD") .. "/foils"
local hachi = {} local hachi = {}