2016-08-02 16:19:20 +02:00
|
|
|
local settings = {}
|
|
|
|
|
|
|
|
settings.triggers = {
|
|
|
|
"^(⚙ [Ee]instellungen)$",
|
|
|
|
"^(/settings)$",
|
2016-08-12 00:44:39 +02:00
|
|
|
"^(💤 [Aa][Ff][Kk]%-[Kk]eyboard einschalten)",
|
|
|
|
"^(💤 [Aa][Ff][Kk]%-[Kk]eyboard ausschalten)",
|
|
|
|
"^(❌ [Ee]instellungen verstecken)"
|
2016-08-02 16:19:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
--[[
|
|
|
|
|
|
|
|
[
|
|
|
|
[ "Top Left", "Top Right" ],
|
|
|
|
[ "Bottom Left", "Bottom Right" ]
|
|
|
|
]
|
|
|
|
|
|
|
|
]]
|
|
|
|
|
|
|
|
function settings:keyboard(user_id)
|
|
|
|
if redis:hget('user:'..user_id, 'afk_keyboard') == 'true' then
|
|
|
|
afk_button = '{"text":"💤 AFK-Keyboard ausschalten"}'
|
|
|
|
else
|
|
|
|
afk_button = '{"text":"💤 AFK-Keyboard einschalten"}'
|
|
|
|
end
|
|
|
|
local hide_settings_button = '{"text":"❌ Einstellungen verstecken"}'
|
|
|
|
|
2016-08-12 00:44:39 +02:00
|
|
|
local settings_keyboard = '[['..afk_button..','..hide_settings_button..']]'
|
2016-08-02 16:19:20 +02:00
|
|
|
return settings_keyboard
|
|
|
|
end
|
|
|
|
|
|
|
|
function settings:action(msg, config, matches)
|
|
|
|
if msg.chat.type ~= "private" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local hash = 'user:'..msg.from.id
|
|
|
|
|
2016-08-12 00:44:39 +02:00
|
|
|
if matches[1] == '⚙ Einstellungen' or matches[1] == '/settings' then
|
2016-08-24 15:38:29 +02:00
|
|
|
utilities.send_reply(msg, 'Was möchtest du einstellen?', false, '{"keyboard":'..settings:keyboard(msg.from.id)..', "one_time_keyboard":true, "selective":true, "resize_keyboard":true}')
|
2016-08-02 16:19:20 +02:00
|
|
|
return
|
2016-08-12 00:44:39 +02:00
|
|
|
elseif matches[1] == '💤 AFK-Keyboard einschalten' then
|
2016-08-02 16:19:20 +02:00
|
|
|
redis:hset(hash, 'afk_keyboard', 'true')
|
2016-08-24 15:38:29 +02:00
|
|
|
utilities.send_reply(msg, 'Das AFK-Keyboard wurde erfolgreich *eingeschaltet*.', true, '{"keyboard":'..settings:keyboard(msg.from.id)..', "one_time_keyboard":true, "selective":true, "resize_keyboard":true}')
|
2016-08-02 16:19:20 +02:00
|
|
|
return
|
|
|
|
elseif matches[1] == '💤 AFK-Keyboard ausschalten' then
|
|
|
|
redis:hset(hash, 'afk_keyboard', 'false')
|
2016-08-24 15:38:29 +02:00
|
|
|
utilities.send_reply(msg, 'Das AFK-Keyboard wurde erfolgreich *ausgeschaltet*.', true, '{"keyboard":'..settings:keyboard(msg.from.id)..', "one_time_keyboard":true, "selective":true, "resize_keyboard":true}')
|
2016-08-02 16:19:20 +02:00
|
|
|
return
|
2016-08-12 00:44:39 +02:00
|
|
|
elseif matches[1] == '❌ Einstellungen verstecken' then
|
2016-08-24 15:38:29 +02:00
|
|
|
utilities.send_reply(msg, 'Um die Einstellungen wieder einzublenden, führe /settings aus.', true, '{"hide_keyboard":true}')
|
2016-08-02 16:19:20 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return settings
|