Added more logging to diagnose Telegram transport
This commit is contained in:
parent
106bb9f800
commit
2e6ebf3b10
@ -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 ($@) {
|
||||||
|
|||||||
@ -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 =~ /^\//) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user