- Echo: Erlaube Markdown (nicht in Supergruppen)
- Entferne orderdPairs(), da .getn deprecated ist
This commit is contained in:
parent
fa1e5d73d2
commit
4cbe28ea93
@ -22,10 +22,8 @@ function echo:action(msg)
|
||||
local output
|
||||
if msg.chat.type == 'supergroup' then
|
||||
output = '*Echo:*\n"' .. utilities.md_escape(input) .. '"'
|
||||
else
|
||||
output = utilities.md_escape(utilities.char.zwnj..input)
|
||||
end
|
||||
utilities.send_message(self, msg.chat.id, output, true, nil, true)
|
||||
utilities.send_message(self, msg.chat.id, input, true, nil, true)
|
||||
end
|
||||
|
||||
|
||||
|
@ -706,56 +706,6 @@ function cache_data(plugin, query, data, timeout, typ)
|
||||
end
|
||||
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
|
||||
|
Reference in New Issue
Block a user