remind.help='/remind <duration> <message> - Repeats a message after a duration of time, in the format 2d3h. The maximum number of reminders at one time is 4 per chat, and each reminder must be between 1 hour and 182 days in duration. Reminders cannot be any more than 256 characters in length. Use /reminders to view your current reminders. An example use of this command would be: /remind 21d3h test, which would remind you in 21 days and 3 hours.'
end
functionremind.get_reminders(message)
localreminders={}
ifredis:get('reminders')then
reminders=json.decode(
redis:get('reminders')
)
end
localthis_chat={}
localcount=0
fork,vinpairs(reminders)do
ifv.chatandv.chat.id==message.chat.idthen
localreal_expiry=tonumber(v.expires)/3600
table.insert(
this_chat,
string.format(
utf8.char(8226)..' %s <code>[Added by %s, expires in approx. %s hour%s]</code>',
mattata.escape_html(v.reminder),
mattata.escape_html(v.name),
mattata.round(
(
tonumber(v.expires)-os.time()
)/3600,
2
),
mattata.round(
(
tonumber(v.expires)-os.time()
)/3600,
2
)==1and''or's'
)
)
count=count+1
end
end
ifcount==0then
returnmattata.send_reply(
message,
'You don\'t have any reminders set up in this chat!'
)
end
returnmattata.send_reply(
message,
string.format(
'You currently have %s reminder%s set up for %s:\n%s',
'The duration you specified isn\'t in a valid format. The duration of your reminder must be between 1 hour and 6 months, and in the format 5m1w12d3h, which would remind you in 5 months, 1 week, 12 days and 3 hours.'
)
elseifduration>15724800orduration<1then
returnmattata.send_reply(
message,
'The duration of your reminder must be between 1 hour and 182 days.'
)
end
ifutf8.len(reminder)>256then
returnmattata.send_reply(
message,
'Your reminder must not be any longer than 256 characters.'
)
end
localreminders={}
ifredis:get('reminders')then
reminders=json.decode(
redis:get('reminders')
)
end
localcount=0
fork,vinpairs(reminders)do
ifv.chatandv.chat.id==message.chat.idthen
count=count+1
end
end
ifcount>=4then
returnmattata.send_reply(
message,
'You already have 4 reminders set up in this chat. Please wait for one to expire before you add any more!'