Fi, Fix und nochmal Fix
This commit is contained in:
parent
206c06937a
commit
49824fcb26
@ -26,7 +26,7 @@ function gSearch:googlethat(query, config)
|
|||||||
utilities.send_reply(self, msg, config.errors.connection)
|
utilities.send_reply(self, msg, config.errors.connection)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local data = JSON.decode(res)
|
local data = json.decode(res)
|
||||||
if data.searchInformation.formattedTotalResults == "0" then return nil end
|
if data.searchInformation.formattedTotalResults == "0" then return nil end
|
||||||
|
|
||||||
local results={}
|
local results={}
|
||||||
|
@ -17,25 +17,29 @@ function remind:action(msg)
|
|||||||
utilities.send_message(self, msg.chat.id, remind.doc, true, msg.message_id, true)
|
utilities.send_message(self, msg.chat.id, remind.doc, true, msg.message_id, true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ensure first arg is a number. If not, send doc.
|
-- Ensure first arg is a number. If not, send doc.
|
||||||
local duration = utilities.get_word(input, 1)
|
local duration = utilities.get_word(input, 1)
|
||||||
if not tonumber(duration) then
|
if not tonumber(duration) then
|
||||||
utilities.send_message(self, msg.chat.id, remind.doc, true, msg.message_id, true)
|
utilities.send_message(self, msg.chat.id, remind.doc, true, msg.message_id, true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Duration must be between one minute and one year (approximately).
|
|
||||||
|
-- Duration must be between one minute and one day (approximately).
|
||||||
duration = tonumber(duration)
|
duration = tonumber(duration)
|
||||||
if duration < 1 then
|
if duration < 1 then
|
||||||
duration = 1
|
duration = 1
|
||||||
elseif duration > 526000 then
|
elseif duration > 1440 then
|
||||||
duration = 526000
|
duration = 1440
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ensure there is a second arg.
|
-- Ensure there is a second arg.
|
||||||
local message = utilities.input(input)
|
local message = utilities.input(input)
|
||||||
if not message then
|
if not message then
|
||||||
utilities.send_message(self, msg.chat.id, remind.doc, true, msg.message_id, true)
|
utilities.send_message(self, msg.chat.id, remind.doc, true, msg.message_id, true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Make a database entry for the group/user if one does not exist.
|
-- Make a database entry for the group/user if one does not exist.
|
||||||
self.database.reminders[msg.chat.id_str] = self.database.reminders[msg.chat.id_str] or {}
|
self.database.reminders[msg.chat.id_str] = self.database.reminders[msg.chat.id_str] or {}
|
||||||
-- Limit group reminders to 10 and private reminders to 50.
|
-- Limit group reminders to 10 and private reminders to 50.
|
||||||
@ -46,19 +50,17 @@ function remind:action(msg)
|
|||||||
utilities.send_reply(msg, 'Du hast schon 50 Erinnerungen!')
|
utilities.send_reply(msg, 'Du hast schon 50 Erinnerungen!')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Put together the reminder with the expiration, message, and message to reply to.
|
-- Put together the reminder with the expiration, message, and message to reply to.
|
||||||
|
local timestamp = os.time() + duration * 60
|
||||||
local reminder = {
|
local reminder = {
|
||||||
time = os.time() + duration * 60,
|
time = timestamp,
|
||||||
message = message
|
message = message
|
||||||
}
|
}
|
||||||
table.insert(self.database.reminders[msg.chat.id_str], reminder)
|
table.insert(self.database.reminders[msg.chat.id_str], reminder)
|
||||||
local output = 'Ich werde dich in ' .. duration
|
local human_readable_time = convert_timestamp(timestamp, '%H:%M:%S')
|
||||||
if duration == 1 then
|
local output = 'Ich werde dich um *'..human_readable_time..' Uhr* erinnern.'
|
||||||
output = output .. ' Minute erinnern!'
|
utilities.send_reply(self, msg, output, true)
|
||||||
else
|
|
||||||
output = output .. ' Minuten erinnern!'
|
|
||||||
end
|
|
||||||
utilities.send_reply(self, msg, output)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function remind:cron()
|
function remind:cron()
|
||||||
|
@ -23,7 +23,7 @@ function leave_group:check_for_admin(msg, self, config)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function leave_group:action(msg)
|
function leave_group:action(msg, config)
|
||||||
if not is_service_msg(msg) then return end -- Bad attempt at trolling!
|
if not is_service_msg(msg) then return end -- Bad attempt at trolling!
|
||||||
local admin_in_group = leave_group:check_for_admin(msg, self, config)
|
local admin_in_group = leave_group:check_for_admin(msg, self, config)
|
||||||
if not admin_in_group then
|
if not admin_in_group then
|
||||||
|
@ -254,7 +254,7 @@ function utilities.trim(str)
|
|||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Retruns true if the string is empty
|
-- Returns true if the string is empty
|
||||||
function string:isempty()
|
function string:isempty()
|
||||||
return self == nil or self == ''
|
return self == nil or self == ''
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user