Upstream # 97c3e6be von Brawlbot

This commit is contained in:
2015-12-05 21:36:56 +01:00
parent d243c5db9c
commit 60925fa6dd
4 changed files with 40 additions and 11 deletions

View File

@ -2,7 +2,7 @@ package.path = './.luarocks/share/lua/5.2/?.lua;./.luarocks/share/lua/5.2/?/init
require("luarocks.loader")
require("./bot/utils")
VERSION = '20151112'
VERSION = '20151205'
-- This function is called when tg receive a msg
function on_msg_receive (msg)

View File

@ -640,4 +640,17 @@ function get_location(user_id)
else
return set_location
end
end
function cache_data(plugin, query, data, timeout, typ)
-- How to: cache_data(pluginname, query_name, data_to_cache, expire_in_seconds)
if not timeout then timeout = 86400 end
local hash = 'telegram:cache:'..plugin..':'..query
print('Caching "'..query..'" from plugin '..plugin..' (expires in '..timeout..' seconds)')
if typ == 'key' then
redis:set(hash, data)
else
redis:hmset(hash, data)
end
redis:expire(hash, timeout)
end