You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
158 lines
4.4 KiB
158 lines
4.4 KiB
<?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_Calendar" 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 <if/icefall|inferno|oc|all>\\n\\n===========================================================")
|
|
else
|
|
get_cal(string.gsub("%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)
|
|
|
|
if (os.time(os.date("!*t"))-dateTime) < 0 then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
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_tz_offset(dateTime, offset)
|
|
|
|
local xyear, xmonth, xday = string.match(dateTime,"(%d+)%-(%d+)%-(%d+)")
|
|
|
|
local xhour, xmin = string.match(dateTime,"%a(%d+):(%d+)")
|
|
|
|
local UTC_from_Eastern = os.time({year = xyear, month = xmonth, day = xday, hour = xhour or 23, min = xmin or 59, sec = 0}) + (offset*3600)
|
|
|
|
|
|
local UTC_time, local_time = os.time(os.date("!*t")), os.time()
|
|
local time_zone = os.difftime(local_time, UTC_time)
|
|
|
|
local converted_time = UTC_from_Eastern + time_zone
|
|
return converted_time
|
|
end
|
|
|
|
function get_cal(epic)
|
|
async_ok, async = pcall (require, "async")
|
|
json = require 'json'
|
|
require('tprint')
|
|
|
|
local cal_output = {}
|
|
local epic_list, key, calid = "all if icefall inferno oc", "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"
|
|
elseif epic:lower() == "all" then
|
|
calid = "shaelynne22%40gmail.com"
|
|
end
|
|
|
|
rpage = "https://www.googleapis.com/calendar/v3/calendars/" .. calid .. "/events?key=" .. key
|
|
tzpage = "http://wwp.greenwichmeantime.com/time/scripts/clock-8/runner.php?tz=america_cayman"
|
|
|
|
if async_ok then
|
|
epage = async.request(rpage,"HTTPS")
|
|
tpage = async.request(tzpage, "HTTP")
|
|
end
|
|
|
|
retval, page, status, headers, full_status = epage:join()
|
|
epage = nil
|
|
|
|
if status == 200 then
|
|
epage = json.decode(page)
|
|
end
|
|
|
|
retval, page, status, headers, full_status = tpage:join()
|
|
tpage = nil
|
|
|
|
if status == 200 then
|
|
tz_off = string.match(page,"%(GMT %-(%d):00%)")
|
|
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(get_tz_offset(starttime, tz_off)) then
|
|
table.insert(cal_output, summary .. os.date("%A, %B %d %Y at %I:%M%p",get_tz_offset(starttime, tz_off)) .. " " .. date_note(starttime))
|
|
end
|
|
end
|
|
if cal_output[1] then
|
|
ColourNote("white","","================ Upcoming Runs (Local time) ===============\n\n" .. table.concat(cal_output,"\n") .. "\n\n===========================================================")
|
|
else
|
|
ColourNote("white","","================ Upcoming Runs (Local 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
|
|
epage, tz_off = nil, nil
|
|
end
|
|
]]>
|
|
</script>
|
|
|
|
|
|
</muclient>
|