--- a/mcbot/cmds/tvcal.lua Mon Apr 19 00:31:05 2010 +0200
+++ b/mcbot/cmds/tvcal.lua Mon Apr 19 10:20:28 2010 +0200
@@ -71,23 +71,24 @@
return r
end
-local function tvcal_by_name (name)
+local function tvcal_by_name (name, plain)
+ local action = plain and "contain" or "match"
local r = ""
name = name:lower()
for day, obj in pairsByKeys(tvcaldata) do
for i,j in ipairs(obj) do
- if j.name:lower():find(name, 1, true) then
+ if j.name:lower():find(name, 1, plain) then
r = r .. day .. "\t" .. j.name .. " (" ..j.ep .. ")\n"
end
end
end
if r == "" then
- return "No episode found containing this string"
+ return "No episode found "..action.."ing this string"
end
r = r:gsub("\n+$", "")
- return "Episodes containing \""..name.."\":\n" .. r
+ return "Episodes "..action.."ing \""..name.."\":\n" .. r
end
function tvcal.cmd (arg)
@@ -117,7 +118,15 @@
return tvcal_by_date(arg)
end
- return tvcal_by_name(arg)
+ -- Is it a pattern? (string surrounded by quotes)
+ local plain = arg:match('^"(.*)"$')
+ if plain then
+ arg = plain
+ plain = false
+ else
+ plain = true
+ end
+ return tvcal_by_name(arg, plain)
end
mcbot_register_command("tvcal", tvcal)