EatMoreCode / Telegram-Bot

Perl module to make creating new Telegram bots easy
4 stars 6 forks source link

Saying /hello to example code bot results in "Bad Request: file must be non-empty" #2

Closed xtaran closed 5 years ago

xtaran commented 5 years ago

I just tried the example code from the Telegram::Bot POD and upon the first /hello the program spew out these messages:

Mojo::Reactor::EV: I/O watcher failed: 400 response: Bad Request
Body: {"ok":false,"error_code":400,"description":"Bad Request: file must be non-empty"} at /usr/share/perl5/Telegram/Bot/Brain.pm line 89.

After that the bot no more answers any /hello requests anymore until I restart it. From reading the code I'd guess it should reply every time I say /hello to it.

I'm using Mojolicious 7.21 from Debian 9 Stretch and Telegram::Bot 0.010 from CPAN.

xtaran commented 5 years ago

Ok, it's these lines because the given file does not exist:

    # send them a picture as well
    my $image = Telegram::Bot::Object::PhotoSize->new(image => "smile.png");
    $self->send_to_chat_id($msg->chat->id, $image);

Commenting them out makes the bot work as expected.

So I see several more or less minor issues here:

tardisx commented 5 years ago

Thanks @xtaran - I will look at hardening against things like this (which we should notice before we send to the API, definitely.

Note that generally speaking one should not expect a code example from a SYNOPSIS to necessarily be complete and self-contained.