text_set und text_gut wurden nun auf basis des zitate plugins zusammengeführt
This commit is contained in:
45
plugins/pluginsold/text_set.lua
Normal file
45
plugins/pluginsold/text_set.lua
Normal file
@ -0,0 +1,45 @@
|
||||
local function save_value(msg, name, value)
|
||||
if (not name or not value) then
|
||||
return ""
|
||||
end
|
||||
|
||||
local hash = 'telegram:savedtext'
|
||||
if hash then
|
||||
print('Saving variable to redis hash '..hash)
|
||||
redis:hset(hash, name, value)
|
||||
return value.." gespeichert!"
|
||||
end
|
||||
end
|
||||
|
||||
local function delete_value(msg, name)
|
||||
local hash = 'telegram:savedtext'
|
||||
if redis:hexists(hash, name) == true then
|
||||
print('Deleting from redis hash '..hash)
|
||||
redis:hdel(hash, name)
|
||||
return value..' erfolgreich gelöscht!'
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
local function run(msg, matches)
|
||||
local name = string.sub(matches[1], 1, 50)
|
||||
local value = string.sub(matches[2], 1, 1000)
|
||||
|
||||
if value == "nil" then
|
||||
text = delete_value(msg, name, value)
|
||||
else
|
||||
text = save_value(msg, name, value)
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
||||
return {
|
||||
description = ".",
|
||||
usage = {},
|
||||
patterns = {
|
||||
"^/save ([^%s]+) (.+)$"
|
||||
},
|
||||
run = run ,
|
||||
privileged = true
|
||||
}
|
Reference in New Issue
Block a user