Add support for tvcal +n
authorMikael Berthe <mikael@lilotux.net>
Mon, 19 Apr 2010 00:31:05 +0200
changeset 37 9d7f19e4e4fe
parent 36 2aedd0749666
child 38 a51ddbce247b
Add support for tvcal +n
mcbot/cmds/tvcal.lua
--- a/mcbot/cmds/tvcal.lua	Sun Apr 18 23:51:22 2010 +0200
+++ b/mcbot/cmds/tvcal.lua	Mon Apr 19 00:31:05 2010 +0200
@@ -60,7 +60,7 @@
 
 local function tvcal_by_date (d)
     if not tvcaldata[d] then
-        return "No episode found for this date"
+        return "No episode found for this date ("..d..")"
     end
 
     local r = "Shows on " .. d .. ":\n"
@@ -106,6 +106,11 @@
         arg = os.date("%F")
     elseif arg == "tomorrow" then
         arg = os.date("%F", os.date("%s")+86400)
+    elseif arg:match("^%+%d+$") then
+        local n = tonumber(arg:match("^%+(%d+)$"))
+        if n < 60 then
+            arg = os.date("%F", os.date("%s")+86400*n)
+        end
     end
 
     if arg:match("^%d%d%d%d%-%d%d%-%d%d$") then