Add telegram bot
This commit is contained in:
1 parent
134d610a5d
commit
6d2d9ab9ae
15 files changed
+941
No files matched your search
@@ -0,0 +1,37 @@
|
||||
"""Message formatting for new-meeting announcements."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from html import escape
|
||||
from urllib.parse import quote
|
||||
|
||||
from .api import Meeting
|
||||
|
||||
|
||||
def _format_local(moment) -> str:
|
||||
return moment.astimezone().strftime("%a, %d %b %Y %H:%M %Z") if moment else "unknown"
|
||||
|
||||
|
||||
def room_link(web_base_url: str, room: str) -> str:
|
||||
return f"{(web_base_url or '').rstrip('/')}/rooms/{quote(room, safe='')}"
|
||||
|
||||
|
||||
def format_new_meeting(meeting: Meeting, *, web_base_url: str = "") -> str:
|
||||
"""Render an announcement; the join link appears only when a room exists."""
|
||||
lines = ["<b>New meeting scheduled</b>", ""]
|
||||
lines.append(f"<b>{escape(meeting.title) or '(untitled meeting)'}</b>")
|
||||
|
||||
if meeting.intent:
|
||||
lines += ["", escape(meeting.intent)]
|
||||
|
||||
lines.append("")
|
||||
lines.append(f"<b>When:</b> {escape(_format_local(meeting.scheduled_at))}")
|
||||
lines.append(f"<b>Planned by:</b> {escape(meeting.created_by_name or 'unknown')}")
|
||||
|
||||
if meeting.room:
|
||||
lines.append(f"<b>Room:</b> <code>{escape(meeting.room)}</code>")
|
||||
if web_base_url:
|
||||
link = room_link(web_base_url, meeting.room)
|
||||
lines.append(f'<a href="{escape(link)}">Join the meeting</a>')
|
||||
|
||||
return "\n".join(lines)
|
||||
Reference in new issue
Block a user