Skip to content

Releases: Kyle2142/PHPBot

Fire and Forget

23 Sep 21:57
Compare
Choose a tag to compare

Very simple fire and forget. All you need to do is replace
$bot->api->method(['params' => 'foo']);
with
$bot->fireAndForget('method', ['params' => 'foo']);
to benefit from potential speedups

Long polling! File downloading!

01 Aug 23:52
Compare
Choose a tag to compare
Pre-release

You can now use long polling (getUpdates) by simply creating a function which accepts an update, and starting polling with handle_updates:

function dumper($update){
    var_dump($update); //do whatever you want in here
}
$bot->handle_updates('dumper'); //blocks forever

See the function docs for parameter details.

You can download files by passing a file_id to downloadFile, and it will do one of 3 things, depending on the type of the destination:

  • null, omitted:
    content is returned directly
  • string:
    content is output into the given string, as a path
  • resource:
    content is written with fwrite

Note that this has not been extensively tested.

Implemented Exceptions

20 Jun 22:06
Compare
Choose a tag to compare
Pre-release

Breaking change:
API methods no longer return stdClass all the time, they return what was the result property from previous versions.
To make code compatible with this release, you need to do two things:

  • Every time you did $result = $bot->......(...)->result, remove the ->result
  • Add Exception handling.
    API calls can now throw kyle2142\TelegramException (in case of RPC error) or RuntimeException (in case of user or other error unrelated to Telegram API), so you will need to catch these where needed.

Pre-release

17 Jun 18:27
Compare
Choose a tag to compare
Pre-release Pre-release
Pre-release

A decent set of basic features, with loads of room for extension and improvement.