init commit
This commit is contained in:
19
app/services/telegram.py
Normal file
19
app/services/telegram.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from typing import Iterable
|
||||
|
||||
def make_keyboard_payload(buttons: Iterable[tuple[str, str]] | None):
|
||||
if not buttons:
|
||||
return None
|
||||
rows = [[{"text": t, "url": u}] for t, u in buttons]
|
||||
return {"rows": rows}
|
||||
|
||||
|
||||
def build_payload(ptype: str, text: str | None, media_file_id: str | None,
|
||||
parse_mode: str | None, keyboard: dict | None) -> dict:
|
||||
# ptype: "text" | "photo" | "video" | "animation"
|
||||
return {
|
||||
"type": ptype,
|
||||
"text": text,
|
||||
"media_file_id": media_file_id,
|
||||
"parse_mode": parse_mode,
|
||||
"keyboard": keyboard,
|
||||
}
|
||||
Reference in New Issue
Block a user