2016-07-07 21:34:32 +02:00
|
|
|
do
|
|
|
|
|
2015-11-12 17:42:03 +01:00
|
|
|
local function get_value(msg, var_name)
|
|
|
|
local hash = 'telegram:birthdays'
|
|
|
|
if hash then
|
|
|
|
local value = redis:hget(hash, var_name)
|
|
|
|
if not value then
|
2016-07-07 21:34:32 +02:00
|
|
|
return'Geburtstag nicht gefunden, benutze "#getbd", um alle Geburtstage aufzulisten.'
|
2015-11-12 17:42:03 +01:00
|
|
|
else
|
|
|
|
return var_name..' hat am '..value..' Geburtstag'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function list_variables(msg)
|
|
|
|
local hash = 'telegram:birthdays'
|
|
|
|
|
|
|
|
if hash then
|
2016-07-07 21:34:32 +02:00
|
|
|
print('Suche nach Geburtstag in '..hash)
|
2015-11-12 17:42:03 +01:00
|
|
|
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 'Keine Geburtstage vorhanden!'
|
|
|
|
else
|
|
|
|
return text
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function run(msg, matches)
|
|
|
|
if matches[2] then
|
|
|
|
return get_value(msg, matches[2])
|
|
|
|
else
|
|
|
|
return 'Geburtstagsliste:\n\n'..list_variables(msg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
2016-07-07 21:34:32 +02:00
|
|
|
description = "Zeigt Geburtstage, die mit #setbd gesetzt wurden",
|
2015-11-12 17:42:03 +01:00
|
|
|
usage = {
|
2016-06-22 13:59:06 +02:00
|
|
|
"#getbd: Gibt alle Geburtstage aus",
|
2016-07-07 21:34:32 +02:00
|
|
|
"#getbd (Name): Gibt ein spezifischen Geburtstag aus."
|
2015-11-12 17:42:03 +01:00
|
|
|
},
|
|
|
|
patterns = {
|
2016-07-07 21:34:32 +02:00
|
|
|
"^(#[Gg][Ee][Tt][Bb][Dd]) (.+)$",
|
|
|
|
"^#[Gg][Ee][Tt][Bb][Dd]$"
|
2015-11-12 17:42:03 +01:00
|
|
|
},
|
|
|
|
run = run
|
2016-07-07 21:34:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
--by Akamaru [https://ponywave.de]
|
|
|
|
|
|
|
|
end
|