Zu viele Änderungen, die ich nicht alle einzeln aufzählen möchte ._.
This commit is contained in:
@ -225,6 +225,7 @@ function create_cred()
|
||||
owm_apikey = "",
|
||||
page2images_restkey = "",
|
||||
soundcloud_client_id = "",
|
||||
tumblr_api_key = "",
|
||||
tw_consumer_key = "",
|
||||
tw_consumer_secret = "",
|
||||
tw_access_token = "",
|
||||
|
@ -663,8 +663,80 @@ function cache_data(plugin, query, data, timeout, typ)
|
||||
redis:expire(hash, timeout)
|
||||
end
|
||||
|
||||
--[[
|
||||
Ordered table iterator, allow to iterate on the natural order of the keys of a
|
||||
table.
|
||||
-- http://lua-users.org/wiki/SortedIteration
|
||||
]]
|
||||
|
||||
function __genOrderedIndex( t )
|
||||
local orderedIndex = {}
|
||||
for key in pairs(t) do
|
||||
table.insert( orderedIndex, key )
|
||||
end
|
||||
table.sort( orderedIndex )
|
||||
return orderedIndex
|
||||
end
|
||||
|
||||
function orderedNext(t, state)
|
||||
-- Equivalent of the next function, but returns the keys in the alphabetic
|
||||
-- order. We use a temporary ordered key table that is stored in the
|
||||
-- table being iterated.
|
||||
|
||||
key = nil
|
||||
--print("orderedNext: state = "..tostring(state) )
|
||||
if state == nil then
|
||||
-- the first time, generate the index
|
||||
t.__orderedIndex = __genOrderedIndex( t )
|
||||
key = t.__orderedIndex[1]
|
||||
else
|
||||
-- fetch the next value
|
||||
for i = 1,table.getn(t.__orderedIndex) do
|
||||
if t.__orderedIndex[i] == state then
|
||||
key = t.__orderedIndex[i+1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if key then
|
||||
return key, t[key]
|
||||
end
|
||||
|
||||
-- no more value to return, cleanup
|
||||
t.__orderedIndex = nil
|
||||
return
|
||||
end
|
||||
|
||||
function orderedPairs(t)
|
||||
-- Equivalent of the pairs() function on tables. Allows to iterate
|
||||
-- in order
|
||||
return orderedNext, t, nil
|
||||
end
|
||||
|
||||
-- converts total amount of seconds (e.g. 65 seconds) to human redable time (e.g. 1:05 minutes)
|
||||
function makeHumanTime(totalseconds)
|
||||
local seconds = totalseconds % 60
|
||||
local minutes = math.floor(totalseconds / 60)
|
||||
local minutes = minutes % 60
|
||||
local hours = math.floor(totalseconds / 3600)
|
||||
if minutes == 00 and hours == 00 then
|
||||
return seconds..' Sekunden'
|
||||
elseif hours == 00 and minutes ~= 00 then
|
||||
return string.format("%02d:%02d", minutes, seconds)..' Minuten'
|
||||
elseif hours ~= 00 then
|
||||
return string.format("%02d:%02d:%02d", hours, minutes, seconds)..' Stunden'
|
||||
end
|
||||
end
|
||||
|
||||
function is_blacklisted(msg)
|
||||
_blacklist = redis:smembers("telegram:img_blacklist")
|
||||
local var = false
|
||||
for v,word in pairs(_blacklist) do
|
||||
if string.find(string.lower(msg), string.lower(word)) then
|
||||
print("Wort steht auf der Blacklist!")
|
||||
var = true
|
||||
break
|
||||
end
|
||||
end
|
||||
return var
|
||||
end
|
Reference in New Issue
Block a user