diff --git a/README.md b/README.md index 6a10512fc..50925f5b5 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ You can find examples for nearly every MadelineProto function in * Deletes profile photos: photos.deletePhotos * Deletes several contacts from the list: contacts.deleteContacts * Deletes the user from the blacklist: contacts.unblock + * Dismiss a suggestion: help.dismissSuggestion * Download a CDN file: upload.getCdnFile * Edit an inline bot message: messages.editInlineBotMessage * Edit location of geogroup: channels.editLocation @@ -273,10 +274,13 @@ You can find examples for nearly every MadelineProto function in * Get channel statistics: stats.getBroadcastStats * Get channel/supergroup messages: channels.getMessages * Get channels/supergroups/geogroups we're admin in. Usually called when the user exceeds the limit for owned public channels/supergroups/geogroups, and the user is given the choice to remove one of his channels/supergroups/geogroups: channels.getAdminedPublicChannels + * Get discussion message from the associated discussion group of a channel to show it on top of the comment section, without actually joining the group: messages.getDiscussionMessage * Get folders: messages.getDialogFilters * Get instant view page: messages.getWebPage + * Get message statistics: stats.getMessageStats * Get passport configuration: help.getPassportConfig * Get suggested folders: messages.getSuggestedDialogFilters + * Get supergroup statistics: stats.getMegagroupStats * Get a document by its SHA256 hash, mainly used for gifs: messages.getDocumentByHash * Get a list of channels/supergroups we left: channels.getLeftChannels * Get a payment form: payments.getPaymentForm @@ -301,6 +305,7 @@ You can find examples for nearly every MadelineProto function in * Get faved stickers: messages.getFavedStickers * Get featured stickers: messages.getFeaturedStickers * Get full info about a channel: channels.getFullChannel + * Get global privacy settings: account.getGlobalPrivacySettings * Get highscores of a game sent using an inline bot: messages.getInlineGameHighScores * Get highscores of a game: messages.getGameHighScores * Get inactive channels and supergroups: channels.getInactiveChannels @@ -324,8 +329,10 @@ You can find examples for nearly every MadelineProto function in * Get logged-in sessions: account.getAuthorizations * Get media autodownload settings: account.getAutoDownloadSettings * Get message ranges for saving the user's chat history: messages.getSplitRanges + * Get messages in a reply thread: messages.getReplies * Get more info about a Seamless Telegram Login authorization request, for more info click here »: messages.requestUrlAuth * Get most used peers: contacts.getTopPeers + * Get name, ISO code, localized name and phone codes/patterns of all available countries: help.getCountriesList * Get new updates: updates.getDifference * Get new strings in languagepack: langpack.getDifference * Get payment receipt: payments.getPaymentReceipt @@ -395,6 +402,7 @@ You can find examples for nearly every MadelineProto function in * Manually mark dialog as unread: messages.markDialogUnread * Mark channel/supergroup history as read: channels.readHistory * Mark channel/supergroup message contents as read: channels.readMessageContents + * Mark a thread as read: messages.readDiscussion * Mark a sticker as favorite: messages.faveSticker * Mark mentions as read: messages.readMentions * Mark new featured stickers as read: messages.readFeaturedStickers @@ -406,6 +414,7 @@ You can find examples for nearly every MadelineProto function in * Notify the other user in a private chat that a screenshot of the chat was taken: messages.sendScreenshotNotification * Notify the user that the sent passport data contains some errors The user will not be able to re-submit their Passport data to you until the errors are fixed (the contents of the field for which you returned the error must change): users.setSecureValueErrors * Obtain configuration for two-factor authorization with password: account.getPassword + * Obtains a list of messages, indicating to which other public channels was a channel message forwarded. : stats.getMessagePublicForwards * Once the user has confirmed their payment and shipping details, the bot receives an updateBotPrecheckoutQuery update. : messages.setBotPrecheckoutResults * Optional: notify the server that the user is currently busy in a call: this will automatically refuse all incoming phone calls until the current phone call is ended: phone.receivedCall * Pin a message: messages.updatePinnedMessage @@ -470,9 +479,10 @@ You can find examples for nearly every MadelineProto function in * Search for messages and peers globally: messages.searchGlobal * Search for stickersets: messages.searchStickerSets * Securely save Telegram Passport document, for more info see the passport docs »: account.saveSecureValue + * Send VoIP signaling data: phone.sendSignalingData * Send a media: messages.sendMedia * Send a result obtained using messages.getInlineBotResults: messages.sendInlineBotResult - * Send an album of media: messages.sendMultiMedia + * Send an album or grouped media: messages.sendMultiMedia * Send compiled payment form: payments.sendPaymentForm * Send confirmation code to cancel account deletion, for more info click here »: account.sendConfirmPhoneCode * Send phone call debug data to server: phone.saveCallDebug @@ -492,6 +502,7 @@ You can find examples for nearly every MadelineProto function in * Set a new 2FA password: account.updatePasswordSettings * Set account self-destruction period: account.setAccountTTL * Set bot command list: bots.setBotCommands + * Set global privacy settings: account.setGlobalPrivacySettings * Set sensitive content settings (for viewing or hiding NSFW content): account.setContentSettings * Set stickerset thumbnail: stickers.setStickerSetThumb * Set the callback answer to a user button press (bots only): messages.setBotCallbackAnswer @@ -499,6 +510,7 @@ You can find examples for nearly every MadelineProto function in * Signs in a user with a validated phone number: auth.signIn * Start a conversation with a bot using a deep linking parameter: messages.startBot * Start a telegram phone call: phone.requestCall + * Stop getting notifications about thread replies of a certain user in @replies: contacts.blockFromReplies * Submit requested order information for validation: payments.validateRequestedInfo * Terminates all user's authorized sessions except for the current one: auth.resetAuthorizations * Toggle contact sign up notifications: account.setContactSignUpNotification @@ -527,6 +539,7 @@ You can find examples for nearly every MadelineProto function in * When client-side passcode lock feature is enabled, will not show message texts in incoming PUSH notifications: account.updateDeviceLocked * Whether the user will receive notifications when contacts sign up: account.getContactSignUpNotification * Complete phone call E2E encryption key exchange »: phone.confirmCall + * Unpin all pinned messages: messages.unpinAllMessages * [Peers](https://docs.madelineproto.xyz/docs/USING_METHODS.html#peers) * [Files](https://docs.madelineproto.xyz/docs/FILES.html) * [Secret chats](https://docs.madelineproto.xyz/docs/USING_METHODS.html#secret-chats) diff --git a/examples/bot.php b/examples/bot.php index bac784187..29a225196 100755 --- a/examples/bot.php +++ b/examples/bot.php @@ -100,7 +100,7 @@ $settings->getLogger()->setLevel(Logger::LEVEL_ULTRA_VERBOSE); // $settings->setDb((new Postgres)->setDatabase('MadelineProto')->setUsername('daniil')->setPassword('pony')); // $settings->setDb((new Mysql)->setDatabase('MadelineProto')->setUsername('daniil')->setPassword('pony')); -$MadelineProto = new API('bot.madeline', $settings); +$MadelineProto = new API('uwu.madeline', $settings); // Reduce boilerplate with new wrapper method. // Also initializes error reporting, catching and reporting all errors surfacing from the event loop. diff --git a/examples/botAllMessages.php b/examples/botAllMessages.php index c4d02cb3a..952dd284b 100644 --- a/examples/botAllMessages.php +++ b/examples/botAllMessages.php @@ -37,18 +37,18 @@ if (\file_exists('vendor/autoload.php')) { $MadelineProto = new \danog\MadelineProto\API('bot.madeline'); $MadelineProto->async(true); -$MadelineProto->loop(static function() use($MadelineProto) { +$MadelineProto->loop(static function () use ($MadelineProto) { yield $MadelineProto->start(); $lastMessageId = 0; $threads = 5; $step = 20; $totalMessages = 0; - $start = microtime(true); - while(true) { + $start = \microtime(true); + while (true) { $promises = []; for ($i = 0; $i < $threads; $i++) { - $promises[] = $MadelineProto->messages->getMessages(['id' => range($lastMessageId+1, $lastMessageId+$step)]); + $promises[] = $MadelineProto->messages->getMessages(['id' => \range($lastMessageId+1, $lastMessageId+$step)]); $lastMessageId +=$step; } $results = yield \Amp\Promise\all($promises); @@ -62,6 +62,6 @@ $MadelineProto->loop(static function() use($MadelineProto) { } } }; - $time = microtime(true)-$start; + $time = \microtime(true)-$start; yield $MadelineProto->echo("\nTime: {$time}\n"); }); diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index e0047af24..f107f5a11 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -232,7 +232,7 @@ class API extends InternalDoc if ($this->API instanceof Client) { $this->logger->logger("Restarting to full instance..."); try { - if (!isset($_GET['MadelineSelfRestart']) && yield $this->hasEventHandler()) { + if (!isset($_GET['MadelineSelfRestart']) && ((yield $this->hasEventHandler()) || !(yield $this->isIpcWorker()))) { $this->logger->logger("Restarting to full instance: the bot is already running!"); MTProto::closeConnection('The bot is already running!'); return false; @@ -256,7 +256,7 @@ class API extends InternalDoc return; } $API = new Client($result, $this->session, Logger::$default, $this->async); - if (yield from $API->hasEventHandler()) { + if ((yield from $API->hasEventHandler()) || !(yield from $API->isIpcWorker())) { $this->logger->logger("Restarting to full instance (again): the bot is already running!"); yield $API->disconnect(); $API->unreference(); diff --git a/src/danog/MadelineProto/InternalDoc.php b/src/danog/MadelineProto/InternalDoc.php index e2b0627df..38e4ce4db 100644 --- a/src/danog/MadelineProto/InternalDoc.php +++ b/src/danog/MadelineProto/InternalDoc.php @@ -1021,17 +1021,17 @@ interface account public function getMultiWallPapers($params); /** - * + * Get global privacy settings. * * @return GlobalPrivacySettings */ public function getGlobalPrivacySettings(); /** - * + * Set global privacy settings. * * Parameters: - * * `GlobalPrivacySettings` **settings** -. + * * `GlobalPrivacySettings` **settings** - Global privacy settings * * @param array $params Parameters * @@ -1157,7 +1157,7 @@ interface contacts * Adds the user to the blacklist. * * Parameters: - * * `InputPeer` **id** - + * * `InputPeer` **id** - User ID * * @param array $params Parameters * @@ -1169,7 +1169,7 @@ interface contacts * Deletes the user from the blacklist. * * Parameters: - * * `InputPeer` **id** - + * * `InputPeer` **id** - User ID * * @param array $params Parameters * @@ -1321,13 +1321,13 @@ interface contacts public function getLocated($params); /** - * + * Stop getting notifications about [thread replies](https://core.telegram.org/api/threads) of a certain user in `@replies`. * * Parameters: - * * `boolean` **delete_message** - Optional: - * * `boolean` **delete_history** - Optional: - * * `boolean` **report_spam** - Optional: - * * `int` **msg_id** -. + * * `boolean` **delete_message** - Optional: Whether to delete the specified message as well + * * `boolean` **delete_history** - Optional: Whether to delete all `@replies` messages from this user as well + * * `boolean` **report_spam** - Optional: Whether to also report this user for spam + * * `int` **msg_id** - ID of the message in the [@replies](https://core.telegram.org/api/threads#replies) chat * * @param array $params Parameters * @@ -1393,8 +1393,8 @@ interface messages * Parameters: * * `InputPeer` **peer** - User or chat, histories with which are searched, or [(inputPeerEmpty)](https://docs.madelineproto.xyz/API_docs/constructors/inputPeerEmpty.html) constructor for global search * * `string` **q** - Text search request - * * `InputPeer` **from_id** - Optional: - * * `int` **top_msg_id** - Optional: + * * `InputPeer` **from_id** - Optional: Only return messages sent by the specified user ID + * * `int` **top_msg_id** - Optional: [Thread ID](https://core.telegram.org/api/threads) * * `MessagesFilter` **filter** - Filter to return only specified message types * * `int` **min_date** - If a positive value was transferred, only messages with a sending date bigger than the transferred one will be returned * * `int` **max_date** - If a positive value was transferred, only messages with a sending date smaller than the transferred one will be returned @@ -1469,7 +1469,7 @@ interface messages * * Parameters: * * `InputPeer` **peer** - Target user or group - * * `int` **top_msg_id** - Optional: + * * `int` **top_msg_id** - Optional: [Thread ID](https://core.telegram.org/api/threads) * * `SendMessageAction` **action** - Type of action
Parameter added in [Layer 17](https://core.telegram.org/api/layers#layer-17). * * @param array $params Parameters @@ -1491,7 +1491,7 @@ interface messages * * `string` **message** - The message * * `ReplyMarkup` **reply_markup** - Optional: Reply markup for sending bot buttons * * `[MessageEntity]` **entities** - Optional: Message [entities](https://core.telegram.org/api/entities) for sending styled text - * * `int` **schedule_date** - Optional: Scheduled message date for scheduled messages + * * `int` **schedule_date** - Optional: Scheduled message date for [scheduled messages](https://core.telegram.org/api/scheduled-messages) * * @param array $params Parameters * @@ -1512,7 +1512,7 @@ interface messages * * `string` **message** - Caption * * `ReplyMarkup` **reply_markup** - Optional: Reply markup for bot keyboards * * `[MessageEntity]` **entities** - Optional: Message [entities](https://core.telegram.org/api/entities) for styled text - * * `int` **schedule_date** - Optional: Scheduled message date for scheduled messages + * * `int` **schedule_date** - Optional: Scheduled message date for [scheduled messages](https://core.telegram.org/api/scheduled-messages) * * @param array $params Parameters * @@ -1748,7 +1748,7 @@ interface messages * Sends a text message to a secret chat. * * Parameters: - * * `boolean` **silent** - Optional: + * * `boolean` **silent** - Optional: Send encrypted message without a notification * * `InputEncryptedChat` **peer** - Secret chat ID * * `DecryptedMessage` **message** - * @@ -1762,7 +1762,7 @@ interface messages * Sends a message with a file attachment to a secret chat. * * Parameters: - * * `boolean` **silent** - Optional: + * * `boolean` **silent** - Optional: Whether to send the file without triggering a notification * * `InputEncryptedChat` **peer** - Secret chat ID * * `DecryptedMessage` **message** - * * `InputEncryptedFile` **file** - File attachment for the secret chat @@ -1993,9 +1993,9 @@ interface messages * Parameters: * * `int` **folder_id** - Optional: [Peer folder ID, for more info click here](https://core.telegram.org/api/folders#peer-folders) * * `string` **q** - Query - * * `MessagesFilter` **filter** - - * * `int` **min_date** - - * * `int` **max_date** - + * * `MessagesFilter` **filter** - Global search filter + * * `int` **min_date** - If a positive value was specified, the method will return only messages with date bigger than min\_date + * * `int` **max_date** - If a positive value was transferred, the method will return only messages with date smaller than max\_date * * `int` **offset_rate** - Initially 0, then set to the [`next_rate` parameter of messages.messagesSlice](https://docs.madelineproto.xyz/API_docs/constructors/messages.messagesSlice.html) * * `InputPeer` **offset_peer** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) * * `int` **offset_id** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) @@ -2137,7 +2137,7 @@ interface messages * * `InputMedia` **media** - Optional: New attached media * * `ReplyMarkup` **reply_markup** - Optional: Reply markup for inline keyboards * * `[MessageEntity]` **entities** - Optional: [Message entities for styled text](https://core.telegram.org/api/entities) - * * `int` **schedule_date** - Optional: Scheduled message date for scheduled messages + * * `int` **schedule_date** - Optional: Scheduled message date for [scheduled messages](https://core.telegram.org/api/scheduled-messages) * * @param array $params Parameters * @@ -2170,7 +2170,7 @@ interface messages * * `InputPeer` **peer** - Where was the inline keyboard sent * * `int` **msg_id** - ID of the Message with the inline keyboard * * `bytes` **data** - Optional: Callback data - * * `InputCheckPasswordSRP` **password** - Optional: + * * `InputCheckPasswordSRP` **password** - Optional: For buttons [requiring you to verify your identity with your 2FA password](https://docs.madelineproto.xyz/API_docs/constructors/keyboardButtonCallback.html), the SRP payload generated using [SRP](https://core.telegram.org/api/srp). * * @param array $params Parameters * @@ -2593,7 +2593,7 @@ interface messages public function getRecentLocations($params); /** - * Send an album of media. + * Send an [album or grouped media](https://core.telegram.org/api/files#albums-grouped-media). * * Parameters: * * `boolean` **silent** - Optional: Whether to send the album silently (no notification triggered) @@ -2676,10 +2676,10 @@ interface messages * * Parameters: * * `boolean` **silent** - Optional: Pin the message silently, without triggering a notification - * * `boolean` **unpin** - Optional: - * * `boolean` **pm_oneside** - Optional: + * * `boolean` **unpin** - Optional: Whether the message should unpinned or pinned + * * `boolean` **pm_oneside** - Optional: Whether the message should only be pinned on the local side of a one-to-one chat * * `InputPeer` **peer** - The peer where to pin the message - * * `int` **id** - The message to pin, can be 0 to unpin any currently pinned messages + * * `int` **id** - The message to pin or unpin * * @param array $params Parameters * @@ -3006,18 +3006,18 @@ interface messages public function getOldFeaturedStickers($params); /** - * + * Get messages in a reply thread. * * Parameters: - * * `InputPeer` **peer** - - * * `int` **msg_id** - - * * `int` **offset_id** - - * * `int` **offset_date** - - * * `int` **add_offset** - - * * `int` **limit** - - * * `int` **max_id** - - * * `int` **min_id** - - * * `[int]` **hash** - Optional:. + * * `InputPeer` **peer** - Peer + * * `int` **msg_id** - Message ID + * * `int` **offset_id** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) + * * `int` **offset_date** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) + * * `int` **add_offset** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) + * * `int` **limit** - Maximum number of results to return, [see pagination](https://core.telegram.org/api/offsets) + * * `int` **max_id** - If a positive value was transferred, the method will return only messages with ID smaller than max\_id + * * `int` **min_id** - If a positive value was transferred, the method will return only messages with ID bigger than min\_id + * * `[int]` **hash** - Optional: [Hash for pagination, for more info click here](https://core.telegram.org/api/offsets#hash-generation) * * @param array $params Parameters * @@ -3026,11 +3026,11 @@ interface messages public function getReplies($params); /** - * + * Get [discussion message](https://core.telegram.org/api/threads) from the [associated discussion group](https://core.telegram.org/api/discussion) of a channel to show it on top of the comment section, without actually joining the group. * * Parameters: - * * `InputPeer` **peer** - - * * `int` **msg_id** -. + * * `InputPeer` **peer** - [Channel ID](https://core.telegram.org/api/channel) + * * `int` **msg_id** - Message ID * * @param array $params Parameters * @@ -3039,12 +3039,12 @@ interface messages public function getDiscussionMessage($params); /** - * + * Mark a [thread](https://core.telegram.org/api/threads) as read. * * Parameters: - * * `InputPeer` **peer** - - * * `int` **msg_id** - - * * `int` **read_max_id** -. + * * `InputPeer` **peer** - Group ID + * * `int` **msg_id** - ID of message that started the thread + * * `int` **read_max_id** - ID up to which thread messages were read * * @param array $params Parameters * @@ -3053,10 +3053,10 @@ interface messages public function readDiscussion($params); /** - * + * [Unpin](https://core.telegram.org/api/pin) all pinned messages. * * Parameters: - * * `InputPeer` **peer** -. + * * `InputPeer` **peer** - Chat where to unpin * * @param array $params Parameters * @@ -3125,8 +3125,8 @@ interface photos * * Parameters: * * `InputFile` **file** - Optional: File saved in parts by means of [upload.saveFilePart](https://docs.madelineproto.xyz/API_docs/methods/upload.saveFilePart.html) method - * * `InputFile` **video** - Optional: - * * `double` **video_start_ts** - Optional: + * * `InputFile` **video** - Optional: [Animated profile picture](https://core.telegram.org/api/files#animated-profile-pictures) video + * * `double` **video_start_ts** - Optional: Floating point UNIX timestamp in seconds, indicating the frame of the video that should be used as static preview. * * @param array $params Parameters * @@ -3479,10 +3479,10 @@ interface help public function hidePromoData($params); /** - * + * Dismiss a suggestion. * * Parameters: - * * `string` **suggestion** -. + * * `string` **suggestion** - Suggestion * * @param array $params Parameters * @@ -3491,11 +3491,11 @@ interface help public function dismissSuggestion($params); /** - * + * Get name, ISO code, localized name and phone codes/patterns of all available countries. * * Parameters: - * * `string` **lang_code** - - * * `[int]` **hash** - Optional:. + * * `string` **lang_code** - Language code of the current user + * * `[int]` **hash** - Optional: [Hash for pagination, for more info click here](https://core.telegram.org/api/offsets#hash-generation) * * @param array $params Parameters * @@ -3762,8 +3762,8 @@ interface channels * Get link and embed info of a message in a [channel/supergroup](https://core.telegram.org/api/channel). * * Parameters: - * * `boolean` **grouped** - Optional: - * * `boolean` **thread** - Optional: + * * `boolean` **grouped** - Optional: Whether to include other grouped media (for albums) + * * `boolean` **thread** - Optional: Whether to also include a thread ID, if available, inside of the link * * `InputChannel` **channel** - Channel * * `int` **id** - Message ID * @@ -3896,18 +3896,21 @@ interface channels public function getLeftChannels($params); /** - * Get all groups that can be used as [discussion groups](https://telegram.org/blog/privacy-discussions-web-bots). + * Get all groups that can be used as [discussion groups](https://core.telegram.org/api/discussion). + * + * Returned [legacy group chats](https://core.telegram.org/api/channel) must be first upgraded to [supergroups](https://core.telegram.org/api/channel) before they can be set as a discussion group. + * To set a returned supergroup as a discussion group, access to its old messages must be enabled using [channels.togglePreHistoryHidden](https://docs.madelineproto.xyz/API_docs/methods/channels.togglePreHistoryHidden.html), first. * * @return messages.Chats */ public function getGroupsForDiscussion(); /** - * Associate a group to a channel as [discussion group](https://telegram.org/blog/privacy-discussions-web-bots) for that channel. + * Associate a group to a channel as [discussion group](https://core.telegram.org/api/discussion) for that channel. * * Parameters: * * `InputChannel` **broadcast** - Channel - * * `InputChannel` **group** - Discussion group to associate to the channel + * * `InputChannel` **group** - [Discussion group](https://core.telegram.org/api/discussion) to associate to the channel * * @param array $params Parameters * @@ -4275,11 +4278,11 @@ interface phone public function saveCallDebug($params); /** - * + * Send VoIP signaling data. * * Parameters: - * * `InputPhoneCall` **peer** - - * * `bytes` **data** -. + * * `InputPhoneCall` **peer** - Phone call + * * `bytes` **data** - Signaling payload * * @param array $params Parameters * @@ -4413,11 +4416,11 @@ interface stats public function loadAsyncGraph($params); /** - * + * Get [supergroup statistics](https://core.telegram.org/api/stats). * * Parameters: - * * `boolean` **dark** - Optional: - * * `InputChannel` **channel** -. + * * `boolean` **dark** - Optional: Whether to enable dark theme for graph colors + * * `InputChannel` **channel** - [Supergroup ID](https://core.telegram.org/api/channel) * * @param array $params Parameters * @@ -4426,15 +4429,16 @@ interface stats public function getMegagroupStats($params); /** - * + * Obtains a list of messages, indicating to which other public channels was a channel message forwarded. + * Will return a list of [messages](https://docs.madelineproto.xyz/API_docs/constructors/message.html) with `peer_id` equal to the public channel to which this message was forwarded. * * Parameters: - * * `InputChannel` **channel** - - * * `int` **msg_id** - - * * `int` **offset_rate** - - * * `InputPeer` **offset_peer** - - * * `int` **offset_id** - - * * `int` **limit** -. + * * `InputChannel` **channel** - Source channel + * * `int` **msg_id** - Source message ID + * * `int` **offset_rate** - Initially 0, then set to the `next_rate` parameter of [messages.messagesSlice](https://docs.madelineproto.xyz/API_docs/constructors/messages.messagesSlice.html) + * * `InputPeer` **offset_peer** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) + * * `int` **offset_id** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) + * * `int` **limit** - Maximum number of results to return, [see pagination](https://core.telegram.org/api/offsets) * * @param array $params Parameters * @@ -4443,12 +4447,12 @@ interface stats public function getMessagePublicForwards($params); /** - * + * Get [message statistics](https://core.telegram.org/api/stats). * * Parameters: - * * `boolean` **dark** - Optional: - * * `InputChannel` **channel** - - * * `int` **msg_id** -. + * * `boolean` **dark** - Optional: Whether to enable dark theme for graph colors + * * `InputChannel` **channel** - Channel ID + * * `int` **msg_id** - Message ID * * @param array $params Parameters * @@ -4705,9 +4709,9 @@ class InternalDoc extends APIFactory * * @return void */ - public function closeConnection($message = 'OK!', array $extra = []) + public function closeConnection($message = 'OK!') { - return $this->__call(__FUNCTION__, [$message, $extra]); + return $this->__call(__FUNCTION__, [$message]); } /** * Complete 2FA login. @@ -4991,7 +4995,7 @@ class InternalDoc extends APIFactory * @param ?Promise $token Cancellation token * @param ?callable $failureCb Failure callback, called only once if the first locking attempt fails. * - * @return \Amp\Promise + * @return \Amp\Promise<$token is null ? callable : ?callable> */ public function flock(string $file, int $operation, float $polling = 0.1, ?\Amp\Promise $token = null, $failureCb = null) { @@ -5598,6 +5602,16 @@ class InternalDoc extends APIFactory { return $this->__call(__FUNCTION__, []); } + /** + * Whether we're an IPC server process (as opposed to an event handler). + * + * @psalm-return bool|\Amp\Promise + * @return mixed + */ + public function isIpcWorker() + { + return $this->__call(__FUNCTION__, []); + } /** * Check whether provided bot API ID is a channel. * diff --git a/src/danog/MadelineProto/Loop/Connection/CleanupLoop.php b/src/danog/MadelineProto/Loop/Connection/CleanupLoop.php index c81c70c5a..f0da57fc5 100644 --- a/src/danog/MadelineProto/Loop/Connection/CleanupLoop.php +++ b/src/danog/MadelineProto/Loop/Connection/CleanupLoop.php @@ -19,10 +19,8 @@ namespace danog\MadelineProto\Loop\Connection; -use Amp\Deferred; use Amp\Loop; use danog\Loop\ResumableSignalLoop; -use danog\MadelineProto\Tools; /** * Message cleanup loop. diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 53de73c2a..90e6ee7b7 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -1365,6 +1365,15 @@ class MTProto extends AsyncConstruct implements TLCallback { return false; } + /** + * Whether we're an IPC server process (as opposed to an event handler). + * + * @return boolean + */ + public function isIpcWorker(): bool + { + return Magic::$isIpcWorker; + } /** * Parse, update and store settings. * diff --git a/src/danog/MadelineProto/SessionPaths.php b/src/danog/MadelineProto/SessionPaths.php index e98befb6e..ad5ee3986 100644 --- a/src/danog/MadelineProto/SessionPaths.php +++ b/src/danog/MadelineProto/SessionPaths.php @@ -106,7 +106,7 @@ class SessionPaths $l += yield $file->write($object); yield $file->close(); - if ($l !== ($need = strlen(Serialization::PHP_HEADER)+1+strlen($object))) { + if ($l !== ($need = \strlen(Serialization::PHP_HEADER)+1+\strlen($object))) { throw new Exception("Did not write all the data (need $need, wrote $l)"); } yield renameAsync("$path.temp.php", $path); diff --git a/src/danog/MadelineProto/TON/InternalDoc.php b/src/danog/MadelineProto/TON/InternalDoc.php index e84d1be4b..51fd8cac1 100644 --- a/src/danog/MadelineProto/TON/InternalDoc.php +++ b/src/danog/MadelineProto/TON/InternalDoc.php @@ -1088,7 +1088,7 @@ class InternalDoc extends APIFactory * @param ?Promise $token Cancellation token * @param ?callable $failureCb Failure callback, called only once if the first locking attempt fails. * - * @return \Amp\Promise + * @return \Amp\Promise<$token is null ? callable : ?callable> */ public function flock(string $file, int $operation, float $polling = 0.1, ?\Amp\Promise $token = null, $failureCb = null) {