Epic Calendar inside the MUD!

Contrast_Picker
Arcidayne 9 years ago
parent 0ec71d40d1
commit c0268d529c

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, September 10, 2015, 11:08 PM -->
<!-- MuClient version 4.98 -->
<!-- Plugin "Epic_Calender" generated by Plugin Wizard -->
<muclient>
<plugin
name="Epic_Calendar"
author="Arcidayne"
id="b14b904695ffa4f7c77ba823"
language="Lua"
purpose="Shows upcoming Epic Runs"
save_state="y"
date_written="2015-09-10 23:06:41"
requires="4.00"
version="1.0"
>
</plugin>
<!-- Aliases -->
<aliases>
<alias
match="^getcal(.*?)$"
enabled="y"
group="EpicTracking"
regexp="y"
send_to="12"
sequence="100"
>
<send>if "%1" == "" then
ColourNote("white","","======================== How To Use =======================\\n\\ngetcal &lt;if/icefall|inferno|oc|all&gt;\\n\\n===========================================================")
else
get_cal("%1")
end</send>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
-- [[Many thanks to Shaelynne for keeping everyone up-to-date with the Epic Calendars! ]]--
function date_check(dateTime)
local xyear, xmonth, xday = string.match(dateTime,"(%d+)%-(%d+)%-(%d+)")
local xhour, xmin = string.match(dateTime,"%a(%d+):(%d+)")
if (os.time()-os.time({year = xyear, month = xmonth, day = xday, hour = xhour or 23, min = xmin or 59, sec = 0})) < 0 then
return true
else
return false
end
end
function date_format(dateTime)
local xyear, xmonth, xday = string.match(dateTime,"(%d+)%-(%d+)%-(%d+)")
local xhour, xmin = string.match(dateTime,"%a(%d+):(%d+)")
return os.date ("%A, %B %d %Y at %I:%M%p", os.time({year = xyear, month = xmonth, day = xday, hour = xhour or 0, min = xmin or 0, sec = 0}))
end
function date_note(dateTime)
if string.match(dateTime, "%a%d+:%d+") then
return ""
else
return "Note: No start time given, may have already ran."
end
end
function get_cal(epic)
async_ok, async = pcall (require, "async")
json = require 'json'
require('tprint')
local cal_output = {}
local epic_list, key = "if icefall inferno oc all", "AIzaSyAHEnr8iiK42hzM21pXSbTrBIQ2ezEEUHA"
if string.match(epic_list, epic:lower()) then
if epic:lower() == "icefall" or epic:lower() == "if" then
calid = "h8jf8vbgsl0in0nmg3vj06r9g4%40group.calendar.google.com"
elseif epic:lower() == "inferno" then
calid = "p8est01hkro1bol0bqfsvfm41o%40group.calendar.google.com"
elseif epic:lower() == "oc" then
calid = "olvq8lncvoufh24b30ml9h2mio%40group.calendar.google.com"
else
calid = "shaelynne22%40gmail.com"
end
rpage = "https://www.googleapis.com/calendar/v3/calendars/" .. calid .. "/events?key=" .. key
if async_ok then
epage = async.request(rpage,"HTTPS")
end
retval, page, status, headers, full_status = epage:join()
epage = nil
if status == 200 then
epage = json.decode(page)
end
for i = 1, #epage.items do
local starttime, summary = "", ""
if epage.items[i].start.date then
starttime = epage.items[i].start.date
else
starttime = epage.items[i].start.dateTime
end
if #epage.items[i].summary < 20 then
summary = epage.items[i].summary .. string.rep(" ", 20-#epage.items[i].summary) .. "- "
else
summary = epage.items[i].summary .. "- "
end
if date_check(starttime) then
table.insert(cal_output, summary .. date_format(starttime) .. " " .. date_note(starttime))
end
end
if cal_output[1] then
ColourNote("white","","================= Upcoming Runs (MUD time) ================\n\n" .. table.concat(cal_output,"\n") .. "\n\n===========================================================")
else
ColourNote("white","","================= Upcoming Runs (MUD time) ================\n\nNo upcoming runs for " .. epic .. "!\n\n===========================================================")
end
else
ColourNote("white", "", "======================== EpicError ========================\n\nNot a valid calendar choice (IF/Icefall, Inferno, OC, All)\n\n===========================================================")
end
end
]]>
</script>
</muclient>
Loading…
Cancel
Save