diff --git a/README.md b/README.md
index 147418ee..cdc7acb6 100644
--- a/README.md
+++ b/README.md
@@ -175,324 +175,324 @@ Tip: if you receive an error (or nothing), [send us](https://t.me/pwrtelegramgro
* [Upload or download files up to 1.5 GB](https://docs.madelineproto.xyz/docs/FILES.html)
* [Make a phone call and play a song](https://docs.madelineproto.xyz/docs/CALLS.html)
* [Create a secret chat bot](https://docs.madelineproto.xyz/docs/SECRET_CHATS.html)
- * Accept URL authorization: messages.acceptUrlAuth
- * Accept contact: contacts.acceptContact
- * Accept telegram passport authorization: account.acceptAuthorization
- * Accept telegram's TOS: help.acceptTermsOfService
- * Add a sticker set: messages.installStickerSet
- * Add a sticker to favorites: messages.faveSticker
- * Add a sticker to recent stickers: messages.saveRecentSticker
- * Add a user to a normal chat (use channels->inviteToChannel for supergroups): messages.addChatUser
- * Add contact: contacts.addContact
- * Add phone number as contact: contacts.importContacts
- * Add sticker to stickerset: stickers.addStickerToSet
- * Add users to channel/supergroup: channels.inviteToChannel
- * Block a user: contacts.block
- * Bots only: get telegram passport authorization form: account.getAuthorizationForm
- * Bots only: send payment form: payments.sendPaymentForm
- * Bots only: set precheckout results: messages.setBotPrecheckoutResults
- * Bots only: set shipping results: messages.setBotShippingResults
- * Bots only: set the callback answer (after a button was clicked): messages.setBotCallbackAnswer
- * Bots only: set the results of an inline query: messages.setInlineBotResults
- * Call inline bot: messages.getInlineBotResults
- * Cancel password recovery email: account.cancelPasswordEmail
- * Change notification settings: account.updateNotifySettings
- * Change sticker position in photo: stickers.changeStickerPosition
- * Change the phone number associated to this account: account.changePhone
- * Change the phone number: account.sendChangePhoneCode
- * Change the profile photo: photos.updateProfilePhoto
- * Change typing status: messages.setTyping
- * Check if about to edit a message or a media caption: messages.getMessageEditData
- * Check if an invitation link is valid: messages.checkChatInvite
- * Check if this username is available: account.checkUsername
- * Check if this username is free and can be assigned to a channel/supergroup: channels.checkUsername
- * Clear all drafts: messages.clearAllDrafts
- * Clear all recent stickers: messages.clearRecentStickers
- * Clear saved payments info: payments.clearSavedInfo
- * Confirm password recovery using email: account.confirmPasswordEmail
- * Confirm this phone number is associated to this account, obtain phone_code_hash from sendConfirmPhoneCode: account.confirmPhone
- * Contact signup notification setting value: account.getContactSignUpNotification
- * Convert chat to supergroup: messages.migrateChat
- * Create a chat (not supergroup): messages.createChat
- * Create a theme: account.createTheme
- * Create channel/supergroup: channels.createChannel
- * Create stickerset: stickers.createStickerSet
- * Delete a certain session: account.resetAuthorization
- * Delete a certain telegram web login authorization: account.resetWebAuthorization
- * Delete a channel/supergroup: channels.deleteChannel
- * Delete a user from a chat (not supergroup): messages.deleteChatUser
- * Delete all logged-in sessions.: auth.resetAuthorizations
- * Delete all messages of a user in a channel/supergroup: channels.deleteUserHistory
- * Delete all temporary authorization keys except the ones provided: auth.dropTempAuthKeys
- * Delete channel/supergroup messages: channels.deleteMessages
- * Delete chat history: messages.deleteHistory
- * Delete contacts by phones: contacts.deleteByPhones
- * Delete folder: folders.deleteFolder
- * Delete messages: messages.deleteMessages
- * Delete multiple contacts: contacts.deleteContacts
- * Delete profile photos: photos.deletePhotos
- * Delete scheduled messages: messages.deleteScheduledMessages
- * Delete secure telegram passport value: account.deleteSecureValue
- * Delete the history of a supergroup/channel: channels.deleteHistory
- * Delete this account: account.deleteAccount
- * Disable all notifications for a certain period: account.updateDeviceLocked
- * Download a file through telegram: upload.getWebFile
- * Edit a message: messages.editMessage
- * Edit a sent inline message: messages.editInlineBotMessage
- * Edit admin permissions of a user in a channel/supergroup: channels.editAdmin
- * Edit admin permissions: messages.editChatAdmin
- * Edit chat info: messages.editChatAbout
- * Edit creator of channel: channels.editCreator
- * Edit default rights of chat: messages.editChatDefaultBannedRights
- * Edit folder: folders.editPeerFolders
- * Edit location (geochats): channels.editLocation
- * Edit the photo of a normal chat (not supergroup): messages.editChatPhoto
- * Edit the photo of a supergroup/channel: channels.editPhoto
- * Edit the title of a normal chat (not supergroup): messages.editChatTitle
- * Edit the title of a supergroup/channel: channels.editTitle
- * Edit user info: help.editUserInfo
- * Enable or disable hidden history for new channel/supergroup users: channels.togglePreHistoryHidden
- * Export chat invite : messages.exportChatInvite
- * Find a sticker set: messages.searchStickerSets
- * Finish account exporting session: account.finishTakeoutSession
- * Forward messages: messages.forwardMessages
- * Get CDN configuration: help.getCdnConfig
- * Get a stickerset: messages.getStickerSet
- * Get account TTL: account.getAccountTTL
- * Get admin log of a channel/supergroup: channels.getAdminLog
- * Get all archived stickers: messages.getArchivedStickers
- * Get all channels you left: channels.getLeftChannels
- * Get all chats (not supergroups or channels): messages.getAllChats
- * Get all contacts: contacts.getContacts
- * Get all logged-in authorizations: account.getAuthorizations
- * Get all message drafts: messages.getAllDrafts
- * Get all secure telegram passport values: account.getAllSecureValues
- * Get all stickerpacks: messages.getAllStickers
- * Get all supergroups/channels where you're admin: channels.getAdminedPublicChannels
- * Get and increase message views: messages.getMessagesViews
- * Get app config: help.getAppConfig
- * Get autodownload settings: account.getAutoDownloadSettings
- * Get available languages: langpack.getLanguages
- * Get blocked users: contacts.getBlocked
- * Get call configuration: phone.getCallConfig
- * Get channel/supergroup messages: channels.getMessages
- * Get channel/supergroup participants (you should use `$MadelineProto->getPwrChat($id)` instead): channels.getParticipants
- * Get chats in common with a user: messages.getCommonChats
- * Get contacts by IDs: contacts.getContactIDs
- * Get deep link info: help.getDeepLinkInfo
- * Get dialog info of peers: messages.getPeerDialogs
- * Get dialogs marked as unread manually: messages.getDialogUnreadMarks
- * Get document by SHA256 hash: messages.getDocumentByHash
- * Get emoji URL: messages.getEmojiURL
- * Get emoji keyword difference: messages.getEmojiKeywordsDifference
- * Get emoji keyword languages: messages.getEmojiKeywordsLanguages
- * Get emoji keywords: messages.getEmojiKeywords
- * Get favorite stickers: messages.getFavedStickers
- * Get featured stickers: messages.getFeaturedStickers
- * Get file hashes: upload.getFileHashes
- * Get groups for discussion: channels.getGroupsForDiscussion
- * Get high scores of a game sent in an inline message: messages.getInlineGameHighScores
- * Get high scores of a game: messages.getGameHighScores
- * Get info about a certain channel/supergroup participant: channels.getParticipant
- * Get info about app updates: help.getAppUpdate
- * Get info about chats: messages.getChats
- * Get info about multiple channels/supergroups: channels.getChannels
- * Get info about users: users.getUsers
- * Get info of support user: help.getSupport
- * Get information about the current proxy: help.getProxyData
- * Get installed themes: account.getThemes
- * Get invitation text: help.getInviteText
- * Get language pack strings: langpack.getStrings
- * Get language pack updates: langpack.getDifference
- * Get language pack: langpack.getLangPack
- * Get language: langpack.getLanguage
- * Get masks: messages.getMaskStickers
- * Get message ranges to fetch: messages.getSplitRanges
- * Get messages: messages.getMessages
- * Get most used chats: contacts.getTopPeers
- * Get nearest datacenter: help.getNearestDc
- * Get notification exceptions: account.getNotifyExceptions
- * Get notification settings: account.getNotifySettings
- * Get online status of all users: contacts.getStatuses
- * Get online users: messages.getOnlines
- * Get passport config: help.getPassportConfig
- * Get payment form: payments.getPaymentForm
- * Get payment receipt: payments.getPaymentReceipt
- * Get people nearby (geochats): contacts.getLocated
- * Get pinned dialogs: messages.getPinnedDialogs
- * Get poll results: messages.getPollResults
- * Get previous messages of a group: messages.getHistory
- * Get privacy settings: account.getPrivacy
- * Get recent locations: messages.getRecentLocations
- * Get recent stickers: messages.getRecentStickers
- * Get recent t.me URLs: help.getRecentMeUrls
- * Get saved contacts: contacts.getSaved
- * Get saved gifs: messages.getSavedGifs
- * Get saved payments info: payments.getSavedInfo
- * Get scheduled history: messages.getScheduledHistory
- * Get scheduled messages: messages.getScheduledMessages
- * Get search counter: messages.getSearchCounters
- * Get secure value for telegram passport: account.getSecureValue
- * Get server configuration: help.getConfig
- * Get stats URL: messages.getStatsURL
- * Get stickers attachable to images: messages.getAttachedStickers
- * Get stickers: messages.getStickers
- * Get support name: help.getSupportName
- * Get telegram web login authorizations: account.getWebAuthorizations
- * Get temporary password for buying products through bots: account.getTmpPassword
- * Get the callback answer of a bot (after clicking a button): messages.getBotCallbackAnswer
- * Get the changelog of this app: help.getAppChangelog
- * Get the current 2FA settings: account.getPasswordSettings
- * Get the current password: account.getPassword
- * Get the link of a message in a channel: channels.exportMessageLink
- * Get the profile photos of a user: photos.getUserPhotos
- * Get the settings of apeer: messages.getPeerSettings
- * Get theme information: account.getTheme
- * Get unread mentions: messages.getUnreadMentions
- * Get updated TOS: help.getTermsOfServiceUpdate
- * Get user info: help.getUserInfo
- * Get wallpaper info: account.getWallPaper
- * Get webpage preview: messages.getWebPage
- * Get webpage preview: messages.getWebPagePreview
- * Gets list of chats: you should use $MadelineProto->getDialogs() instead: https://docs.madelineproto.xyz/docs/DIALOGS.html: messages.getDialogs
- * Global message search: messages.searchGlobal
- * Hide peer settings bar: messages.hidePeerSettingsBar
- * Import chat invite: messages.importChatInvite
+ * Accept URL authorization: messages.acceptUrlAuth
+ * Accept contact: contacts.acceptContact
+ * Accept telegram passport authorization: account.acceptAuthorization
+ * Accept telegram's TOS: help.acceptTermsOfService
+ * Add a sticker set: messages.installStickerSet
+ * Add a sticker to favorites: messages.faveSticker
+ * Add a sticker to recent stickers: messages.saveRecentSticker
+ * Add a user to a normal chat (use channels->inviteToChannel for supergroups): messages.addChatUser
+ * Add contact: contacts.addContact
+ * Add phone number as contact: contacts.importContacts
+ * Add sticker to stickerset: stickers.addStickerToSet
+ * Add users to channel/supergroup: channels.inviteToChannel
+ * Block a user: contacts.block
+ * Bots only: get telegram passport authorization form: account.getAuthorizationForm
+ * Bots only: send payment form: payments.sendPaymentForm
+ * Bots only: set precheckout results: messages.setBotPrecheckoutResults
+ * Bots only: set shipping results: messages.setBotShippingResults
+ * Bots only: set the callback answer (after a button was clicked): messages.setBotCallbackAnswer
+ * Bots only: set the results of an inline query: messages.setInlineBotResults
+ * Call inline bot: messages.getInlineBotResults
+ * Cancel password recovery email: account.cancelPasswordEmail
+ * Change notification settings: account.updateNotifySettings
+ * Change sticker position in photo: stickers.changeStickerPosition
+ * Change the phone number associated to this account: account.changePhone
+ * Change the phone number: account.sendChangePhoneCode
+ * Change the profile photo: photos.updateProfilePhoto
+ * Change typing status: messages.setTyping
+ * Check if about to edit a message or a media caption: messages.getMessageEditData
+ * Check if an invitation link is valid: messages.checkChatInvite
+ * Check if this username is available: account.checkUsername
+ * Check if this username is free and can be assigned to a channel/supergroup: channels.checkUsername
+ * Clear all drafts: messages.clearAllDrafts
+ * Clear all recent stickers: messages.clearRecentStickers
+ * Clear saved payments info: payments.clearSavedInfo
+ * Confirm password recovery using email: account.confirmPasswordEmail
+ * Confirm this phone number is associated to this account, obtain phone_code_hash from sendConfirmPhoneCode: account.confirmPhone
+ * Contact signup notification setting value: account.getContactSignUpNotification
+ * Convert chat to supergroup: messages.migrateChat
+ * Create a chat (not supergroup): messages.createChat
+ * Create a theme: account.createTheme
+ * Create channel/supergroup: channels.createChannel
+ * Create stickerset: stickers.createStickerSet
+ * Delete a certain session: account.resetAuthorization
+ * Delete a certain telegram web login authorization: account.resetWebAuthorization
+ * Delete a channel/supergroup: channels.deleteChannel
+ * Delete a user from a chat (not supergroup): messages.deleteChatUser
+ * Delete all logged-in sessions.: auth.resetAuthorizations
+ * Delete all messages of a user in a channel/supergroup: channels.deleteUserHistory
+ * Delete all temporary authorization keys except the ones provided: auth.dropTempAuthKeys
+ * Delete channel/supergroup messages: channels.deleteMessages
+ * Delete chat history: messages.deleteHistory
+ * Delete contacts by phones: contacts.deleteByPhones
+ * Delete folder: folders.deleteFolder
+ * Delete messages: messages.deleteMessages
+ * Delete multiple contacts: contacts.deleteContacts
+ * Delete profile photos: photos.deletePhotos
+ * Delete scheduled messages: messages.deleteScheduledMessages
+ * Delete secure telegram passport value: account.deleteSecureValue
+ * Delete the history of a supergroup/channel: channels.deleteHistory
+ * Delete this account: account.deleteAccount
+ * Disable all notifications for a certain period: account.updateDeviceLocked
+ * Download a file through telegram: upload.getWebFile
+ * Edit a message: messages.editMessage
+ * Edit a sent inline message: messages.editInlineBotMessage
+ * Edit admin permissions of a user in a channel/supergroup: channels.editAdmin
+ * Edit admin permissions: messages.editChatAdmin
+ * Edit chat info: messages.editChatAbout
+ * Edit creator of channel: channels.editCreator
+ * Edit default rights of chat: messages.editChatDefaultBannedRights
+ * Edit folder: folders.editPeerFolders
+ * Edit location (geochats): channels.editLocation
+ * Edit the photo of a normal chat (not supergroup): messages.editChatPhoto
+ * Edit the photo of a supergroup/channel: channels.editPhoto
+ * Edit the title of a normal chat (not supergroup): messages.editChatTitle
+ * Edit the title of a supergroup/channel: channels.editTitle
+ * Edit user info: help.editUserInfo
+ * Enable or disable hidden history for new channel/supergroup users: channels.togglePreHistoryHidden
+ * Export chat invite : messages.exportChatInvite
+ * Find a sticker set: messages.searchStickerSets
+ * Finish account exporting session: account.finishTakeoutSession
+ * Forward messages: messages.forwardMessages
+ * Get CDN configuration: help.getCdnConfig
+ * Get a stickerset: messages.getStickerSet
+ * Get account TTL: account.getAccountTTL
+ * Get admin log of a channel/supergroup: channels.getAdminLog
+ * Get all archived stickers: messages.getArchivedStickers
+ * Get all channels you left: channels.getLeftChannels
+ * Get all chats (not supergroups or channels): messages.getAllChats
+ * Get all contacts: contacts.getContacts
+ * Get all logged-in authorizations: account.getAuthorizations
+ * Get all message drafts: messages.getAllDrafts
+ * Get all secure telegram passport values: account.getAllSecureValues
+ * Get all stickerpacks: messages.getAllStickers
+ * Get all supergroups/channels where you're admin: channels.getAdminedPublicChannels
+ * Get and increase message views: messages.getMessagesViews
+ * Get app config: help.getAppConfig
+ * Get autodownload settings: account.getAutoDownloadSettings
+ * Get available languages: langpack.getLanguages
+ * Get blocked users: contacts.getBlocked
+ * Get call configuration: phone.getCallConfig
+ * Get channel/supergroup messages: channels.getMessages
+ * Get channel/supergroup participants (you should use `$MadelineProto->getPwrChat($id)` instead): channels.getParticipants
+ * Get chats in common with a user: messages.getCommonChats
+ * Get contacts by IDs: contacts.getContactIDs
+ * Get deep link info: help.getDeepLinkInfo
+ * Get dialog info of peers: messages.getPeerDialogs
+ * Get dialogs marked as unread manually: messages.getDialogUnreadMarks
+ * Get document by SHA256 hash: messages.getDocumentByHash
+ * Get emoji URL: messages.getEmojiURL
+ * Get emoji keyword difference: messages.getEmojiKeywordsDifference
+ * Get emoji keyword languages: messages.getEmojiKeywordsLanguages
+ * Get emoji keywords: messages.getEmojiKeywords
+ * Get favorite stickers: messages.getFavedStickers
+ * Get featured stickers: messages.getFeaturedStickers
+ * Get file hashes: upload.getFileHashes
+ * Get groups for discussion: channels.getGroupsForDiscussion
+ * Get high scores of a game sent in an inline message: messages.getInlineGameHighScores
+ * Get high scores of a game: messages.getGameHighScores
+ * Get info about a certain channel/supergroup participant: channels.getParticipant
+ * Get info about app updates: help.getAppUpdate
+ * Get info about chats: messages.getChats
+ * Get info about multiple channels/supergroups: channels.getChannels
+ * Get info about users: users.getUsers
+ * Get info of support user: help.getSupport
+ * Get information about the current proxy: help.getProxyData
+ * Get installed themes: account.getThemes
+ * Get invitation text: help.getInviteText
+ * Get language pack strings: langpack.getStrings
+ * Get language pack updates: langpack.getDifference
+ * Get language pack: langpack.getLangPack
+ * Get language: langpack.getLanguage
+ * Get masks: messages.getMaskStickers
+ * Get message ranges to fetch: messages.getSplitRanges
+ * Get messages: messages.getMessages
+ * Get most used chats: contacts.getTopPeers
+ * Get nearest datacenter: help.getNearestDc
+ * Get notification exceptions: account.getNotifyExceptions
+ * Get notification settings: account.getNotifySettings
+ * Get online status of all users: contacts.getStatuses
+ * Get online users: messages.getOnlines
+ * Get passport config: help.getPassportConfig
+ * Get payment form: payments.getPaymentForm
+ * Get payment receipt: payments.getPaymentReceipt
+ * Get people nearby (geochats): contacts.getLocated
+ * Get pinned dialogs: messages.getPinnedDialogs
+ * Get poll results: messages.getPollResults
+ * Get previous messages of a group: messages.getHistory
+ * Get privacy settings: account.getPrivacy
+ * Get recent locations: messages.getRecentLocations
+ * Get recent stickers: messages.getRecentStickers
+ * Get recent t.me URLs: help.getRecentMeUrls
+ * Get saved contacts: contacts.getSaved
+ * Get saved gifs: messages.getSavedGifs
+ * Get saved payments info: payments.getSavedInfo
+ * Get scheduled history: messages.getScheduledHistory
+ * Get scheduled messages: messages.getScheduledMessages
+ * Get search counter: messages.getSearchCounters
+ * Get secure value for telegram passport: account.getSecureValue
+ * Get server configuration: help.getConfig
+ * Get stats URL: messages.getStatsURL
+ * Get stickers attachable to images: messages.getAttachedStickers
+ * Get stickers: messages.getStickers
+ * Get support name: help.getSupportName
+ * Get telegram web login authorizations: account.getWebAuthorizations
+ * Get temporary password for buying products through bots: account.getTmpPassword
+ * Get the callback answer of a bot (after clicking a button): messages.getBotCallbackAnswer
+ * Get the changelog of this app: help.getAppChangelog
+ * Get the current 2FA settings: account.getPasswordSettings
+ * Get the current password: account.getPassword
+ * Get the link of a message in a channel: channels.exportMessageLink
+ * Get the profile photos of a user: photos.getUserPhotos
+ * Get the settings of apeer: messages.getPeerSettings
+ * Get theme information: account.getTheme
+ * Get unread mentions: messages.getUnreadMentions
+ * Get updated TOS: help.getTermsOfServiceUpdate
+ * Get user info: help.getUserInfo
+ * Get wallpaper info: account.getWallPaper
+ * Get webpage preview: messages.getWebPage
+ * Get webpage preview: messages.getWebPagePreview
+ * Gets list of chats: you should use $MadelineProto->getDialogs() instead: https://docs.madelineproto.xyz/docs/DIALOGS.html: messages.getDialogs
+ * Global message search: messages.searchGlobal
+ * Hide peer settings bar: messages.hidePeerSettingsBar
+ * Import chat invite: messages.importChatInvite
* Initializes connection and save information on the user's device and application.: initConnection
- * Install theme: account.installTheme
- * Install wallpaper: account.installWallPaper
- * Invalidate sent phone code: auth.cancelCode
+ * Install theme: account.installTheme
+ * Install wallpaper: account.installWallPaper
+ * Invalidate sent phone code: auth.cancelCode
* Invoke method from takeout session: invokeWithTakeout
* Invoke this method with layer X: invokeWithLayer
* Invoke with messages range: invokeWithMessagesRange
* Invoke with method without returning updates in the socket: invokeWithoutUpdates
* Invokes a query after successfull completion of one of the previous queries.: invokeAfterMsg
- * Join a channel/supergroup: channels.joinChannel
- * Kick or ban a user from a channel/supergroup: channels.editBanned
- * Leave a channel/supergroup: channels.leaveChannel
- * Log data for developer of this app: help.saveAppLog
- * Mark channel/supergroup history as read: channels.readHistory
- * Mark channel/supergroup messages as read: channels.readMessageContents
- * Mark dialog as unread : messages.markDialogUnread
- * Mark mentions as read: messages.readMentions
- * Mark message as read: messages.readMessageContents
- * Mark messages as read in secret chats: messages.readEncryptedHistory
- * Mark messages as read: messages.readHistory
- * Mark messages as read: messages.receivedMessages
- * Mark new featured stickers as read: messages.readFeaturedStickers
- * Notify server that you received a call (server will refuse all incoming calls until the current call is over): phone.receivedCall
- * Pin or unpin dialog: messages.toggleDialogPin
- * Register device for push notifications: account.registerDevice
- * Remove a sticker set: messages.uninstallStickerSet
- * Remove sticker from stickerset: stickers.removeStickerFromSet
- * Reorder pinned dialogs: messages.reorderPinnedDialogs
- * Reorder sticker sets: messages.reorderStickerSets
- * Report a message in a supergroup/channel for spam: channels.reportSpam
- * Report a message: messages.report
- * Report a peer for spam: messages.reportSpam
- * Report for spam a secret chat: messages.reportEncryptedSpam
- * Report for spam: account.reportPeer
- * Request URL authorization: messages.requestUrlAuth
- * Resend password recovery email: account.resendPasswordEmail
- * Resend the SMS verification code: auth.resendCode
- * Reset all notification settings: account.resetNotifySettings
- * Reset all telegram web login authorizations: account.resetWebAuthorizations
- * Reset saved contacts: contacts.resetSaved
- * Reset top peer rating for a certain category/peer: contacts.resetTopPeerRating
- * Reset wallpapers: account.resetWallPapers
+ * Join a channel/supergroup: channels.joinChannel
+ * Kick or ban a user from a channel/supergroup: channels.editBanned
+ * Leave a channel/supergroup: channels.leaveChannel
+ * Log data for developer of this app: help.saveAppLog
+ * Mark channel/supergroup history as read: channels.readHistory
+ * Mark channel/supergroup messages as read: channels.readMessageContents
+ * Mark dialog as unread : messages.markDialogUnread
+ * Mark mentions as read: messages.readMentions
+ * Mark message as read: messages.readMessageContents
+ * Mark messages as read in secret chats: messages.readEncryptedHistory
+ * Mark messages as read: messages.readHistory
+ * Mark messages as read: messages.receivedMessages
+ * Mark new featured stickers as read: messages.readFeaturedStickers
+ * Notify server that you received a call (server will refuse all incoming calls until the current call is over): phone.receivedCall
+ * Pin or unpin dialog: messages.toggleDialogPin
+ * Register device for push notifications: account.registerDevice
+ * Remove a sticker set: messages.uninstallStickerSet
+ * Remove sticker from stickerset: stickers.removeStickerFromSet
+ * Reorder pinned dialogs: messages.reorderPinnedDialogs
+ * Reorder sticker sets: messages.reorderStickerSets
+ * Report a message in a supergroup/channel for spam: channels.reportSpam
+ * Report a message: messages.report
+ * Report a peer for spam: messages.reportSpam
+ * Report for spam a secret chat: messages.reportEncryptedSpam
+ * Report for spam: account.reportPeer
+ * Request URL authorization: messages.requestUrlAuth
+ * Resend password recovery email: account.resendPasswordEmail
+ * Resend the SMS verification code: auth.resendCode
+ * Reset all notification settings: account.resetNotifySettings
+ * Reset all telegram web login authorizations: account.resetWebAuthorizations
+ * Reset saved contacts: contacts.resetSaved
+ * Reset top peer rating for a certain category/peer: contacts.resetTopPeerRating
+ * Reset wallpapers: account.resetWallPapers
* Result type returned by a current query.: invokeAfterMsgs
- * Returns a list of available wallpapers.: account.getWallPapers
- * Save a GIF: messages.saveGif
- * Save a message draft: messages.saveDraft
- * Save autodownload settings: account.saveAutoDownloadSettings
- * Save call debugging info: phone.saveCallDebug
- * Save telegram passport secure value: account.saveSecureValue
- * Save theme: account.saveTheme
- * Save wallpaper: account.saveWallPaper
- * Search contacts: contacts.search
- * Search gifs: messages.searchGifs
- * Search peers or messages: messages.search
- * Send a custom request to the bot API: bots.sendCustomRequest
- * Send a file to a secret chat: messages.sendEncryptedFile
- * Send a media: messages.sendMedia
- * Send a message: messages.sendMessage
- * Send a service message to a secret chat: messages.sendEncryptedService
- * Send an album: messages.sendMultiMedia
- * Send an email to recover the 2FA password: auth.requestPasswordRecovery
- * Send confirmation phone code: account.sendConfirmPhoneCode
- * Send email verification code: account.sendVerifyEmailCode
- * Send inline bot result obtained with messages.getInlineBotResults to the chat: messages.sendInlineBotResult
- * Send message to secret chat: messages.sendEncrypted
- * Send phone verification code: account.sendVerifyPhoneCode
- * Send scheduled messages: messages.sendScheduledMessages
- * Send screenshot notification: messages.sendScreenshotNotification
- * Send typing notification to secret chat: messages.setEncryptedTyping
- * Send vote: messages.sendVote
- * Send webhook request via bot API: bots.answerWebhookJSONQuery
- * Set account TTL: account.setAccountTTL
- * Set contact sign up notification: account.setContactSignUpNotification
- * Set discussion group of channel: channels.setDiscussionGroup
- * Set phone call rating: phone.setCallRating
- * Set privacy settings: account.setPrivacy
- * Set secure value error for telegram passport: users.setSecureValueErrors
- * Set the game score of an inline message: messages.setInlineGameScore
- * Set the game score: messages.setGameScore
- * Set the supergroup/channel stickerpack: channels.setStickers
- * Set the update status of webhook: help.setBotUpdatesStatus
- * Start a bot: messages.startBot
- * Start account exporting session: account.initTakeoutSession
- * Stop sending PUSH notifications to app: account.unregisterDevice
- * Toggle channel signatures: channels.toggleSignatures
- * Toggle slow mode: channels.toggleSlowMode
- * Toggle top peers: contacts.toggleTopPeers
- * Unblock a user: contacts.unblock
- * Update online status: account.updateStatus
- * Update pinned message: messages.updatePinnedMessage
- * Update profile info: account.updateProfile
- * Update the username of a supergroup/channel: channels.updateUsername
- * Update theme: account.updateTheme
- * Update this user's username: account.updateUsername
- * Upload a file without sending it to anyone: messages.uploadMedia
- * Upload a secret chat file without sending it to anyone: messages.uploadEncryptedFile
- * Upload profile photo: photos.uploadProfilePhoto
- * Upload theme: account.uploadTheme
- * Upload wallpaper: account.uploadWallPaper
- * Use phone_login instead: auth.sendCode
- * Use the code that was emailed to you after running $MadelineProto->auth->requestPasswordRecovery to login to your account: auth.recoverPassword
- * Validate requested payment info: payments.validateRequestedInfo
- * Verify email address: account.verifyEmail
- * Verify phone number: account.verifyPhone
- * You cannot use this method directly, instead modify the PFS and default_temp_auth_key_expires_in settings, see https://docs.madelineproto.xyz/docs/SETTINGS.html for more info: auth.bindTempAuthKey
- * You cannot use this method directly, instead use $MadelineProto->getDhConfig();: messages.getDhConfig
- * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling secret chats: messages.acceptEncryption
- * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling secret chats: messages.discardEncryption
- * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling secret chats: messages.requestEncryption
- * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling updates: updates.getChannelDifference
- * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling updates: updates.getDifference
- * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling updates: updates.getState
- * You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.acceptCall
- * You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.confirmCall
- * You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.discardCall
- * You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.requestCall
- * You cannot use this method directly, use $MadelineProto->exportAuthorization() instead, see https://docs.madelineproto.xyz/docs/LOGIN.html: auth.exportAuthorization
- * You cannot use this method directly, use $MadelineProto->importAuthorization($authorization) instead, see https://docs.madelineproto.xyz/docs/LOGIN.html: auth.importAuthorization
- * You cannot use this method directly, use the bot_login method instead (see https://docs.madelineproto.xyz for more info): auth.importBotAuthorization
- * You cannot use this method directly, use the complete_2fa_login method instead (see https://docs.madelineproto.xyz for more info): auth.checkPassword
- * You cannot use this method directly, use the complete_phone_login method instead (see https://docs.madelineproto.xyz for more info): auth.signIn
- * You cannot use this method directly, use the complete_signup method instead (see https://docs.madelineproto.xyz for more info): auth.signUp
- * You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://docs.madelineproto.xyz for more info): channels.getFullChannel
- * You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://docs.madelineproto.xyz for more info): messages.getFullChat
- * You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://docs.madelineproto.xyz for more info): users.getFullUser
- * You cannot use this method directly, use the logout method instead (see https://docs.madelineproto.xyz for more info): auth.logOut
- * You cannot use this method directly, use the resolve_username, get_pwr_chat, get_info, get_full_info methods instead (see https://docs.madelineproto.xyz for more info): contacts.resolveUsername
- * You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://docs.madelineproto.xyz for more info: upload.getCdnFile
- * You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://docs.madelineproto.xyz for more info: upload.getCdnFileHashes
- * You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://docs.madelineproto.xyz for more info: upload.getFile
- * You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://docs.madelineproto.xyz for more info: upload.reuploadCdnFile
- * You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://docs.madelineproto.xyz for more info: upload.saveBigFilePart
- * You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://docs.madelineproto.xyz for more info: upload.saveFilePart
- * You cannot use this method directly: messages.receivedQueue
- * You cannot use this method directly; use $MadelineProto->update_2fa($params), instead (see https://docs.madelineproto.xyz for more info): account.updatePasswordSettings
+ * Returns a list of available wallpapers.: account.getWallPapers
+ * Save a GIF: messages.saveGif
+ * Save a message draft: messages.saveDraft
+ * Save autodownload settings: account.saveAutoDownloadSettings
+ * Save call debugging info: phone.saveCallDebug
+ * Save telegram passport secure value: account.saveSecureValue
+ * Save theme: account.saveTheme
+ * Save wallpaper: account.saveWallPaper
+ * Search contacts: contacts.search
+ * Search gifs: messages.searchGifs
+ * Search peers or messages: messages.search
+ * Send a custom request to the bot API: bots.sendCustomRequest
+ * Send a file to a secret chat: messages.sendEncryptedFile
+ * Send a media: messages.sendMedia
+ * Send a message: messages.sendMessage
+ * Send a service message to a secret chat: messages.sendEncryptedService
+ * Send an album: messages.sendMultiMedia
+ * Send an email to recover the 2FA password: auth.requestPasswordRecovery
+ * Send confirmation phone code: account.sendConfirmPhoneCode
+ * Send email verification code: account.sendVerifyEmailCode
+ * Send inline bot result obtained with messages.getInlineBotResults to the chat: messages.sendInlineBotResult
+ * Send message to secret chat: messages.sendEncrypted
+ * Send phone verification code: account.sendVerifyPhoneCode
+ * Send scheduled messages: messages.sendScheduledMessages
+ * Send screenshot notification: messages.sendScreenshotNotification
+ * Send typing notification to secret chat: messages.setEncryptedTyping
+ * Send vote: messages.sendVote
+ * Send webhook request via bot API: bots.answerWebhookJSONQuery
+ * Set account TTL: account.setAccountTTL
+ * Set contact sign up notification: account.setContactSignUpNotification
+ * Set discussion group of channel: channels.setDiscussionGroup
+ * Set phone call rating: phone.setCallRating
+ * Set privacy settings: account.setPrivacy
+ * Set secure value error for telegram passport: users.setSecureValueErrors
+ * Set the game score of an inline message: messages.setInlineGameScore
+ * Set the game score: messages.setGameScore
+ * Set the supergroup/channel stickerpack: channels.setStickers
+ * Set the update status of webhook: help.setBotUpdatesStatus
+ * Start a bot: messages.startBot
+ * Start account exporting session: account.initTakeoutSession
+ * Stop sending PUSH notifications to app: account.unregisterDevice
+ * Toggle channel signatures: channels.toggleSignatures
+ * Toggle slow mode: channels.toggleSlowMode
+ * Toggle top peers: contacts.toggleTopPeers
+ * Unblock a user: contacts.unblock
+ * Update online status: account.updateStatus
+ * Update pinned message: messages.updatePinnedMessage
+ * Update profile info: account.updateProfile
+ * Update the username of a supergroup/channel: channels.updateUsername
+ * Update theme: account.updateTheme
+ * Update this user's username: account.updateUsername
+ * Upload a file without sending it to anyone: messages.uploadMedia
+ * Upload a secret chat file without sending it to anyone: messages.uploadEncryptedFile
+ * Upload profile photo: photos.uploadProfilePhoto
+ * Upload theme: account.uploadTheme
+ * Upload wallpaper: account.uploadWallPaper
+ * Use phoneLogin instead: auth.sendCode
+ * Use the code that was emailed to you after running $MadelineProto->auth->requestPasswordRecovery to login to your account: auth.recoverPassword
+ * Validate requested payment info: payments.validateRequestedInfo
+ * Verify email address: account.verifyEmail
+ * Verify phone number: account.verifyPhone
+ * You cannot use this method directly, instead modify the PFS and default_temp_auth_key_expires_in settings, see https://docs.madelineproto.xyz/docs/SETTINGS.html for more info: auth.bindTempAuthKey
+ * You cannot use this method directly, instead use $MadelineProto->getDhConfig();: messages.getDhConfig
+ * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling secret chats: messages.acceptEncryption
+ * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling secret chats: messages.discardEncryption
+ * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling secret chats: messages.requestEncryption
+ * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling updates: updates.getChannelDifference
+ * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling updates: updates.getDifference
+ * You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling updates: updates.getState
+ * You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.acceptCall
+ * You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.confirmCall
+ * You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.discardCall
+ * You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.requestCall
+ * You cannot use this method directly, use $MadelineProto->exportAuthorization() instead, see https://docs.madelineproto.xyz/docs/LOGIN.html: auth.exportAuthorization
+ * You cannot use this method directly, use $MadelineProto->importAuthorization($authorization) instead, see https://docs.madelineproto.xyz/docs/LOGIN.html: auth.importAuthorization
+ * You cannot use this method directly, use the botLogin method instead (see https://docs.madelineproto.xyz for more info): auth.importBotAuthorization
+ * You cannot use this method directly, use the completePhoneLogin method instead (see https://docs.madelineproto.xyz for more info): auth.signIn
+ * You cannot use this method directly, use the completeSignup method instead (see https://docs.madelineproto.xyz for more info): auth.signUp
+ * You cannot use this method directly, use the complete_2fa_login method instead (see https://docs.madelineproto.xyz for more info): auth.checkPassword
+ * You cannot use this method directly, use the getPwrChat, getInfo, getFullInfo methods instead (see https://docs.madelineproto.xyz for more info): channels.getFullChannel
+ * You cannot use this method directly, use the getPwrChat, getInfo, getFullInfo methods instead (see https://docs.madelineproto.xyz for more info): messages.getFullChat
+ * You cannot use this method directly, use the getPwrChat, getInfo, getFullInfo methods instead (see https://docs.madelineproto.xyz for more info): users.getFullUser
+ * You cannot use this method directly, use the logout method instead (see https://docs.madelineproto.xyz for more info): auth.logOut
+ * You cannot use this method directly, use the resolveUsername, getPwrChat, getInfo, getFullInfo methods instead (see https://docs.madelineproto.xyz for more info): contacts.resolveUsername
+ * You cannot use this method directly, use the upload, downloadToStream, downloadToFile, downloadToDir methods instead; see https://docs.madelineproto.xyz for more info: upload.getCdnFile
+ * You cannot use this method directly, use the upload, downloadToStream, downloadToFile, downloadToDir methods instead; see https://docs.madelineproto.xyz for more info: upload.getCdnFileHashes
+ * You cannot use this method directly, use the upload, downloadToStream, downloadToFile, downloadToDir methods instead; see https://docs.madelineproto.xyz for more info: upload.getFile
+ * You cannot use this method directly, use the upload, downloadToStream, downloadToFile, downloadToDir methods instead; see https://docs.madelineproto.xyz for more info: upload.reuploadCdnFile
+ * You cannot use this method directly, use the upload, downloadToStream, downloadToFile, downloadToDir methods instead; see https://docs.madelineproto.xyz for more info: upload.saveBigFilePart
+ * You cannot use this method directly, use the upload, downloadToStream, downloadToFile, downloadToDir methods instead; see https://docs.madelineproto.xyz for more info: upload.saveFilePart
+ * You cannot use this method directly: messages.receivedQueue
+ * You cannot use this method directly; use $MadelineProto->update_2fa($params), instead (see https://docs.madelineproto.xyz for more info): account.updatePasswordSettings
* [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/docs b/docs
index 9f21080a..336c4d4a 160000
--- a/docs
+++ b/docs
@@ -1 +1 @@
-Subproject commit 9f21080a2952ff2d62af31aebbebae8743653aa9
+Subproject commit 336c4d4aa0086a548029a974a8b830fa3974b3db
diff --git a/src/danog/MadelineProto/DocsBuilder.php b/src/danog/MadelineProto/DocsBuilder.php
index 836aa3ed..06d31d1a 100644
--- a/src/danog/MadelineProto/DocsBuilder.php
+++ b/src/danog/MadelineProto/DocsBuilder.php
@@ -49,16 +49,6 @@ class DocsBuilder
public $types = [];
public $any = '*';
- public function end($what)
- {
- return \end($what);
- }
-
- public function escape($hwat)
- {
- return \str_replace('_', '\\_', $hwat);
- }
-
public function mkDocs()
{
\danog\MadelineProto\Logger::log('Generating documentation index...', \danog\MadelineProto\Logger::NOTICE);
diff --git a/src/danog/MadelineProto/InternalDoc.php b/src/danog/MadelineProto/InternalDoc.php
index ee65fc74..7375addf 100644
--- a/src/danog/MadelineProto/InternalDoc.php
+++ b/src/danog/MadelineProto/InternalDoc.php
@@ -4302,22 +4302,6 @@ class InternalDoc extends APIFactory
{
return $this->__call(__FUNCTION__, [$id, $extra]);
}
- /**
- * Synchronous wrapper for methodCall.
- *
- * @param string $method Method name
- * @param array $args Arguments
- * @param array $aargs Additional arguments
- *
- * @return array
- */
- public function methodCall(string $method, $args = [
- ], array $aargs = [
- 'msg_id' => null,
- ], array $extra = [])
- {
- return $this->__call(__FUNCTION__, [$method, $args, $aargs, $extra]);
- }
/**
* Call method and wait asynchronously for response.
*
@@ -4329,7 +4313,7 @@ class InternalDoc extends APIFactory
*
* @return Promise
*/
- public function methodCallRead(string $method, $args = [
+ public function methodCall(string $method, $args = [
], array $aargs = [
'msg_id' => null,
], array $extra = [])
@@ -4868,26 +4852,6 @@ class InternalDoc extends APIFactory
return $this->__call(__FUNCTION__, [$button_list, $extra]);
}
- public function base64urlDecode($data, array $extra = [])
- {
- return $this->__call(__FUNCTION__, [$data, $extra]);
- }
-
- public function base64urlEncode($data, array $extra = [])
- {
- return $this->__call(__FUNCTION__, [$data, $extra]);
- }
-
- public function rleDecode($string, array $extra = [])
- {
- return $this->__call(__FUNCTION__, [$string, $extra]);
- }
-
- public function rleEncode($string, array $extra = [])
- {
- return $this->__call(__FUNCTION__, [$string, $extra]);
- }
-
public function photosizeToBotAPI($photoSize, $photo, $thumbnail = false, array $extra = [])
{
return $this->__call(__FUNCTION__, [$photoSize, $photo, $thumbnail, $extra]);
@@ -4947,41 +4911,82 @@ class InternalDoc extends APIFactory
{
return $this->__call(__FUNCTION__, [$params, $extra]);
}
-
- public function genVectorHash($ints, array $extra = [])
+ /**
+ * Generate MTProto vector hash.
+ *
+ * @param array $ints IDs
+ *
+ * @return int Vector hash
+ */
+ public function genVectorHash(array $ints, array $extra = []): int
{
return $this->__call(__FUNCTION__, [$ints, $extra]);
}
-
- public function randomInt($modulus = false, array $extra = [])
+ /**
+ * Get random integer.
+ *
+ * @param integer $modulus Modulus
+ *
+ * @return int
+ */
+ public function randomInt($modulus = false, array $extra = []): int
{
return $this->__call(__FUNCTION__, [$modulus, $extra]);
}
-
- public function random($length, array $extra = [])
+ /**
+ * Get random string of specified length.
+ *
+ * @param integer $length Length
+ *
+ * @return string Random string
+ */
+ public function random(int $length, array $extra = []): string
{
return $this->__call(__FUNCTION__, [$length, $extra]);
}
/**
- * posmod(numeric,numeric) : numeric
+ * Positive modulo
* Works just like the % (modulus) operator, only returns always a postive number.
+ *
+ * @param int $a A
+ * @param int $b B
+ *
+ * @return int Modulo
*/
- public function posmod($a, $b, array $extra = [])
+ public function posmod(int $a, int $b, array $extra = []): int
{
return $this->__call(__FUNCTION__, [$a, $b, $extra]);
}
-
- public function unpackSignedInt($value, array $extra = [])
+ /**
+ * Unpack base256 signed int.
+ *
+ * @param string $value base256 int
+ *
+ * @return integer
+ */
+ public function unpackSignedInt($value, array $extra = []): int
{
return $this->__call(__FUNCTION__, [$value, $extra]);
}
-
- public function unpackSignedLong($value, array $extra = [])
+ /**
+ * Unpack base256 signed long.
+ *
+ * @param string $value base256 long
+ *
+ * @return integer
+ */
+ public function unpackSignedLong($value, array $extra = []): int
{
return $this->__call(__FUNCTION__, [$value, $extra]);
}
-
- public function unpackSignedLongString($value, array $extra = [])
+ /**
+ * Unpack base256 signed long to string.
+ *
+ * @param string $value base256 long
+ *
+ * @return string
+ */
+ public function unpackSignedLongString($value, array $extra = []): string
{
return $this->__call(__FUNCTION__, [$value, $extra]);
}
@@ -5065,50 +5070,96 @@ class InternalDoc extends APIFactory
{
return $this->__call(__FUNCTION__, [$a, $b, $extra]);
}
+ /**
+ * Asynchronously send noCache headers.
+ *
+ * @param integer $status HTTP status code to send
+ * @param string $message Message to print
+ *
+ * @return Promise
+ */
+ public function noCache(int $status, string $message, array $extra = [])
+ {
+ return $this->__call(__FUNCTION__, [$status, $message, $extra]);
+ }
/**
* Asynchronously lock a file
* Resolves with a callbable that MUST eventually be called in order to release the lock.
*
- * @param string $file File to lock
- * @param integer $operation Locking mode (see flock)
- * @param numeric $polling Polling interval for lock
+ * @param string $file File to lock
+ * @param integer $operation Locking mode
+ * @param integer $polling Polling interval
+ *
* @return Promise
*/
public function flock(string $file, int $operation, $polling = 0.1, array $extra = [])
{
return $this->__call(__FUNCTION__, [$file, $operation, $polling, $extra]);
}
-
- public function noCache(int $status, string $message, array $extra = [])
- {
- return $this->__call(__FUNCTION__, [$status, $message, $extra]);
- }
-
+ /**
+ * Asynchronously lock a file (internal generator function).
+ *
+ * @param string $file File to lock
+ * @param integer $operation Locking mode
+ * @param integer $polling Polling interval
+ *
+ * @return void
+ */
public function flockGenerator(string $file, int $operation, $polling, array $extra = [])
{
return $this->__call(__FUNCTION__, [$file, $operation, $polling, $extra]);
}
-
- public function sleep($time, array $extra = [])
+ /**
+ * Asynchronously sleep.
+ *
+ * @param int $time Number of seconds to sleep for
+ *
+ * @return Promise
+ */
+ public function sleep(int $time, array $extra = [])
{
return $this->__call(__FUNCTION__, [$time, $extra]);
}
-
- public function readLine($prompt = '', array $extra = [])
+ /**
+ * Asynchronously read line.
+ *
+ * @param string $prompt Prompt
+ *
+ * @return Promise
+ */
+ public function readLine(string $prompt = '', array $extra = [])
{
return $this->__call(__FUNCTION__, [$prompt, $extra]);
}
-
- public function readLineGenerator($prompt = '', array $extra = [])
+ /**
+ * Asynchronously read line (generator function).
+ *
+ * @param string $prompt Prompt
+ *
+ * @return void
+ */
+ public function readLineGenerator(string $prompt = '', array $extra = [])
{
return $this->__call(__FUNCTION__, [$prompt, $extra]);
}
-
- public function echo($string, array $extra = [])
+ /**
+ * Asynchronously write to stdout/browser.
+ *
+ * @param string $string Message to echo
+ *
+ * @return Promise
+ */
+ public function echo(string $string, array $extra = [])
{
return $this->__call(__FUNCTION__, [$string, $extra]);
}
-
+ /**
+ * Check if is array or similar (traversable && countable && arrayAccess).
+ *
+ * @param arraylike $var Value to check
+ *
+ * @return boolean
+ */
public function isArrayOrAlike($var, array $extra = [])
{
return $this->__call(__FUNCTION__, [$var, $extra]);
@@ -5146,6 +5197,50 @@ class InternalDoc extends APIFactory
{
return $this->__call(__FUNCTION__, Tools::arr(...$params));
}
+ /**
+ * base64URL decode.
+ *
+ * @param string $data Data to decode
+ *
+ * @return string
+ */
+ public function base64urlDecode(string $data, array $extra = []): string
+ {
+ return $this->__call(__FUNCTION__, [$data, $extra]);
+ }
+ /**
+ * Base64URL encode.
+ *
+ * @param string $data Data to encode
+ *
+ * @return string
+ */
+ public function base64urlEncode(string $data, array $extra = []): string
+ {
+ return $this->__call(__FUNCTION__, [$data, $extra]);
+ }
+ /**
+ * null-byte RLE decode.
+ *
+ * @param string $string Data to decode
+ *
+ * @return string
+ */
+ public function rleDecode(string $string, array $extra = []): string
+ {
+ return $this->__call(__FUNCTION__, [$string, $extra]);
+ }
+ /**
+ * null-byte RLE encode.
+ *
+ * @param string $string Data to encode
+ *
+ * @return string
+ */
+ public function rleEncode(string $string, array $extra = []): string
+ {
+ return $this->__call(__FUNCTION__, [$string, $extra]);
+ }
public function requestCall($user, array $extra = [])
{
diff --git a/src/danog/MadelineProto/Lang.php b/src/danog/MadelineProto/Lang.php
index 098605cc..c617101d 100644
--- a/src/danog/MadelineProto/Lang.php
+++ b/src/danog/MadelineProto/Lang.php
@@ -3514,8 +3514,6 @@ class Lang
'object_decryptedMessageMediaPhoto_param_w_type_int' => 'Width',
'object_decryptedMessageMediaPhoto_param_h_type_int' => 'Height',
'object_decryptedMessageMediaPhoto_param_size_type_int' => 'Size',
- 'object_decryptedMessageMediaPhoto_param_key_type_bytes' => 'Key',
- 'object_decryptedMessageMediaPhoto_param_iv_type_bytes' => 'Iv',
'object_decryptedMessageMediaVideo' => 'Decrypted message media video',
'object_decryptedMessageMediaVideo_param_thumb_type_bytes' => 'Thumbnail',
'object_decryptedMessageMediaVideo_param_thumb_w_type_int' => 'Thumbnail width',
@@ -3524,8 +3522,6 @@ class Lang
'object_decryptedMessageMediaVideo_param_w_type_int' => 'Width',
'object_decryptedMessageMediaVideo_param_h_type_int' => 'Height',
'object_decryptedMessageMediaVideo_param_size_type_int' => 'Size',
- 'object_decryptedMessageMediaVideo_param_key_type_bytes' => 'Key',
- 'object_decryptedMessageMediaVideo_param_iv_type_bytes' => 'Iv',
'object_decryptedMessageMediaGeoPoint' => 'Decrypted message media geo point',
'object_decryptedMessageMediaGeoPoint_param_lat_type_double' => 'Lat',
'object_decryptedMessageMediaGeoPoint_param_long_type_double' => 'Long',
@@ -3543,13 +3539,9 @@ class Lang
'object_decryptedMessageMediaDocument_param_file_name_type_string' => 'File name',
'object_decryptedMessageMediaDocument_param_mime_type_type_string' => 'Mime type',
'object_decryptedMessageMediaDocument_param_size_type_int' => 'Size',
- 'object_decryptedMessageMediaDocument_param_key_type_bytes' => 'Key',
- 'object_decryptedMessageMediaDocument_param_iv_type_bytes' => 'Iv',
'object_decryptedMessageMediaAudio' => 'Decrypted message media audio',
'object_decryptedMessageMediaAudio_param_duration_type_int' => 'Duration',
'object_decryptedMessageMediaAudio_param_size_type_int' => 'Size',
- 'object_decryptedMessageMediaAudio_param_key_type_bytes' => 'Key',
- 'object_decryptedMessageMediaAudio_param_iv_type_bytes' => 'Iv',
'object_decryptedMessageActionReadMessages' => 'Decrypted message action read messages',
'object_decryptedMessageActionReadMessages_param_random_ids_type_Vector t' => 'Random IDs',
'object_decryptedMessageActionDeleteMessages' => 'Decrypted message action delete messages',
@@ -5244,6 +5236,16 @@ class Lang
'method_account.installTheme_param_dark_type_true' => 'Whether to install the dark version',
'method_account.getThemes' => 'Get installed themes',
'method_account.saveTheme' => 'Save theme',
+ 'object_inputBotInlineResult_param_send_message_type_InputBotInlineMessage' => '',
+ 'object_inputBotInlineResultPhoto_param_send_message_type_InputBotInlineMessage' => '',
+ 'object_inputBotInlineResultDocument_param_send_message_type_InputBotInlineMessage' => '',
+ 'object_inputBotInlineResultGame_param_send_message_type_InputBotInlineMessage' => '',
+ 'object_botInlineResult_param_send_message_type_BotInlineMessage' => '',
+ 'object_botInlineMediaResult_param_send_message_type_BotInlineMessage' => '',
+ 'object_chatBannedRights_param_send_messages_type_true' => '',
+ 'object_botInlineMediaResultDocument_param_send_message_type_BotInlineMessage' => '',
+ 'object_botInlineMediaResultPhoto_param_send_message_type_BotInlineMessage' => '',
+ 'object_channelBannedRights_param_send_messages_type_true' => '',
],
];
@@ -8599,8 +8601,6 @@ class Lang
'object_decryptedMessageMediaPhoto_param_w_type_int' => 'Width',
'object_decryptedMessageMediaPhoto_param_h_type_int' => 'Height',
'object_decryptedMessageMediaPhoto_param_size_type_int' => 'Size',
- 'object_decryptedMessageMediaPhoto_param_key_type_bytes' => 'Key',
- 'object_decryptedMessageMediaPhoto_param_iv_type_bytes' => 'Iv',
'object_decryptedMessageMediaVideo' => 'Decrypted message media video',
'object_decryptedMessageMediaVideo_param_thumb_type_bytes' => 'Thumbnail',
'object_decryptedMessageMediaVideo_param_thumb_w_type_int' => 'Thumbnail width',
@@ -8609,8 +8609,6 @@ class Lang
'object_decryptedMessageMediaVideo_param_w_type_int' => 'Width',
'object_decryptedMessageMediaVideo_param_h_type_int' => 'Height',
'object_decryptedMessageMediaVideo_param_size_type_int' => 'Size',
- 'object_decryptedMessageMediaVideo_param_key_type_bytes' => 'Key',
- 'object_decryptedMessageMediaVideo_param_iv_type_bytes' => 'Iv',
'object_decryptedMessageMediaGeoPoint' => 'Decrypted message media geo point',
'object_decryptedMessageMediaGeoPoint_param_lat_type_double' => 'Lat',
'object_decryptedMessageMediaGeoPoint_param_long_type_double' => 'Long',
@@ -8628,13 +8626,9 @@ class Lang
'object_decryptedMessageMediaDocument_param_file_name_type_string' => 'File name',
'object_decryptedMessageMediaDocument_param_mime_type_type_string' => 'Mime type',
'object_decryptedMessageMediaDocument_param_size_type_int' => 'Size',
- 'object_decryptedMessageMediaDocument_param_key_type_bytes' => 'Key',
- 'object_decryptedMessageMediaDocument_param_iv_type_bytes' => 'Iv',
'object_decryptedMessageMediaAudio' => 'Decrypted message media audio',
'object_decryptedMessageMediaAudio_param_duration_type_int' => 'Duration',
'object_decryptedMessageMediaAudio_param_size_type_int' => 'Size',
- 'object_decryptedMessageMediaAudio_param_key_type_bytes' => 'Key',
- 'object_decryptedMessageMediaAudio_param_iv_type_bytes' => 'Iv',
'object_decryptedMessageActionReadMessages' => 'Decrypted message action read messages',
'object_decryptedMessageActionReadMessages_param_random_ids_type_Vector t' => 'Random IDs',
'object_decryptedMessageActionDeleteMessages' => 'Decrypted message action delete messages',
@@ -10329,5 +10323,15 @@ class Lang
'method_account.installTheme_param_dark_type_true' => 'Whether to install the dark version',
'method_account.getThemes' => 'Get installed themes',
'method_account.saveTheme' => 'Save theme',
+ 'object_inputBotInlineResult_param_send_message_type_InputBotInlineMessage' => '',
+ 'object_inputBotInlineResultPhoto_param_send_message_type_InputBotInlineMessage' => '',
+ 'object_inputBotInlineResultDocument_param_send_message_type_InputBotInlineMessage' => '',
+ 'object_inputBotInlineResultGame_param_send_message_type_InputBotInlineMessage' => '',
+ 'object_botInlineResult_param_send_message_type_BotInlineMessage' => '',
+ 'object_botInlineMediaResult_param_send_message_type_BotInlineMessage' => '',
+ 'object_chatBannedRights_param_send_messages_type_true' => '',
+ 'object_botInlineMediaResultDocument_param_send_message_type_BotInlineMessage' => '',
+ 'object_botInlineMediaResultPhoto_param_send_message_type_BotInlineMessage' => '',
+ 'object_channelBannedRights_param_send_messages_type_true' => '',
];
}
diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php
index 9214de3c..f61217aa 100644
--- a/src/danog/MadelineProto/MTProto.php
+++ b/src/danog/MadelineProto/MTProto.php
@@ -493,7 +493,12 @@ class MTProto extends AsyncConstruct implements TLCallback
$this->v = self::V;
}
- public function __sleep()
+ /**
+ * Sleep function
+ *
+ * @return array
+ */
+ public function __sleep(): array
{
if ($this->settings['serialization']['cleanup_before_serialization']) {
$this->cleanup();
@@ -526,7 +531,13 @@ class MTProto extends AsyncConstruct implements TLCallback
return isset($this->logger) ? $this->logger->logger($param, $level, $file) : Logger::$default->logger($param, $level, $file);
}
- public function isAltervista()
+
+ /**
+ * Whether this is altervista
+ *
+ * @return boolean
+ */
+ public function isAltervista(): bool
{
return Magic::$altervista;
}
@@ -563,7 +574,7 @@ class MTProto extends AsyncConstruct implements TLCallback
return $this->datacenter->getDataCenterConnections();
}
- public function hasAllAuth()
+ public function hasAllAuth(): bool
{
if ($this->isInitingAuthorization()) {
return false;
@@ -848,7 +859,7 @@ class MTProto extends AsyncConstruct implements TLCallback
$this->logger("Successfully destroyed MadelineProto");
}
- public static function getSettings($settings, $previousSettings = [])
+ public static function getSettings($settings, $previousSettings = []): array
{
Magic::classExists();
if (isset($previousSettings['connection_settings']['default_dc'])) {
@@ -1224,7 +1235,7 @@ class MTProto extends AsyncConstruct implements TLCallback
*
* @return boolean
*/
- public function isHttp(string $datacenter)
+ public function isHttp(string $datacenter): bool
{
return $this->datacenter->isHttp($datacenter);
}
@@ -1454,7 +1465,12 @@ class MTProto extends AsyncConstruct implements TLCallback
$this->datacenter->curdc = $curdc;
}
- public function getSelf()
+ /**
+ * Get info about the logged-in user
+ *
+ * @return \Generator
+ */
+ public function getSelf(): \Generator
{
try {
$this->authorization = ['user' => (yield $this->methodCallAsyncRead('users.getUsers', ['id' => [['_' => 'inputUserSelf']]], ['datacenter' => $this->datacenter->curdc]))[0]];
@@ -1506,7 +1522,12 @@ class MTProto extends AsyncConstruct implements TLCallback
}
- public function __debugInfo()
+ /**
+ * Get debug information for var_dump
+ *
+ * @return array
+ */
+ public function __debugInfo(): array
{
return ['MadelineProto instance '.\spl_object_hash($this)];
}
diff --git a/src/danog/MadelineProto/Magic.php b/src/danog/MadelineProto/Magic.php
index 5e14ade7..48678753 100644
--- a/src/danog/MadelineProto/Magic.php
+++ b/src/danog/MadelineProto/Magic.php
@@ -73,10 +73,15 @@ class Magic
const JSON_EMOJIS = '["\\ud83d\\ude09","\\ud83d\\ude0d","\\ud83d\\ude1b","\\ud83d\\ude2d","\\ud83d\\ude31","\\ud83d\\ude21","\\ud83d\\ude0e","\\ud83d\\ude34","\\ud83d\\ude35","\\ud83d\\ude08","\\ud83d\\ude2c","\\ud83d\\ude07","\\ud83d\\ude0f","\\ud83d\\udc6e","\\ud83d\\udc77","\\ud83d\\udc82","\\ud83d\\udc76","\\ud83d\\udc68","\\ud83d\\udc69","\\ud83d\\udc74","\\ud83d\\udc75","\\ud83d\\ude3b","\\ud83d\\ude3d","\\ud83d\\ude40","\\ud83d\\udc7a","\\ud83d\\ude48","\\ud83d\\ude49","\\ud83d\\ude4a","\\ud83d\\udc80","\\ud83d\\udc7d","\\ud83d\\udca9","\\ud83d\\udd25","\\ud83d\\udca5","\\ud83d\\udca4","\\ud83d\\udc42","\\ud83d\\udc40","\\ud83d\\udc43","\\ud83d\\udc45","\\ud83d\\udc44","\\ud83d\\udc4d","\\ud83d\\udc4e","\\ud83d\\udc4c","\\ud83d\\udc4a","\\u270c","\\u270b","\\ud83d\\udc50","\\ud83d\\udc46","\\ud83d\\udc47","\\ud83d\\udc49","\\ud83d\\udc48","\\ud83d\\ude4f","\\ud83d\\udc4f","\\ud83d\\udcaa","\\ud83d\\udeb6","\\ud83c\\udfc3","\\ud83d\\udc83","\\ud83d\\udc6b","\\ud83d\\udc6a","\\ud83d\\udc6c","\\ud83d\\udc6d","\\ud83d\\udc85","\\ud83c\\udfa9","\\ud83d\\udc51","\\ud83d\\udc52","\\ud83d\\udc5f","\\ud83d\\udc5e","\\ud83d\\udc60","\\ud83d\\udc55","\\ud83d\\udc57","\\ud83d\\udc56","\\ud83d\\udc59","\\ud83d\\udc5c","\\ud83d\\udc53","\\ud83c\\udf80","\\ud83d\\udc84","\\ud83d\\udc9b","\\ud83d\\udc99","\\ud83d\\udc9c","\\ud83d\\udc9a","\\ud83d\\udc8d","\\ud83d\\udc8e","\\ud83d\\udc36","\\ud83d\\udc3a","\\ud83d\\udc31","\\ud83d\\udc2d","\\ud83d\\udc39","\\ud83d\\udc30","\\ud83d\\udc38","\\ud83d\\udc2f","\\ud83d\\udc28","\\ud83d\\udc3b","\\ud83d\\udc37","\\ud83d\\udc2e","\\ud83d\\udc17","\\ud83d\\udc34","\\ud83d\\udc11","\\ud83d\\udc18","\\ud83d\\udc3c","\\ud83d\\udc27","\\ud83d\\udc25","\\ud83d\\udc14","\\ud83d\\udc0d","\\ud83d\\udc22","\\ud83d\\udc1b","\\ud83d\\udc1d","\\ud83d\\udc1c","\\ud83d\\udc1e","\\ud83d\\udc0c","\\ud83d\\udc19","\\ud83d\\udc1a","\\ud83d\\udc1f","\\ud83d\\udc2c","\\ud83d\\udc0b","\\ud83d\\udc10","\\ud83d\\udc0a","\\ud83d\\udc2b","\\ud83c\\udf40","\\ud83c\\udf39","\\ud83c\\udf3b","\\ud83c\\udf41","\\ud83c\\udf3e","\\ud83c\\udf44","\\ud83c\\udf35","\\ud83c\\udf34","\\ud83c\\udf33","\\ud83c\\udf1e","\\ud83c\\udf1a","\\ud83c\\udf19","\\ud83c\\udf0e","\\ud83c\\udf0b","\\u26a1","\\u2614","\\u2744","\\u26c4","\\ud83c\\udf00","\\ud83c\\udf08","\\ud83c\\udf0a","\\ud83c\\udf93","\\ud83c\\udf86","\\ud83c\\udf83","\\ud83d\\udc7b","\\ud83c\\udf85","\\ud83c\\udf84","\\ud83c\\udf81","\\ud83c\\udf88","\\ud83d\\udd2e","\\ud83c\\udfa5","\\ud83d\\udcf7","\\ud83d\\udcbf","\\ud83d\\udcbb","\\u260e","\\ud83d\\udce1","\\ud83d\\udcfa","\\ud83d\\udcfb","\\ud83d\\udd09","\\ud83d\\udd14","\\u23f3","\\u23f0","\\u231a","\\ud83d\\udd12","\\ud83d\\udd11","\\ud83d\\udd0e","\\ud83d\\udca1","\\ud83d\\udd26","\\ud83d\\udd0c","\\ud83d\\udd0b","\\ud83d\\udebf","\\ud83d\\udebd","\\ud83d\\udd27","\\ud83d\\udd28","\\ud83d\\udeaa","\\ud83d\\udeac","\\ud83d\\udca3","\\ud83d\\udd2b","\\ud83d\\udd2a","\\ud83d\\udc8a","\\ud83d\\udc89","\\ud83d\\udcb0","\\ud83d\\udcb5","\\ud83d\\udcb3","\\u2709","\\ud83d\\udceb","\\ud83d\\udce6","\\ud83d\\udcc5","\\ud83d\\udcc1","\\u2702","\\ud83d\\udccc","\\ud83d\\udcce","\\u2712","\\u270f","\\ud83d\\udcd0","\\ud83d\\udcda","\\ud83d\\udd2c","\\ud83d\\udd2d","\\ud83c\\udfa8","\\ud83c\\udfac","\\ud83c\\udfa4","\\ud83c\\udfa7","\\ud83c\\udfb5","\\ud83c\\udfb9","\\ud83c\\udfbb","\\ud83c\\udfba","\\ud83c\\udfb8","\\ud83d\\udc7e","\\ud83c\\udfae","\\ud83c\\udccf","\\ud83c\\udfb2","\\ud83c\\udfaf","\\ud83c\\udfc8","\\ud83c\\udfc0","\\u26bd","\\u26be","\\ud83c\\udfbe","\\ud83c\\udfb1","\\ud83c\\udfc9","\\ud83c\\udfb3","\\ud83c\\udfc1","\\ud83c\\udfc7","\\ud83c\\udfc6","\\ud83c\\udfca","\\ud83c\\udfc4","\\u2615","\\ud83c\\udf7c","\\ud83c\\udf7a","\\ud83c\\udf77","\\ud83c\\udf74","\\ud83c\\udf55","\\ud83c\\udf54","\\ud83c\\udf5f","\\ud83c\\udf57","\\ud83c\\udf71","\\ud83c\\udf5a","\\ud83c\\udf5c","\\ud83c\\udf61","\\ud83c\\udf73","\\ud83c\\udf5e","\\ud83c\\udf69","\\ud83c\\udf66","\\ud83c\\udf82","\\ud83c\\udf70","\\ud83c\\udf6a","\\ud83c\\udf6b","\\ud83c\\udf6d","\\ud83c\\udf6f","\\ud83c\\udf4e","\\ud83c\\udf4f","\\ud83c\\udf4a","\\ud83c\\udf4b","\\ud83c\\udf52","\\ud83c\\udf47","\\ud83c\\udf49","\\ud83c\\udf53","\\ud83c\\udf51","\\ud83c\\udf4c","\\ud83c\\udf50","\\ud83c\\udf4d","\\ud83c\\udf46","\\ud83c\\udf45","\\ud83c\\udf3d","\\ud83c\\udfe1","\\ud83c\\udfe5","\\ud83c\\udfe6","\\u26ea","\\ud83c\\udff0","\\u26fa","\\ud83c\\udfed","\\ud83d\\uddfb","\\ud83d\\uddfd","\\ud83c\\udfa0","\\ud83c\\udfa1","\\u26f2","\\ud83c\\udfa2","\\ud83d\\udea2","\\ud83d\\udea4","\\u2693","\\ud83d\\ude80","\\u2708","\\ud83d\\ude81","\\ud83d\\ude82","\\ud83d\\ude8b","\\ud83d\\ude8e","\\ud83d\\ude8c","\\ud83d\\ude99","\\ud83d\\ude97","\\ud83d\\ude95","\\ud83d\\ude9b","\\ud83d\\udea8","\\ud83d\\ude94","\\ud83d\\ude92","\\ud83d\\ude91","\\ud83d\\udeb2","\\ud83d\\udea0","\\ud83d\\ude9c","\\ud83d\\udea6","\\u26a0","\\ud83d\\udea7","\\u26fd","\\ud83c\\udfb0","\\ud83d\\uddff","\\ud83c\\udfaa","\\ud83c\\udfad","\\ud83c\\uddef\\ud83c\\uddf5","\\ud83c\\uddf0\\ud83c\\uddf7","\\ud83c\\udde9\\ud83c\\uddea","\\ud83c\\udde8\\ud83c\\uddf3","\\ud83c\\uddfa\\ud83c\\uddf8","\\ud83c\\uddeb\\ud83c\\uddf7","\\ud83c\\uddea\\ud83c\\uddf8","\\ud83c\\uddee\\ud83c\\uddf9","\\ud83c\\uddf7\\ud83c\\uddfa","\\ud83c\\uddec\\ud83c\\udde7","1\\u20e3","2\\u20e3","3\\u20e3","4\\u20e3","5\\u20e3","6\\u20e3","7\\u20e3","8\\u20e3","9\\u20e3","0\\u20e3","\\ud83d\\udd1f","\\u2757","\\u2753","\\u2665","\\u2666","\\ud83d\\udcaf","\\ud83d\\udd17","\\ud83d\\udd31","\\ud83d\\udd34","\\ud83d\\udd35","\\ud83d\\udd36","\\ud83d\\udd37"]';
+ /**
+ * Initialize magic constants
+ *
+ * @return void
+ */
public static function classExists()
{
\set_error_handler(['\\danog\\MadelineProto\\Exception', 'ExceptionErrorHandler']);
- \set_exceptionHandler(['\\danog\\MadelineProto\\Exception', 'ExceptionHandler']);
+ \set_exception_handler(['\\danog\\MadelineProto\\Exception', 'ExceptionHandler']);
if (!self::$inited) {
if (!\defined('\\phpseclib\\Crypt\\Common\\SymmetricKey::MODE_IGE') || \phpseclib\Crypt\Common\SymmetricKey::MODE_IGE !== 7) {
throw new Exception(\danog\MadelineProto\Lang::$current_lang['phpseclib_fork']);
@@ -200,6 +205,11 @@ class Magic
}
}
+ /**
+ * Check if this is a POSIX fork of the main PHP process
+ *
+ * @return boolean
+ */
public static function isFork()
{
if (self::$isFork) {
@@ -220,6 +230,11 @@ class Magic
}
}
+ /**
+ * Get current working directory
+ *
+ * @return string
+ */
public static function getcwd(): string
{
return self::$can_getcwd ? \getcwd() : self::$cwd;
diff --git a/src/danog/MadelineProto/Tools.php b/src/danog/MadelineProto/Tools.php
index 771aabfa..5d2c6278 100644
--- a/src/danog/MadelineProto/Tools.php
+++ b/src/danog/MadelineProto/Tools.php
@@ -42,7 +42,14 @@ use function Amp\Promise\wait;
*/
trait Tools
{
- public static function genVectorHash($ints)
+ /**
+ * Generate MTProto vector hash.
+ *
+ * @param array $ints IDs
+ *
+ * @return int Vector hash
+ */
+ public static function genVectorHash(array $ints): int
{
//sort($ints, SORT_NUMERIC);
if (\danog\MadelineProto\Magic::$bigint) {
@@ -61,7 +68,14 @@ trait Tools
return $hash;
}
- public static function randomInt($modulus = false)
+ /**
+ * Get random integer.
+ *
+ * @param integer $modulus Modulus
+ *
+ * @return int
+ */
+ public static function randomInt($modulus = false): int
{
if ($modulus === false) {
$modulus = PHP_INT_MAX;
@@ -89,23 +103,42 @@ trait Tools
return ($number & PHP_INT_MAX) % $modulus;
}
- public static function random($length)
+ /**
+ * Get random string of specified length.
+ *
+ * @param integer $length Length
+ *
+ * @return string Random string
+ */
+ public static function random(int $length): string
{
return $length === 0 ? '' : \phpseclib\Crypt\Random::string($length);
}
/**
- * posmod(numeric,numeric) : numeric
+ * Positive modulo
* Works just like the % (modulus) operator, only returns always a postive number.
+ *
+ * @param int $a A
+ * @param int $b B
+ *
+ * @return int Modulo
*/
- public static function posmod($a, $b)
+ public static function posmod(int $a, int $b): int
{
$resto = $a % $b;
return $resto < 0 ? $resto + \abs($b) : $resto;
}
- public static function unpackSignedInt($value)
+ /**
+ * Unpack base256 signed int.
+ *
+ * @param string $value base256 int
+ *
+ * @return integer
+ */
+ public static function unpackSignedInt($value): int
{
if (\strlen($value) !== 4) {
throw new TL\Exception(\danog\MadelineProto\Lang::$current_lang['length_not_4']);
@@ -114,7 +147,14 @@ trait Tools
return \unpack('l', \danog\MadelineProto\Magic::$BIG_ENDIAN ? \strrev($value) : $value)[1];
}
- public static function unpackSignedLong($value)
+ /**
+ * Unpack base256 signed long.
+ *
+ * @param string $value base256 long
+ *
+ * @return integer
+ */
+ public static function unpackSignedLong($value): int
{
if (\strlen($value) !== 8) {
throw new TL\Exception(\danog\MadelineProto\Lang::$current_lang['length_not_8']);
@@ -122,8 +162,14 @@ trait Tools
return \unpack('q', \danog\MadelineProto\Magic::$BIG_ENDIAN ? \strrev($value) : $value)[1];
}
-
- public static function unpackSignedLongString($value)
+ /**
+ * Unpack base256 signed long to string.
+ *
+ * @param string $value base256 long
+ *
+ * @return string
+ */
+ public static function unpackSignedLongString($value): string
{
if (\is_int($value)) {
return (string) $value;
@@ -136,7 +182,14 @@ trait Tools
return (string) $big;
}
- public static function packSignedInt($value)
+ /**
+ * Convert integer to base256 signed int.
+ *
+ * @param integer $value Value to convert
+ *
+ * @return string
+ */
+ public static function packSignedInt(int $value): string
{
if ($value > 2147483647) {
throw new TL\Exception(\sprintf(\danog\MadelineProto\Lang::$current_lang['value_bigger_than_2147483647'], $value));
@@ -149,7 +202,14 @@ trait Tools
return \danog\MadelineProto\Magic::$BIG_ENDIAN ? \strrev($res) : $res;
}
- public static function packSignedLong($value)
+ /**
+ * Convert integer to base256 long.
+ *
+ * @param int $value Value to convert
+ *
+ * @return string
+ */
+ public static function packSignedLong(int $value): string
{
if ($value > 9223372036854775807) {
throw new TL\Exception(\sprintf(\danog\MadelineProto\Lang::$current_lang['value_bigger_than_9223372036854775807'], $value));
@@ -162,7 +222,14 @@ trait Tools
return $res;
}
- public static function packUnsignedInt($value)
+ /**
+ * Convert value to unsigned base256 int
+ *
+ * @param int $value Value
+ *
+ * @return string
+ */
+ public static function packUnsignedInt(int $value): string
{
if ($value > 4294967295) {
throw new TL\Exception(\sprintf(\danog\MadelineProto\Lang::$current_lang['value_bigger_than_4294967296'], $value));
@@ -174,7 +241,14 @@ trait Tools
return \pack('V', $value);
}
- public static function packDouble($value)
+ /**
+ * Convert double to binary version
+ *
+ * @param double $value Value to convert
+ *
+ * @return string
+ */
+ public static function packDouble(double $value): string
{
$res = \pack('d', $value);
if (\strlen($res) !== 8) {
@@ -184,7 +258,14 @@ trait Tools
return \danog\MadelineProto\Magic::$BIG_ENDIAN ? \strrev($res) : $res;
}
- public static function unpackDouble($value)
+ /**
+ * Unpack binary double
+ *
+ * @param string $value Value to unpack
+ *
+ * @return double
+ */
+ public static function unpackDouble(string $value): double
{
if (\strlen($value) !== 8) {
throw new TL\Exception(\danog\MadelineProto\Lang::$current_lang['length_not_8']);
@@ -193,6 +274,14 @@ trait Tools
return \unpack('d', \danog\MadelineProto\Magic::$BIG_ENDIAN ? \strrev($value) : $value)[1];
}
+ /**
+ * Synchronously wait for a promise|generator
+ *
+ * @param \Generator|Promise $promise The promise to wait for
+ * @param boolean $ignoreSignal Whether to ignore shutdown signals
+ *
+ * @return mixed
+ */
public static function wait($promise, $ignoreSignal = false)
{
if ($promise instanceof \Generator) {
@@ -226,7 +315,15 @@ trait Tools
return $value;
}
- public static function all($promises)
+ /**
+ * Returns a promise that succeeds when all promises succeed, and fails if any promise fails.
+ * Returned promise succeeds with an array of values used to succeed each contained promise, with keys corresponding to the array of promises.
+ *
+ * @param array<\Generator|Promise> $promises Promises
+ *
+ * @return Promise
+ */
+ public static function all(array $promises): Promise
{
foreach ($promises as &$promise) {
$promise = self::call($promise);
@@ -235,7 +332,14 @@ trait Tools
return all($promises);
}
- public static function any($promises)
+ /**
+ * Returns a promise that is resolved when all promises are resolved. The returned promise will not fail.
+ *
+ * @param array $promises Promises
+ *
+ * @return Promise
+ */
+ public static function any(array $promises): Promise
{
foreach ($promises as &$promise) {
$promise = self::call($promise);
@@ -244,7 +348,15 @@ trait Tools
return any($promises);
}
- public static function some($promises)
+ /**
+ * Resolves with a two-item array delineating successful and failed Promise results.
+ * The returned promise will only fail if the given number of required promises fail.
+ *
+ * @param array $promises Promises
+ *
+ * @return Promise
+ */
+ public static function some(array $promises): Promise
{
foreach ($promises as &$promise) {
$promise = self::call($promise);
@@ -253,7 +365,14 @@ trait Tools
return some($promises);
}
- public static function first($promises)
+ /**
+ * Returns a promise that succeeds when the first promise succeeds, and fails only if all promises fail.
+ *
+ * @param array $promises Promises
+ *
+ * @return Promise
+ */
+ public static function first(array $promises): Promise
{
foreach ($promises as &$promise) {
$promise = self::call($promise);
@@ -262,12 +381,27 @@ trait Tools
return first($promises);
}
- public static function timeout($promise, $timeout)
+ /**
+ * Create an artificial timeout for any \Generator or Promise
+ *
+ * @param \Generator|Promise $promise
+ * @param integer $timeout
+ *
+ * @return Promise
+ */
+ public static function timeout($promise, int $timeout): Promise
{
return timeout(self::call($promise), $timeout);
}
- public static function call($promise)
+ /**
+ * Convert generator, promise or any other value to a promise
+ *
+ * @param \Generator|Promise|mixed $promise
+ *
+ * @return Promise
+ */
+ public static function call($promise): Promise
{
if ($promise instanceof \Generator) {
$promise = new Coroutine($promise);
@@ -278,6 +412,15 @@ trait Tools
return $promise;
}
+ /**
+ * Call promise in background
+ *
+ * @param \Generator|Promise $promise Promise to resolve
+ * @param ?\Generator|Promise $actual Promise to resolve instead of $promise
+ * @param string $file File
+ *
+ * @return void
+ */
public static function callFork($promise, $actual = null, $file = '')
{
if ($actual) {
@@ -310,12 +453,27 @@ trait Tools
return $promise;
}
+ /**
+ * Call promise in background, deferring execution
+ *
+ * @param \Generator|Promise $promise Promise to resolve
+ *
+ * @return void
+ */
public static function callForkDefer($promise)
{
Loop::defer([__CLASS__, 'callFork'], $promise);
}
- public static function rethrow($e, $file = '')
+ /**
+ * Rethrow error catched in strand
+ *
+ * @param \Throwable $e Exception
+ * @param string $file File where the strand started
+ *
+ * @return void
+ */
+ public static function rethrow(\Throwable $e, $file = '')
{
$zis = isset($this) ? $this : null;
$logger = isset($zis->logger) ? $zis->logger : Logger::$default;
@@ -340,7 +498,15 @@ trait Tools
}
}
- public static function after($a, $b)
+ /**
+ * Call promise $b after promise $a
+ *
+ * @param \Generator|Promise $a Promise A
+ * @param \Generator|Promise $b Promise B
+ *
+ * @return Promise
+ */
+ public static function after($a, $b): Promise
{
$a = self::call($a());
$deferred = new Deferred();
@@ -370,19 +536,14 @@ trait Tools
return $deferred->promise();
}
/**
- * Asynchronously lock a file
- * Resolves with a callbable that MUST eventually be called in order to release the lock.
+ * Asynchronously send noCache headers.
+ *
+ * @param integer $status HTTP status code to send
+ * @param string $message Message to print
*
- * @param string $file File to lock
- * @param integer $operation Locking mode (see flock)
- * @param numeric $polling Polling interval for lock
* @return Promise
*/
- public static function flock(string $file, int $operation, $polling = 0.1): Promise
- {
- return self::call(self::flockGenerator($file, $operation, $polling));
- }
- public static function noCache(int $status, string $message)
+ public static function noCache(int $status, string $message): Promise
{
\header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
\header('Cache-Control: post-check=0, pre-check=0', false);
@@ -390,7 +551,31 @@ trait Tools
\http_response_code($status);
return self::echo($message);
}
- public static function flockGenerator(string $file, int $operation, $polling)
+
+ /**
+ * Asynchronously lock a file
+ * Resolves with a callbable that MUST eventually be called in order to release the lock.
+ *
+ * @param string $file File to lock
+ * @param integer $operation Locking mode
+ * @param integer $polling Polling interval
+ *
+ * @return Promise
+ */
+ public static function flock(string $file, int $operation, $polling = 0.1): Promise
+ {
+ return self::call(self::flockGenerator($file, $operation, $polling));
+ }
+ /**
+ * Asynchronously lock a file (internal generator function).
+ *
+ * @param string $file File to lock
+ * @param integer $operation Locking mode
+ * @param integer $polling Polling interval
+ *
+ * @return void
+ */
+ private static function flockGenerator(string $file, int $operation, $polling)
{
if (!yield exists($file)) {
yield \touch($file);
@@ -413,15 +598,37 @@ trait Tools
}
};
}
- public static function sleep($time)
+ /**
+ * Asynchronously sleep.
+ *
+ * @param int $time Number of seconds to sleep for
+ *
+ * @return Promise
+ */
+ public static function sleep(int $time): Promise
{
return new \Amp\Delayed($time * 1000);
}
- public static function readLine($prompt = '')
+
+ /**
+ * Asynchronously read line.
+ *
+ * @param string $prompt Prompt
+ *
+ * @return Promise
+ */
+ public static function readLine(string $prompt = ''): Promise
{
return self::call(Tools::readLineGenerator($prompt));
}
- public static function readLineGenerator($prompt = '')
+ /**
+ * Asynchronously read line (generator function).
+ *
+ * @param string $prompt Prompt
+ *
+ * @return void
+ */
+ private static function readLineGenerator(string $prompt = '')
{
$stdin = getStdin();
$stdout = getStdout();
@@ -437,10 +644,24 @@ trait Tools
return \array_shift($lines);
}
- public static function echo($string)
+ /**
+ * Asynchronously write to stdout/browser.
+ *
+ * @param string $string Message to echo
+ *
+ * @return Promise
+ */
+ public static function echo(string $string): Promise
{
return getOutputBufferStream()->write($string);
}
+ /**
+ * Check if is array or similar (traversable && countable && arrayAccess).
+ *
+ * @param arraylike $var Value to check
+ *
+ * @return boolean
+ */
public static function isArrayOrAlike($var)
{
return \is_array($var) ||
@@ -489,17 +710,37 @@ trait Tools
{
return $params;
}
- public function base64urlDecode($data)
+ /**
+ * base64URL decode.
+ *
+ * @param string $data Data to decode
+ *
+ * @return string
+ */
+ public function base64urlDecode(string $data): string
{
return \base64_decode(\str_pad(\strtr($data, '-_', '+/'), \strlen($data) % 4, '=', STR_PAD_RIGHT));
}
-
- public function base64urlEncode($data)
+ /**
+ * Base64URL encode.
+ *
+ * @param string $data Data to encode
+ *
+ * @return string
+ */
+ public function base64urlEncode(string $data): string
{
return \rtrim(\strtr(\base64_encode($data), '+/', '-_'), '=');
}
- public function rleDecode($string)
+ /**
+ * null-byte RLE decode.
+ *
+ * @param string $string Data to decode
+ *
+ * @return string
+ */
+ public function rleDecode(string $string): string
{
$new = '';
$last = '';
@@ -518,7 +759,14 @@ trait Tools
return $string;
}
- public function rleEncode($string)
+ /**
+ * null-byte RLE encode.
+ *
+ * @param string $string Data to encode
+ *
+ * @return string
+ */
+ public function rleEncode(string $string): string
{
$new = '';
$count = 0;
@@ -537,4 +785,28 @@ trait Tools
return $new;
}
+
+ /**
+ * Get final element of array.
+ *
+ * @param array $what Array
+ *
+ * @return mixed
+ */
+ public static function end(array $what)
+ {
+ return \end($what);
+ }
+
+ /**
+ * Escape string for markdown.
+ *
+ * @param string $hwat String to escape
+ *
+ * @return void
+ */
+ public function markdownEscape(string $hwat): string
+ {
+ return \str_replace('_', '\\_', $hwat);
+ }
}