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
de01aa55
Commit
de01aa55
authored
4 years ago
by
Tulir Asokan
Browse files
Options
Downloads
Patches
Plain Diff
Rename default timezone config field
parent
5bace921
No related branches found
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
+4
-3
4 additions, 3 deletions
base-config.yaml
reminder/bot.py
+4
-2
4 additions, 2 deletions
reminder/bot.py
reminder/db.py
+2
-1
2 additions, 1 deletion
reminder/db.py
reminder/util.py
+1
-1
1 addition, 1 deletion
reminder/util.py
with
11 additions
and
7 deletions
base-config.yaml
+
4
−
3
View file @
de01aa55
# Default timezone for users who did not set one.
# This is parsed with pytz, so the usual format is Continent/City, e.g. Europe/Helsinki.
default_timezone
:
'
UTC'
# Base command without the prefix (!).
# If a list is provided, the first is the main name and the rest are aliases.
base_command
:
-
remind
-
reminder
# Default timezone for users who did not set one
timezone
:
'
UTC'
This diff is collapsed.
Click to expand it.
reminder/bot.py
+
4
−
2
View file @
de01aa55
...
...
@@ -36,6 +36,7 @@ class ReminderBot(Plugin):
reminder_loop_task
:
asyncio
.
Future
base_command
:
str
base_aliases
:
Tuple
[
str
,
...]
default_timezone
:
pytz
.
timezone
@classmethod
def
get_config_class
(
cls
)
->
Type
[
BaseProxyConfig
]:
...
...
@@ -51,10 +52,11 @@ class ReminderBot(Plugin):
bc
=
self
.
config
[
"
base_command
"
]
self
.
base_command
=
bc
[
0
]
if
isinstance
(
bc
,
list
)
else
bc
self
.
base_aliases
=
tuple
(
bc
)
if
isinstance
(
bc
,
list
)
else
(
bc
,)
raw_timezone
=
self
.
config
[
"
default_timezone
"
]
try
:
self
.
default_timezone
=
pytz
.
timezone
(
self
.
config
[
"
timezone
"
]
)
self
.
default_timezone
=
pytz
.
timezone
(
raw_
timezone
)
except
pytz
.
UnknownTimeZoneError
:
self
.
log
.
warning
(
f
"
Unknown default timezone
{
self
.
config
[
'
timezone
'
]
}
"
)
self
.
log
.
warning
(
f
"
Unknown default timezone
{
raw_
timezone
}
"
)
self
.
default_timezone
=
pytz
.
UTC
async
def
stop
(
self
)
->
None
:
...
...
This diff is collapsed.
Click to expand it.
reminder/db.py
+
2
−
1
View file @
de01aa55
...
...
@@ -70,7 +70,8 @@ class ReminderDatabase:
tx
.
execute
(
self
.
timezone
.
insert
().
values
(
user_id
=
user_id
,
timezone
=
tz
.
zone
))
self
.
tz_cache
[
user_id
]
=
tz
def
get_timezone
(
self
,
user_id
:
UserID
,
default_tz
:
Optional
[
pytz
.
timezone
])
->
Optional
[
pytz
.
timezone
]:
def
get_timezone
(
self
,
user_id
:
UserID
,
default_tz
:
Optional
[
pytz
.
timezone
]
=
None
)
->
Optional
[
pytz
.
timezone
]:
try
:
return
self
.
tz_cache
[
user_id
]
except
KeyError
:
...
...
This diff is collapsed.
Click to expand it.
reminder/util.py
+
1
−
1
View file @
de01aa55
...
...
@@ -34,8 +34,8 @@ if TYPE_CHECKING:
class
Config
(
BaseProxyConfig
):
def
do_update
(
self
,
helper
:
ConfigUpdateHelper
)
->
None
:
helper
.
copy
(
"
default_timezone
"
)
helper
.
copy
(
"
base_command
"
)
helper
.
copy
(
"
timezone
"
)
class
DateArgument
(
Argument
):
...
...
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