main: better task invite message
This commit is contained in:
parent
aec64d3a6c
commit
9ec684d345
23
main.py
23
main.py
@ -40,6 +40,18 @@ def necessary_changes(current: List[T], desired: List[T]) -> Changes[T]:
|
||||
|
||||
return changes
|
||||
|
||||
def format_seconds(seconds: float) -> str:
|
||||
seconds = int(seconds)
|
||||
|
||||
if seconds < 60:
|
||||
return f"{seconds} seconds"
|
||||
elif seconds < 3600:
|
||||
return f"{seconds//60} minutes"
|
||||
elif seconds < 86400:
|
||||
return f"{seconds//3600} hours"
|
||||
else:
|
||||
return f"{seconds//86400} days"
|
||||
|
||||
class SignalAPI:
|
||||
|
||||
def __init__(self, apiurl, number):
|
||||
@ -396,7 +408,16 @@ class LabCleaningBot:
|
||||
reqs = reqs.unwrap()
|
||||
|
||||
for request in reqs:
|
||||
message = SendMessageSimple(message=task.name, recipients=[request.user.name])
|
||||
seconds_to_due = (task.due - request.requested_at).total_seconds()
|
||||
text = f"""Hi!
|
||||
|
||||
You have been requested to participate in the task: {task.name} (starts in {format_seconds(seconds_to_due)}).
|
||||
|
||||
To accept the request, react with 👍. To reject, react with any other emoji.
|
||||
|
||||
You have time to answer for {format_seconds(task.timeout)}."""
|
||||
|
||||
message = SendMessageSimple(message=text, recipients=[request.user.name])
|
||||
res = self.api.send_message(message)
|
||||
|
||||
if is_ok(res):
|
||||
|
Loading…
Reference in New Issue
Block a user