...und enterne das Feature wieder, weil das in Gruppen kontraproduktiv ist >_<
This commit is contained in:
parent
234faf0db6
commit
77515f6cdb
@ -50,30 +50,16 @@ function quotes:delete_quote(msg)
|
||||
end
|
||||
end
|
||||
|
||||
function quotes:get_quote(msg, num)
|
||||
function quotes:get_quote(msg)
|
||||
local hash = get_redis_hash(msg, 'quotes')
|
||||
|
||||
if hash then
|
||||
print('Getting quote from redis set '..hash)
|
||||
local quotes_table = redis:smembers(hash)
|
||||
if not quotes_table[1] then
|
||||
return nil, 'Es wurden noch keine Zitate gespeichert.\nSpeichere doch welche mit /addquote [Zitat]'
|
||||
return 'Es wurden noch keine Zitate gespeichert.\nSpeichere doch welche mit /addquote [Zitat]'
|
||||
else
|
||||
local totalquotes = #quotes_table
|
||||
if num then
|
||||
selected_quote = tonumber(num)
|
||||
else
|
||||
selected_quote = math.random(1,totalquotes)
|
||||
end
|
||||
local prev_num = selected_quote - 1
|
||||
if prev_num == 0 then
|
||||
prev_num = totalquotes -- last quote
|
||||
end
|
||||
local next_num = selected_quote + 1
|
||||
if next_num > totalquotes then
|
||||
next_num = 1
|
||||
end
|
||||
return prev_num, quotes_table[selected_quote], next_num
|
||||
return quotes_table[math.random(1,#quotes_table)]
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -96,21 +82,10 @@ function quotes:list_quotes(msg)
|
||||
end
|
||||
end
|
||||
|
||||
function quotes:action(msg, config, matches, num, self_plz)
|
||||
if num or matches[1] == "quote" then
|
||||
if not self.BASE_URL then self = self_plz end
|
||||
local prev_num, selected_quote, next_num = quotes:get_quote(msg, num)
|
||||
if prev_num == next_num or not next_num or not prev_num then
|
||||
keyboard = nil
|
||||
else
|
||||
keyboard = '{"inline_keyboard":[[{"text":"« '..prev_num..'","callback_data":"quotes:'..prev_num..'"},{"text":"'..next_num..' »","callback_data":"quotes:'..next_num..'"}]]}'
|
||||
end
|
||||
if num then
|
||||
local result = utilities.edit_message(self, msg.chat.id, msg.message_id, selected_quote, true, false, keyboard)
|
||||
return
|
||||
end
|
||||
utilities.send_message(self, msg.chat.id, selected_quote, true, false, false, keyboard)
|
||||
return
|
||||
function quotes:action(msg, config, matches)
|
||||
if matches[1] == "quote" then
|
||||
utilities.send_message(self, msg.chat.id, quotes:get_quote(msg), true)
|
||||
return
|
||||
elseif matches[1] == "addquote" and matches[2] then
|
||||
utilities.send_reply(self, msg, quotes:save_quote(msg), true)
|
||||
return
|
||||
@ -133,9 +108,4 @@ function quotes:action(msg, config, matches, num, self_plz)
|
||||
utilities.send_reply(self, msg, quotes.doc, true)
|
||||
end
|
||||
|
||||
function quotes:callback(callback, msg, self, config, num)
|
||||
utilities.answer_callback_query(self, callback)
|
||||
quotes:action(msg, config, nil, num, self)
|
||||
end
|
||||
|
||||
return quotes
|
||||
|
Reference in New Issue
Block a user