diff --git a/bot.lua b/bot.lua index 1833cf3..3d81f4a 100755 --- a/bot.lua +++ b/bot.lua @@ -30,7 +30,7 @@ function on_msg_receive(msg) v.action(msg) end) if not a then - print('',msg.text,'\n',b) -- For debugging purposes. + print('',msg.text,'\n',b) -- debugging send_msg(msg, b) end end @@ -77,7 +77,6 @@ function bot_init() print('@'.. bot.username ..', AKA '.. bot.first_name ..' ('.. bot.id ..')') is_started = true - counter = {} end @@ -105,6 +104,7 @@ end bot_init() last_update = 0 +last_cron = os.time() while is_started do @@ -122,13 +122,14 @@ while is_started do -- cron-like thing -- run PLUGIN.cron() every five seconds - if os.date('%S', os.time()) % 5 == 0 then -- Only check every five seconds. + if last_cron < os.time() - 5 then for k,v in pairs(plugins) do if v.cron then a,b = pcall(function() v.cron() end) if not a then print(b) end end end + last_cron = os.time() end end diff --git a/config.lua.default b/config.lua.default index ca1965b..52f924a 100755 --- a/config.lua.default +++ b/config.lua.default @@ -23,6 +23,7 @@ return { 'imdb.lua', 'urbandictionary.lua', 'spotify.lua', + 'youtube.lua', 'kickass.lua', 'hackernews.lua', 'cats.lua', diff --git a/plugins/youtube.lua b/plugins/youtube.lua old mode 100644 new mode 100755 index 872275f..3f9d402 --- a/plugins/youtube.lua +++ b/plugins/youtube.lua @@ -3,8 +3,8 @@ local PLUGIN = {} PLUGIN.doc = [[ - /youtube [term]: Search for a youtube video and send it. - Search video on youtube and send it. + /youtube + Search videos on YouTube. ]] PLUGIN.triggers = {