dailies 1.1

This commit is contained in:
Adrian Malacoda 2018-04-29 17:47:25 -05:00
parent af59c8d360
commit a65c36ad9b
2 changed files with 85 additions and 14 deletions

View File

@ -27,17 +27,25 @@ function sleep (sec)
return os.execute("sleep " .. tonumber(sec))
end
while true do
sleep_duration = get_sleep_duration_sec()
print("sleep for " .. sleep_duration)
function run_dailies (dailies)
while true do
sleep_duration = get_sleep_duration_sec()
print("sleep for " .. sleep_duration)
if not sleep(sleep_duration) then
print("sleep exited abnormally - break")
break
end
if not sleep(sleep_duration) then
print("sleep exited abnormally - break")
break
end
if get_weekday() == weekday then
print("send message " .. message)
sender:send({type = "message", channel = channel, message = message})
time_table = os.date("*t", os.time())
time_table.weekday = get_weekday()
for i, fn in dailies do
message = fn(time_table)
if message then
print("send message " .. message)
sender:send({type = "message", channel = channel, message = message})
break
end
end
end
end

View File

@ -1,12 +1,75 @@
[general]
foo = "bar"
[dailies]
type = "lua"
children = ["irc"]
file = "lua/dailies.lua"
hour = 8
minute = 0
second = 0
channel = "#eightbar"
code = """
function chrimbus (time)
if time.day == 25 and time.month == 12 then
return "https://i.imgur.com/cDiJxrV.gif"
end
end
function februaryween (time)
if time.day == 14 and time.month == 2 then
return "http://s3images.coroflot.com/user_files/individual_files/302239_CauyLQoHZTkSJkkGnr3kVbFtw.jpg"
end
end
function monday (time)
if time.weekday == "monday" then
return "https://memegenerator.net/img/instances/66733493/you-dont-hate-mondays-you-hate-capitalism.jpg"
end
end
function tuesday (time)
if time.weekday == "tuesday" then
return "https://78.media.tumblr.com/996c6866874691590558dce00b394416/tumblr_nxyfp54u121rp1193o1_1280.png"
end
end
function wednesday (time)
if time.weekday == "wednesday" then
return "http://i0.kym-cdn.com/photos/images/original/001/091/264/665.jpg"
end
end
function thursday (time)
if time.weekday == "thursday" then
if time.day == 20 then
return "http://i1.kym-cdn.com/photos/images/newsfeed/001/245/590/bd8.jpg"
else
return "https://78.media.tumblr.com/b05de5acb40dfb4eca044526eed5bbfa/tumblr_inline_p59be6mrQp1scg9wt_540.png"
end
end
end
function friday (time)
if time.weekday == "friday" then
if time.day == 13 then
return "https://www.youtube.com/watch?v=9cPDdQs7iHs"
else
return "https://www.youtube.com/watch?v=kfVsfOSbJY0"
end
end
end
run_dailies({chrimbus, februaryween, monday, tuesday, wednesday, thursday, friday})
"""
[irc]
nickname = "tenquestionmarks2"
server = "irc.rizon.net"
channels = ["#eightbar"]
[discord]
token = "your token here"
#[discord]
#token = "your token here"
[stdin]
@ -120,11 +183,11 @@ parents = ["stdin", "discord", "irc"]
[icced]
type = "random"
parents = ["stdin", "discord", "irc"]
pattern = "\\bicc?ed?\\b"
pattern = "(?i)\\bicc?ed?\\b"
responses = ["Did some carbon-based lifeform just say **I C E**?"]
[trout]
type = "random"
parents = ["stdin", "discord", "irc"]
pattern = "^?slap (.*)"
pattern = "^\\?slap (.*)"
responses = ["/me slaps $1 around a bit with a large trout", "/me slaps $1 around a bit with a large brick"]