-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quote.lua
41 lines (30 loc) · 1.09 KB
/
Quote.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function Initialize()
path = SKIN:GetVariable('CURRENTPATH')
json = dofile(path..'dkjson.lua')
html = dofile(path..'htmlEntities/src/htmlEntities.lua')
end -->Initialize
function Update()
now = os.date('%H_%M.json')
hour= os.date('%H/')
file = io.open(path..'times/'..hour..now, "rb")
if file then
content = file:read "*a"
file:close()
info = json.decode(content)
repeat
rand = math.random(1, #info)
until(info[rand]["sfw"] == "yes")
quote_time_case = info[rand]["quote_time_case"]
quote = info[rand]["quote_first"]..info[rand]["quote_time_case"]..info[rand]["quote_last"]
author = info[rand]["title"]..", "..info[rand]["author"]
quote = html.decode(quote)
else
quote_time_case = os.date('%H:%M')
quote = quote_time_case
author = ""
end
SKIN:Bang('!SetVariable', 'Time_Case', quote_time_case)
SKIN:Bang('!SetOption', 'MeterQuote', 'Text', quote)
SKIN:Bang('!SetOption', 'MeterAuthor', 'Text', author)
return
end -->Update