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
4b448b4e
Commit
4b448b4e
authored
2 years ago
by
Tulir Asokan
Browse files
Options
Downloads
Patches
Plain Diff
Use new wrapper for creating background tasks
parent
eab7e5d3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
maubot.yaml
+1
-1
1 addition, 1 deletion
maubot.yaml
reminder/bot.py
+3
-2
3 additions, 2 deletions
reminder/bot.py
with
4 additions
and
3 deletions
maubot.yaml
+
1
−
1
View file @
4b448b4e
maubot
:
0.
1.0
maubot
:
0.
4.1
id
:
xyz.maubot.reminder
id
:
xyz.maubot.reminder
version
:
0.2.2
version
:
0.2.2
license
:
AGPL-3.0-or-later
license
:
AGPL-3.0-or-later
...
...
This diff is collapsed.
Click to expand it.
reminder/bot.py
+
3
−
2
View file @
4b448b4e
...
@@ -23,6 +23,7 @@ import pytz
...
@@ -23,6 +23,7 @@ import pytz
from
mautrix.types
import
(
EventType
,
RedactionEvent
,
StateEvent
,
Format
,
MessageType
,
from
mautrix.types
import
(
EventType
,
RedactionEvent
,
StateEvent
,
Format
,
MessageType
,
TextMessageEventContent
,
ReactionEvent
,
UserID
)
TextMessageEventContent
,
ReactionEvent
,
UserID
)
from
mautrix.util.config
import
BaseProxyConfig
from
mautrix.util.config
import
BaseProxyConfig
from
mautrix.util
import
background_task
from
maubot
import
Plugin
,
MessageEvent
from
maubot
import
Plugin
,
MessageEvent
from
maubot.handlers
import
command
,
event
from
maubot.handlers
import
command
,
event
...
@@ -78,7 +79,7 @@ class ReminderBot(Plugin):
...
@@ -78,7 +79,7 @@ class ReminderBot(Plugin):
async
def
schedule_nearby_reminders
(
self
,
now
:
datetime
)
->
None
:
async
def
schedule_nearby_reminders
(
self
,
now
:
datetime
)
->
None
:
until
=
now
+
timedelta
(
minutes
=
1
)
until
=
now
+
timedelta
(
minutes
=
1
)
for
reminder
in
self
.
db
.
all_in_range
(
now
,
until
):
for
reminder
in
self
.
db
.
all_in_range
(
now
,
until
):
asyncio
.
create
_task
(
self
.
send_reminder
(
reminder
))
background_task
.
create
(
self
.
send_reminder
(
reminder
))
async
def
send_reminder
(
self
,
reminder
:
ReminderInfo
)
->
None
:
async
def
send_reminder
(
self
,
reminder
:
ReminderInfo
)
->
None
:
try
:
try
:
...
@@ -175,7 +176,7 @@ class ReminderBot(Plugin):
...
@@ -175,7 +176,7 @@ class ReminderBot(Plugin):
now
=
datetime
.
now
(
tz
=
pytz
.
UTC
)
now
=
datetime
.
now
(
tz
=
pytz
.
UTC
)
if
(
rem
.
date
-
now
).
total_seconds
()
<
60
and
now
.
minute
==
rem
.
date
.
minute
:
if
(
rem
.
date
-
now
).
total_seconds
()
<
60
and
now
.
minute
==
rem
.
date
.
minute
:
self
.
log
.
debug
(
f
"
Reminder
{
rem
}
is in less than a minute, scheduling now...
"
)
self
.
log
.
debug
(
f
"
Reminder
{
rem
}
is in less than a minute, scheduling now...
"
)
asyncio
.
create
_task
(
self
.
send_reminder
(
rem
))
background_task
.
create
(
self
.
send_reminder
(
rem
))
@remind.subcommand
(
"
help
"
,
help
=
"
Usage instructions
"
)
@remind.subcommand
(
"
help
"
,
help
=
"
Usage instructions
"
)
async
def
help
(
self
,
evt
:
MessageEvent
)
->
None
:
async
def
help
(
self
,
evt
:
MessageEvent
)
->
None
:
...
...
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