Upcoming in v2: Support for PostegreSQL and TTL in Conversations
- Update to Bot API v5.2.
- Fixed crash when
pcntl
is not available. - Webhook is now automatically set.
- Fixed
restart_on_changes
with spaces inside file path. - Improved regex handlers: regex will no longer be used on handlers with exact match conditions.
v1.9 - Source Code
-
New User mode: you can now run userbots with NovaGram using tdlight-telegram-bot-api. (Webhooks too!) Check out this example.
-
Bot API v5.1:
Check full changelog for more info
- New types:
ChatMemberUpdated
,ChatInviteLink
,VoiceChatStarted
,VoiceChatEnded
,VoiceChatParticipantsInvited
,MessageAutoDeleteTimerChanged
. - New methods:
createChatInviteLink
,editChatInviteLink
,revokeChatInviteLink
. - New handlers:
onMyChatMember
,onChatMember
.
- New types:
-
New Features:
- New
onCallbackData
handler: similar toonText
but for Callback Queries data. - New
onNewChatMember
andonNewGroup
handlers: check updated docs. - New
exportCommands
method, that callssetMyCommands
with the registered command handlers (onCommand()
). Automatically called by default on CLI restart_on_changes
has been improved: now it usespcntl_exec
when possible (instead ofshell_exec
)- Added
User::getMention()
: it generates a clickable link for that User. - Added new Class Handlers:
CommandHandler
andCallbackHandler
- Added
toArray()
andtoJSON()
methods toObjectsList
andType
objects - Added
ObjectsList::getLast()
, useful if you work with photos, which are arrays ofPhotoSize
s - Added autoload of class handlers: it will include and fire all handlers found by searching for files that ends with
Handler.php
,Command.php
andCallback.php
. Class names must be the same as file names. It won't look insidevendor
. - Now
Message::editText()
will not deletereply_markup
by default. Usereply_markup: null
to force deleting it. - Added
Dispatcher::stopHandling()
or simplystop_handling()
, which stop other handlers from being executed (previously,exit()
was needed) - Added
Database::getConversationsByName()
- New
-
New Bot settings:
username
: Bot username, needed to avoid that other bot's commands are recognized in groups when using command handlers and webhook.export_commands
: Whether to callBot::exportCommands()
when idling on CLI. Default totrue
include_classes
: Whether to automatically include and fire Commands Class Handlers (includes all files that ends withCommand.php
,Handler.php
, andCallback.php
inside the main script directory). Defualt value istrue
onCLI
andfalse
onWebhook
.workers
: Maximum amount of processes that will run simultaneously. (CLI
only)skip_old_updates
: Whether to not process updates sent before starting the bot.
-
New Exceptions:
NotFoundException
(404)MethodNotAllowedException
(405)RequestEntityTooLargeException
(413)
-
Fixes:
- Bot won't crash on uncaught internal exceptions.
- Conversations are now updated instead of deleted and reinserted.
- Classes
MessageId
,ProximityAlertTriggered
didn't work properly - Bot will now process queued updates before retrieving other ones
- Fixed wrong behaviour when serializing false
- Default values for
log_updates
anddebug
are nownull
instead offalse
. - Now
log_updates
setting works on getUpdates too setMyCommands
arguments were wrong- Errors weren't handled when thrown inside class handlers
- Unknown objects are now instances of
stdClass
orObjectsList
- Exceptions constructor argument
$previous_exception
was anException
instead of aThrowable
- Entities parser didn't work with
ObjectsList
- Some databases couldn't be used with
getUpdates
, fixed onCommand
handler$args
argument behaviour was incorrect
-
Minor:
- Added
CurlException
- Renamed
Bot::idle()
toBot::start()
- You can now use PHP8
named arguments
in Bot constructor instead of the$settings
array JSON
all all the related methods are now static in Bot, this makes faster using multiple bot instances- Now when using
getUpdates
process titles are customized in order to differenciate main process and child processes - Properties
User::dc_id
andMessage::html
are now cached - All the Objects are now serializable
- Added
$description
parameter toonCommand
- Improvements in
Prototypes
:isPrototypeable
is now cached
- Added
v1.8 - Source Code
- New handlers:
onTextMessage
,onText
, andonCommand
- New Bot settings:
command_prefixes
: Array of characters for commands prefixes. e.g./start
,.info
group_handlers
: Whether to execute all the handlers of an update in the same process (true
), or fork a process for each handler (false
)wait_handlers
: Whether to wait for handlers to finish when closing scriptthreshold
: Amount of max seconds the script will sleep instead of throwing aTooManyRequestsException
. Defaults to 10 when usinggetUpdates
only_if_banned
: Default value foronly_if_banned
parameter inunbanChatMember
method
- Conversations full getters
getConversationsByChat
(User|Chat::getConversations()
)getConversationsByValue
amphp
has been removed, now skrtdev/async is used in classes too- Added all class handlers:
onMessage
,onEditedMessage
,onChannelPost
, etcallowed_updates
is automatically generated from classes too$this->Bot
can be used to getBot
instance inside Class handlers- More classes can be handled in a single
handleClass
call
- Now when using
getUpdates
bot won't crash onBadGatewayException
s, it will retry to connect every second instead - Now
var_dump
is used instead ofprint_r
indebug
functions - Now list of Objects are instances of
ObjectsList
rather than instances ofstdClass
- You can now use PHP8
named arguments
instead of the$args
array in bothBot
andObjects
methods - A custom
PDO
instance can now be used as database. Pass it in the database Bot setting instead of the Database array (novagram
will be used as prefix) Exception::$response_parameters
is now an instance ofResponseParameters
or null- Return types of every method has been updated
- Now a warning is emitted when using getUpdates if a webhook url is set
v1.7 - Source Code
- Improved performances of skrtdev/async
- Bot API 5.0
- Own Bot API Server: added new
bot_api_url
parameter to bot settings - Added
allow_sending_without_reply
global parameter to bot settings - Updated all objects and methods
- Added the new ChatLocation Object
- Added all new Methods
- Own Bot API Server: added new
- New Exception:
UnauthorizedException
(401) allowed_updates
is automatically generated when using getUpdates, so bot is faster if it receives many unwanted updates- Improved Composer Autoloader (PSR-4)
v1.6.1 - Bug Fix Release
- Fixed a bug that affected webhook
v1.6 - Source Code
-
Improved Composer Autoloader (PSR-4)
-
Added getUpdates mode (multi-processing)
- New
Dispatcher
class - Mode (Webhook/getUpdates/None) is recognized automatically
- Optional async handling of updates
- Closure Handlers (skrtdev/async)
- Full handlers (onUpdate, onMessage, onCallbackQuery, etc.)
- Error handler
- Class Handlers (amphp/amp)
- Only Update handler
- Auto restart when Bot file is edited (optional)
- New
-
Many new Exceptions
BadRequestException
(400)ForbiddenException
(403)ConflictException
(409)TooManyRequestsException
(429)BadGatewayException
(502) (yes, sometimes it happens)
-
Changes in Bot settings
- Changed behaviour of settings'
debug
parameter: now it creates an Error Handler async
: Concurrent handling of updatesrestart_on_changes
: Auto restart when Bot file is edited (optional)logger
:Monolog\Logger
constant for logging
- Changed behaviour of settings'
-
Now you can pass your custom
Monolog\Logger
, as the 3rd parameter of the Bot constructor -
Some improvements to Prototypes
$this
inside prototype now refers to the Object, so that$self
is no longer needed -
Fixed many bugs in HTML Entities Parser
v1.5.1 - Bug Fix Release
-
Fixed a bug with Prototypes and Objects
Prototypes Methods couldn't be added directly to objects
v1.5 - Source Code
-
Added positional arguments and named arguments (like
python kwargs
) to Types Methods (in a BC way)Check updated docs
-
Bot and Database Classes are now prototypeable
Learn more about prototypes here
-
Full Return Types implementation
-
Added some HTML tags to Entities Parser
Message::toHTML() is now removed in favor of Message::getHTMLText()
-
Built-in debug now looks like a normal exception
-
NULL
properties are no longer displayed in debug functions (such asvar_dump
,print_r
and similar) -
Updated docs
v1.4 - Source Code
-
Added Typed Properties with Description to every Object
-
Added non-dinamic Methods to Bot Class
-
Added positional arguments and named arguments (like
python kwargs
) to Bot Methods (in a BC way)Check updated docs
-
Added Entities Parser, and Message::toHTML() Method