Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
maubot-ethzlunch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
isgphys
maubot-ethzlunch
Commits
58fb98b5
Commit
58fb98b5
authored
1 year ago
by
MxMarx
Browse files
Options
Downloads
Patches
Plain Diff
add time_format parameter
parent
d450e323
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
base-config.yaml
+12
-2
12 additions, 2 deletions
base-config.yaml
reminder/bot.py
+2
-0
2 additions, 0 deletions
reminder/bot.py
reminder/reminder.py
+4
-4
4 additions, 4 deletions
reminder/reminder.py
reminder/util.py
+4
-5
4 additions, 5 deletions
reminder/util.py
with
22 additions
and
11 deletions
base-config.yaml
+
12
−
2
View file @
58fb98b5
# https://github.com/MxMarx/reminder
# Feature requests welcome!
# Default timezone for users who did not set one.
# This is parsed with dateparser, so Continent/City, UTC offsets, and abbreviations should work.
# e.g. Europe/Helsinki, EET, +0300
...
...
@@ -14,7 +17,8 @@ base_command:
-
remind
-
remindme
# subcommands used to create an agenda items
# Agenda items are like reminders but don't have a time, for things like to-do lists.
# Aliases used to create an agenda items by calling "!agenda <message>":
agenda_command
:
-
agenda
-
todo
...
...
@@ -24,7 +28,6 @@ cancel_command:
-
cancel
-
delete
# If verbose is true, display full confirmation messages. If false, confirm by reacting with :thumbs-up:
verbose
:
true
...
...
@@ -32,4 +35,11 @@ verbose: true
rate_limit
:
10
rate_limit_minutes
:
60
# Power level needed to delete someone else's reminder
admin_power_level
:
50
# time_format: strftime format when listing reminders.
# "%-I:%M%P %Z on %A, %B %-d %Y" - 7:36pm PDT on Sunday, September 17 2023
# "%Y-%m-%d %H:%M %Z" - 2023-09-17 19:36 PDT
# Currently, reminders within 7 days will be displayed as just the relative delta, e.g. "2 days and 1 hour"
time_format
:
"
%-I:%M%P
%Z
on
%A,
%B
%-d
%Y"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
reminder/bot.py
+
2
−
0
View file @
58fb98b5
...
...
@@ -44,6 +44,8 @@ class Config(BaseProxyConfig):
helper
.
copy
(
"
rate_limit
"
)
helper
.
copy
(
"
verbose
"
)
helper
.
copy
(
"
admin_power_level
"
)
helper
.
copy
(
"
time_format
"
)
class
ReminderBot
(
Plugin
):
base_command
:
Tuple
[
str
,
...]
...
...
This diff is collapsed.
Click to expand it.
reminder/reminder.py
+
4
−
4
View file @
58fb98b5
...
...
@@ -203,17 +203,17 @@ class Reminder(object):
"""
if
self
.
is_agenda
:
return
format_time
(
self
.
start_time
,
user_info
)
return
format_time
(
self
.
start_time
,
user_info
=
user_info
,
time_format
=
self
.
bot
.
config
[
'
time_format
'
]
)
else
:
next_run
=
format_time
(
self
.
job
.
next_run_time
,
user_info
)
next_run
=
format_time
(
self
.
job
.
next_run_time
,
user_info
=
user_info
,
time_format
=
self
.
bot
.
config
[
'
time_format
'
]
)
if
self
.
cron_tab
:
# TODO add languages
if
USE_CRON_DESCRIPTOR
:
return
f
"
{
ExpressionDescriptor
(
self
.
cron_tab
,
casing_type
=
CasingTypeEnum
.
LowerCase
)
}
(`
{
self
.
cron_tab
}
`), next run
{
next_run
}
"
else
:
return
f
"
`
{
self
.
cron_tab
}
`, next run
{
next_run
}
"
return
f
"
`
{
self
.
cron_tab
}
`, next run
at
{
next_run
}
"
elif
self
.
recur_every
:
return
f
"
every
{
self
.
recur_every
}
, next run
{
next_run
}
"
return
f
"
every
{
self
.
recur_every
}
, next run
at
{
next_run
}
"
else
:
# once-off reminders
return
next_run
...
...
This diff is collapsed.
Click to expand it.
reminder/util.py
+
4
−
5
View file @
58fb98b5
...
...
@@ -222,13 +222,13 @@ def pluralize(val: int, unit: str) -> str:
return
f
"
{
val
}
{
unit
}
"
return
f
"
{
val
}
{
unit
}
s
"
def
format_time
(
time
:
datetime
,
user_info
:
UserInfo
)
->
str
:
def
format_time
(
time
:
datetime
,
user_info
:
UserInfo
,
time_format
:
str
=
"
%-I:%M%P %Z on %A, %B %-d %Y
"
)
->
str
:
"""
Format time as something readable by humans.
Args:
time: datetime to format
user_info: contains locale
(if using arrow)
and timezone
user_info: contains locale and timezone
time_format:
Returns:
"""
...
...
@@ -256,8 +256,7 @@ def format_time(time: datetime, user_info: UserInfo) -> str:
formatted_time
=
formatted_time
+
"
ago
"
else
:
formatted_time
=
time
.
astimezone
(
dateparser
.
utils
.
get_timezone_from_tz_string
(
user_info
.
timezone
)).
strftime
(
"
at %I:%M%P %Z on %A, %B %d %Y
"
)
dateparser
.
utils
.
get_timezone_from_tz_string
(
user_info
.
timezone
)).
strftime
(
time_format
)
return
formatted_time
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment