Skip to content

Breaking backwards compatibility

Armando Lüscher edited this page Jun 25, 2017 · 26 revisions

This library is still under heavy development, so some changes will break backwards compatibility (BC). We try to keep breaking changes to a minimum, but also try to create the best solution for any given situation.

Here is a list of BC breaking changes in each version.

Remove deprecated methods

Before:

Telegram::getBotName();
Entity::getBotName();
Telegram::unsetWebhook();

After:

Telegram::getBotUsername();
Entity::getBotUsername();
Telegram::deleteWebhook();

Chats params array

Request::sendToActiveChats and DB::selectChats now accept parameters as an options array and allow selecting of channels.

Before: Parameters to limit selection were all passed individually.

$results = DB::selectChats(
    true, // Select groups
    true, // Select supergroups
    true, // Select users
    null, // 'yyyy-mm-dd hh:mm:ss' date range from
    null, // 'yyyy-mm-dd hh:mm:ss' date range to
    null, // Specific chat_id to select
    null  // Text to search in user/group name
);

$results = Request::sendToActiveChats(
    'sendMessage',     // Callback function to execute (see Request.php methods)
    ['text' => $text], // Param to evaluate the request
    true,              // Send to groups
    true,              // Send to supergroups
    true,              // Send to users
);

After: Parameters to limit selection now gets passed as an associative array.

$results = DB::selectChats([
    'groups'      => true,
    'supergroups' => true,
    'channels'    => true,
    'users'       => true,
    'date_from'   => null,
    'date_to'     => null,
    'chat_id'     => null,
    'text'        => null,
]);

$results = Request::sendToActiveChats(
    'sendMessage',     // Callback function to execute (see Request.php methods)
    ['text' => $text], // Param to evaluate the request
    [
        'groups'      => true,
        'supergroups' => true,
        'channels'    => false,
        'users'       => true,
    ]
);

Up/Download directories

The upload and download directories are not set any more by default and must be set manually in the hook file.

$telegram->setUploadPath('/path/to/uploads');
$telegram->setDownloadPath('/path/to/downloads');

Before: Returned an array containing the update content.

$m   = $update->getUpdateContent();
$mid = $m['message']['message_id'];
$cid = $m['message']['chat']['id'];
$uid = $m['from']['id'];

Now: Correctly returns the Entity of the update content.

$m   = $update->getUpdateContent();
$mid = $m->getMessage()->getMessageId();
$cid = $m->getMessage()->getChat()->getId();
$uid = $m->getFrom()->getId();