Added more logging to diagnose Telegram transport

This commit is contained in:
Rodger Castle 2026-06-04 21:57:46 -04:00
parent 106bb9f800
commit 2e6ebf3b10
2 changed files with 13 additions and 2 deletions

View File

@ -203,8 +203,18 @@ sub save_cancel_keyboard {
sub _post { sub _post {
my ($self, $method, $body) = @_; my ($self, $method, $body) = @_;
my $url = API_BASE . $self->{_token} . '/' . $method; my $url = API_BASE . $self->{_token} . '/' . $method;
my $json = encode_json($body);
if ($method =~ /^(sendMessage|editMessageText)$/) {
my $kb = !exists $body->{reply_markup} ? 'none'
: exists $body->{reply_markup}{inline_keyboard} ? 'inline'
: exists $body->{reply_markup}{keyboard} ? 'reply'
: 'other';
warn "DBG _post $method: keyboard_type=$kb\n";
}
my $tx = $self->{_ua}->post( my $tx = $self->{_ua}->post(
$url => { 'Content-Type' => 'application/json' } => encode_json($body) $url => { 'Content-Type' => 'application/json' } => $json
); );
my $res = eval { $tx->result }; my $res = eval { $tx->result };
if ($@) { if ($@) {

View File

@ -56,6 +56,7 @@ sub _handle_message {
# Wizard in progress — /cancel always escapes; other commands are blocked # Wizard in progress — /cancel always escapes; other commands are blocked
if (exists $SESSIONS{$chat_id} && $SESSIONS{$chat_id}{step} ne 'done') { if (exists $SESSIONS{$chat_id} && $SESSIONS{$chat_id}{step} ne 'done') {
warn "DBG handle_message_in_session: step=$SESSIONS{$chat_id}{step} text=" . substr($text, 0, 60) . "\n";
if ($text =~ /^\/cancel/i) { if ($text =~ /^\/cancel/i) {
_cmd_cancel($chat_id, $telegram); _cmd_cancel($chat_id, $telegram);
} elsif ($text =~ /^\//) { } elsif ($text =~ /^\//) {