text_set und text_gut wurden nun auf basis des zitate plugins zusammengeführt
This commit is contained in:
42
plugins/pluginsold/text_get.lua
Normal file
42
plugins/pluginsold/text_get.lua
Normal file
@ -0,0 +1,42 @@
|
||||
local function get_value(msg, var_name)
|
||||
local hash = 'telegram:savedtext'
|
||||
if hash then
|
||||
local value = redis:hget(hash, var_name)
|
||||
if not value then
|
||||
return ""
|
||||
else
|
||||
return var_name..' '..value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function list_variables(msg)
|
||||
local hash = 'telegram:savedtext'
|
||||
|
||||
if hash then
|
||||
print('Getting variable from redis hash '..hash)
|
||||
local names = redis:hkeys(hash)
|
||||
local text = ''
|
||||
for i=1, #names do
|
||||
variables = get_value(msg, names[i])
|
||||
text = text..variables.."\n"
|
||||
end
|
||||
if text == '' or text == nil then
|
||||
return ""
|
||||
else
|
||||
return text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function run(msg, matches)
|
||||
return list_variables(msg)
|
||||
end
|
||||
|
||||
return {
|
||||
description = "",
|
||||
usage = {},
|
||||
patterns = {"^/save$"},
|
||||
run = run,
|
||||
privileged = true
|
||||
}
|
Reference in New Issue
Block a user