mnemosyne/lib/Mnemosyne/Telegram.pm

36 lines
1.3 KiB
Perl

package Mnemosyne::Telegram;
use strict;
use warnings;
# Bot API client. All outbound calls use Mojo::UserAgent.
# Never use Telegram::Bot or other heavyweight frameworks.
#
# Constructor:
# TODO: new($token) — stores token; lazily creates Mojo::UserAgent
#
# Sending messages:
# TODO: send_message($chat_id, $text, %opts)
# — opts: parse_mode (default 'HTML'), reply_markup (inline keyboard hashref)
# — returns the sent message's message_id (needed for later edits)
#
# TODO: edit_message($chat_id, $message_id, $text, %opts)
# — wraps editMessageText; used to replace "pending" with "✓ Done — [Undo]"
#
# TODO: edit_reply_markup($chat_id, $message_id, $reply_markup)
# — wraps editMessageReplyMarkup; strips buttons after undo window expires
#
# TODO: answer_callback_query($callback_query_id, %opts)
# — must be called promptly to stop the client spinner; opts: text, show_alert
#
# Keyboard helpers:
# TODO: mark_done_keyboard($task_id) — returns inline_keyboard hashref with one
# "Mark Done" button; callback_data encodes action + task_id
#
# TODO: undo_keyboard($completion_id) — "Undo" button after a mark-done action
#
# Setup:
# TODO: set_webhook($url, $secret_token) — calls setWebhook; idempotent
# TODO: delete_webhook() — calls deleteWebhook
1;