From 6cc71a5c8efd72b591df775bdc667b64ae5670ab Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 15 Jul 2023 16:34:54 +0200 Subject: [PATCH] Cleanup changelog --- .gitignore | 1 + CHANGELOG.md | 95 +++------------------- README.md | 7 +- composer.json | 1 - docs | 2 +- examples/bot.php | 2 - tests/danog/MadelineProto/EntitiesTest.php | 13 +++ tests/makephar.sh | 2 +- 8 files changed, 32 insertions(+), 91 deletions(-) diff --git a/.gitignore b/.gitignore index 25dd441e9..cb5fef111 100644 --- a/.gitignore +++ b/.gitignore @@ -149,3 +149,4 @@ config.json /docker-compose.yml /Caddyfile /tt.php +/changelog diff --git a/CHANGELOG.md b/CHANGELOG.md index ca7c26c5f..d69f63fc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,92 +1,12 @@ Introducing MadelineProto's biggest update yet, 8.0.0-beta100! -This version introduces [plugins](https://docs.madelineproto.xyz/docs/PLUGINS.html), [bound methods](https://docs.madelineproto.xyz/docs/UPDATES.html#bound-methods), [filters](https://docs.madelineproto.xyz/docs/FILTERS.html), [a built-in cron system](https://docs.madelineproto.xyz/docs/UPDATES.html#cron), [IPC support for the event handler](https://docs.madelineproto.xyz/docs/UPDATES.html#persisting-data-and-ipc) and automatic static analysis for event handler code. +This version introduces [plugins »](https://docs.madelineproto.xyz/docs/PLUGINS.html), [bound methods »](https://docs.madelineproto.xyz/docs/UPDATES.html#bound-methods), [filters »](https://docs.madelineproto.xyz/docs/FILTERS.html), [a built-in cron system »](https://docs.madelineproto.xyz/docs/UPDATES.html#cron), [IPC support for the event handler »](https://docs.madelineproto.xyz/docs/UPDATES.html#persisting-data-and-ipc) and [automatic static analysis for event handler code »](https://docs.madelineproto.xyz/docs/UPDATES.html#automatic-static-analysis). -- [Plugins](https://docs.madelineproto.xyz/docs/PLUGINS.html) - -To create a plugin, simply create an event handler that extends PluginEventHandler. - -For example, create a `plugins/Danogentili/PingPlugin.php` file: -``` -commandArgs; - - $message->reply($args[0] ?? ''); - } - - #[FilterRegex('/.*(mt?proto).*/i')] - public function testRegex(Incoming & Message $message): void - { - $message->reply("Did you mean to write MadelineProto instead of ".$message->matches[1].'?'); - } - - #[FilterText('ping')] - public function pingCommand(Incoming&Message $message): void - { - $message->reply("Pong"); - } -} -``` - -And use a [plugin base](https://raw.githubusercontent.com/danog/MadelineProto/v8/examples/PluginBase.php) to run all plugins included in the `plugins` folder. - -See the [documentation](https://docs.madelineproto.xyz/docs/PLUGINS.html) for more info on how to create MadelineProto plugins! - -- [Message](https://docs.madelineproto.xyz/PHP/danog/MadelineProto/EventHandler/Message.html) objects with bound methods - -Both plugins and normal bots can make use of [bound update methods](https://docs.madelineproto.xyz/docs/UPDATES.html#bound-methods) like `reply()`, `delete()`, `getReply()`, `getHTML()` and simplified properties like `chatId`, `senderId`, `command`, `commandArgs` and many more, see the [documentation](https://docs.madelineproto.xyz/docs/UPDATES.html#bound-methods) for more info! - -- [Filters](https://docs.madelineproto.xyz/docs/FILTERS.html) - -Plugins and bots can now use three different filtering systems, to easily receive only updates satisfying certain conditions (incoming/outgoing, from group, channel, private, from an admin or a specific peer, with an audio/sticker/..., satisfying a certain regex or a certain /command, and much more!), [see the documentation](https://docs.madelineproto.xyz/docs/FILTERS.html) for more info! - -- [Built-in cron system](https://docs.madelineproto.xyz/docs/UPDATES.html#cron) - -All event handler methods marked by the `Cron` attribute are now automatically invoked by MadelineProto every `period` seconds: - -``` -use danog\MadelineProto\EventHandler\Attributes\Cron; - -class MyEventHandler extends SimpleEventHandler -{ - /** - * This cron function will be executed forever, every 60 seconds. - */ - #[Cron(period: 60.0)] - public function cron1(): void - { - $this->sendMessageToAdmins("The bot is online, current time ".date(DATE_RFC850)."!"); - } -} -``` - -See the [documentation](https://docs.madelineproto.xyz/docs/UPDATES.html#cron) for more info! - -- [IPC support for the event handler](https://docs.madelineproto.xyz/docs/UPDATES.html#persisting-data-and-ipc) - -You can now call event handler and plugin methods from outside of the event handler, using `getEventHandler()` on an `API` instance, see [the docs for more info](https://docs.madelineproto.xyz/docs/PLUGINS.html#limitations)! - -- Automatic static analysis of event handler code - -Finally, all new bots and plugins will be automatically analyzed by MadelineProto, blocking execution if performance or security issues are detected! +See the [following post](https://t.me/MadelineProto/630) for examples! Other features: - Thanks to the many translation contributors @ https://weblate.madelineproto.xyz/, MadelineProto is now localized in Hebrew, Persian, Kurdish, Uzbek, Russian, French and Italian! -- Added simplified sendMessage, sendDocument, sendPhoto methods that return abstract [Message](https://docs.madelineproto.xyz/PHP/danog/MadelineProto/EventHandler/Message.html) objects with simplified properties and bound methods! +- Added simplified [sendMessage](https://docs.madelineproto.xyz/PHP/danog/MadelineProto/API.html#sendmessage-int-string-peer-string-message-parsemode-parsemode-danog-madelineproto-parsemode-text-int-null-replytomsgid-null-int-null-topmsgid-null-array-null-replymarkup-null-int-null-sendas-null-int-null-scheduledate-null-bool-silent-false-bool-noforwards-false-bool-background-false-bool-cleardraft-false-bool-nowebpage-false-bool-updatestickersetsorder-false-danog-madelineproto-eventhandler-message), [sendDocument](https://docs.madelineproto.xyz/PHP/danog/MadelineProto/API.html#senddocument-int-string-peer-message-media-localfile-remoteurl-botapifileid-readablestream-file-message-media-localfile-remoteurl-botapifileid-readablestream-null-thumb-null-string-caption-parsemode-parsemode-danog-madelineproto-parsemode-text-callable-callback-null-string-filename-null-string-mimetype-null-int-ttl-null-bool-spoiler-false-int-null-replytomsgid-null-int-null-topmsgid-null-array-null-replymarkup-null-int-null-sendas-null-int-null-scheduledate-null-bool-silent-false-bool-noforwards-false-bool-background-false-bool-cleardraft-false-bool-updatestickersetsorder-false-danog-madelineproto-eventhandler-message), [sendPhoto](https://docs.madelineproto.xyz/PHP/danog/MadelineProto/API.html#sendphoto-int-string-peer-message-media-localfile-remoteurl-botapifileid-readablestream-file-string-caption-parsemode-parsemode-danog-madelineproto-parsemode-text-callable-callback-null-string-filename-null-int-ttl-null-bool-spoiler-false-int-null-replytomsgid-null-int-null-topmsgid-null-array-null-replymarkup-null-int-null-sendas-null-int-null-scheduledate-null-bool-silent-false-bool-noforwards-false-bool-background-false-bool-cleardraft-false-bool-updatestickersetsorder-false-danog-madelineproto-eventhandler-message) methods that return abstract [Message](https://docs.madelineproto.xyz/PHP/danog/MadelineProto/EventHandler/Message.html) objects with simplified properties and bound methods! - You can now use `Tools::callFork` to fork a new green thread! - You can now automatically pin messages broadcasted using `broadcastMessages`, `broadcastForwardMessages` by using the new `pin: true` parameter! - You can now use `sendMessageToAdmins` to send messages to the bot's admin (the peers returned by `getReportPeers`). @@ -99,6 +19,13 @@ Other features: - You can now use `reportMemoryProfile()` to generate and send a `pprof` memory profile to all report peers to debug the causes of high memory usage. - Added support for `pay`, `login_url`, `web_app` and `tg://user?id=` buttons in bot API syntax! - Added a `getAdminIds` function that returns the IDs of the admin of the bot (equal to the peers returned by getReportPeers in the event handler). +- Added a new `ParseMode` enum! +- Added support for HTML lists in parseMode! +- Fixed parsing of markdown code blocks! + +Breaking changes: +- Switched to a custom markdown parser with [bot API MarkdownV2](https://core.telegram.org/bots/api#markdownv2-style) syntax, which differs from the previous Markdown syntax supported by parsedown. +- Markdown text can't contain HTML anymore. Fixes: - Fixed file uploads with ext-uv! @@ -111,4 +38,6 @@ Fixes: - Reduced memory usage by clearing the min database automatically as needed. - Automatically try caching all dialogs if a peer not found error is about to be thrown. - Fixed some issues with pure phar installs. +- Fixed splitting of HTML and markdown messages +- Fixed formatting of multiline markdown codeblocks - And many other performance improvements and bugfixes! diff --git a/README.md b/README.md index 803bd33b8..61ca357f9 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ Want to add your own open-source project to this list? [Click here!](https://doc * [Restarting](https://docs.madelineproto.xyz/docs/UPDATES.html#restarting) * [Self-restart on webhosts](https://docs.madelineproto.xyz/docs/UPDATES.html#self-restart-on-webhosts) * [Multi-account](https://docs.madelineproto.xyz/docs/UPDATES.html#multiaccount) + * [Automatic static analysis](https://docs.madelineproto.xyz/docs/UPDATES.html#automatic-static-analysis) * [Webhook (for HTTP APIs)](https://docs.madelineproto.xyz/docs/UPDATES.html#webhook) * [getUpdates (only for Javascript APIs)](https://docs.madelineproto.xyz/docs/UPDATES.html#getUpdates) * [Noop (default)](https://docs.madelineproto.xyz/docs/UPDATES.html#noop) @@ -413,7 +414,7 @@ Want to add your own open-source project to this list? [Click here!](https://doc * Extract an update message constructor from an Updates constructor: extractMessageUpdate * Extract file info from bot API message: extractBotAPIFile * Fetch custom emoji stickers »: messages.getCustomEmojiDocuments - * Fetch new chats associated with an imported chat folder deep link ». Must be invoked at most every chatlist_update_period seconds (as per the related client configuration parameter »): chatlists.getChatlistUpdates + * Fetch new chats associated with an imported chat folder deep link ». Must be invoked at most every chatlistupdateperiod seconds (as per the related client configuration parameter »): chatlists.getChatlistUpdates * Fetch saved notification sounds: account.getSavedRingtones * Find out if a media message's caption can be edited: messages.getMessageEditData * Finish account takeout session: account.finishTakeoutSession @@ -575,7 +576,7 @@ Want to add your own open-source project to this list? [Click here!](https://doc * Get unread messages where we were mentioned: messages.getUnreadMentions * Get unread reactions to messages you sent: messages.getUnreadReactions * Get web login widget authorizations: account.getWebAuthorizations - * Get which users read a specific message: only available for groups and supergroups with less than chat_read_mark_size_threshold members, read receipts will be stored for chat_read_mark_expire_period seconds after the message was sent, see client configuration for more info »: messages.getMessageReadParticipants + * Get which users read a specific message: only available for groups and supergroups with less than chatreadmarksizethreshold members, read receipts will be stored for chatreadmarkexpireperiod seconds after the message was sent, see client configuration for more info »: messages.getMessageReadParticipants * Gets current notification settings for a given user/group, from all users/all groups: account.getNotifySettings * Gets featured custom emoji stickersets: messages.getFeaturedEmojiStickers * Gets the default value of the Time-To-Live setting, applied to all new chats: messages.getDefaultHistoryTTL @@ -637,7 +638,7 @@ Want to add your own open-source project to this list? [Click here!](https://doc * MTProto to TDCLI params: MTProtoToTdcli * Make a user admin in a basic group: messages.editChatAdmin * Manually convert HTML to a message and a set of entities: htmlToMessageEntities - * Manually convert markdown to a message and a set of entities: markdownToMessageEntities + * Manually convert markdown to a message and a set of entities: markdownToMessageEntities * Manually mark dialog as unread: messages.markDialogUnread * Mark channel/supergroup history as read: channels.readHistory * Mark channel/supergroup message contents as read: channels.readMessageContents diff --git a/composer.json b/composer.json index 4f49ea8d7..df51f3777 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,6 @@ "require": { "php-64bit": ">=8.1", "danog/primemodule": "^1", - "erusev/parsedown": "^1.7", "symfony/polyfill-mbstring": "*", "ext-mbstring": "*", "ext-json": "*", diff --git a/docs b/docs index d24140ca5..1dae2c3bc 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit d24140ca57f743943341d38777f1246f038ce63b +Subproject commit 1dae2c3bc73effbcd19cb61fe16e61050c1d6553 diff --git a/examples/bot.php b/examples/bot.php index f723a6a92..e4dbe0a59 100755 --- a/examples/bot.php +++ b/examples/bot.php @@ -30,9 +30,7 @@ use danog\MadelineProto\EventHandler\Filter\FilterText; use danog\MadelineProto\EventHandler\Message; use danog\MadelineProto\EventHandler\SimpleFilter\FromAdmin; use danog\MadelineProto\EventHandler\SimpleFilter\Incoming; -use danog\MadelineProto\LocalFile; use danog\MadelineProto\Logger; -use danog\MadelineProto\RemoteUrl; use danog\MadelineProto\Settings; use danog\MadelineProto\Settings\Database\Mysql; use danog\MadelineProto\Settings\Database\Postgres; diff --git a/tests/danog/MadelineProto/EntitiesTest.php b/tests/danog/MadelineProto/EntitiesTest.php index 3c64d9136..fdb7a5340 100644 --- a/tests/danog/MadelineProto/EntitiesTest.php +++ b/tests/danog/MadelineProto/EntitiesTest.php @@ -336,6 +336,19 @@ class EntitiesTest extends MadelineTestCase ], ], ], + [ + 'markdown', + '![link ](https://google.com/)', + 'link ', + [ + [ + 'offset' => 0, + 'length' => 4, + 'type' => 'text_url', + 'url' => 'https://google.com/' + ], + ], + ], [ 'html', 'link test', diff --git a/tests/makephar.sh b/tests/makephar.sh index 9257abdd5..63513d1fe 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -31,7 +31,7 @@ if [ "$TAG" == "" ]; then fi if [ "$TAG" != "7777" ]; then - grep -q "const RELEASE = '$TAG'" src/MTProto.php || { + grep -q "const RELEASE = '$TAG'" src/API.php || { echo "The RELEASE constant is not up to date!" exit 1 }