...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
|
||||||
end
|
end
|
||||||
|
|
||||||
function quotes:get_quote(msg, num)
|
function quotes:get_quote(msg)
|
||||||
local hash = get_redis_hash(msg, 'quotes')
|
local hash = get_redis_hash(msg, 'quotes')
|
||||||
|
|
||||||
if hash then
|
if hash then
|
||||||
print('Getting quote from redis set '..hash)
|
print('Getting quote from redis set '..hash)
|
||||||
local quotes_table = redis:smembers(hash)
|
local quotes_table = redis:smembers(hash)
|
||||||
if not quotes_table[1] then
|
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
|
else
|
||||||
local totalquotes = #quotes_table
|
return quotes_table[math.random(1,#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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -96,20 +82,9 @@ function quotes:list_quotes(msg)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function quotes:action(msg, config, matches, num, self_plz)
|
function quotes:action(msg, config, matches)
|
||||||
if num or matches[1] == "quote" then
|
if matches[1] == "quote" then
|
||||||
if not self.BASE_URL then self = self_plz end
|
utilities.send_message(self, msg.chat.id, quotes:get_quote(msg), true)
|
||||||
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
|
return
|
||||||
elseif matches[1] == "addquote" and matches[2] then
|
elseif matches[1] == "addquote" and matches[2] then
|
||||||
utilities.send_reply(self, msg, quotes:save_quote(msg), true)
|
utilities.send_reply(self, msg, quotes:save_quote(msg), true)
|
||||||
@ -133,9 +108,4 @@ function quotes:action(msg, config, matches, num, self_plz)
|
|||||||
utilities.send_reply(self, msg, quotes.doc, true)
|
utilities.send_reply(self, msg, quotes.doc, true)
|
||||||
end
|
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
|
return quotes
|
||||||
|
Reference in New Issue
Block a user