Layer 113

This commit is contained in:
Daniil Gentili 2020-06-16 17:52:55 +02:00
parent 0e9f107754
commit 69f33dce34
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
39 changed files with 2683 additions and 1436 deletions

102
README.md
View File

@ -191,6 +191,8 @@ You can find examples for nearly every MadelineProto function in
* [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)
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.acceptLoginToken.html" name="auth.acceptLoginToken">Accept QR code login token, logging in the app that generated it: auth.acceptLoginToken</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.acceptCall.html" name="phone.acceptCall">Accept incoming call: phone.acceptCall</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.acceptTermsOfService.html" name="help.acceptTermsOfService">Accept the new terms of service: help.acceptTermsOfService</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.saveGif.html" name="messages.saveGif">Add GIF to saved gifs list: messages.saveGif</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/stickers.addStickerToSet.html" name="stickers.addStickerToSet">Add a sticker to a stickerset, bots only. The sticker set must have been created by the bot: stickers.addStickerToSet</a>
@ -200,11 +202,14 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.block.html" name="contacts.block">Adds the user to the blacklist: contacts.block</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.setInlineBotResults.html" name="messages.setInlineBotResults">Answer an inline query, for bots only: messages.setInlineBotResults</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/bots.answerWebhookJSONQuery.html" name="bots.answerWebhookJSONQuery">Answers a custom query; for bots only: bots.answerWebhookJSONQuery</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.toggleStickerSets.html" name="messages.toggleStickerSets">Apply changes to multiple stickersets: messages.toggleStickerSets</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.setDiscussionGroup.html" name="channels.setDiscussionGroup">Associate a group to a channel as discussion group for that channel: channels.setDiscussionGroup</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.setStickers.html" name="channels.setStickers">Associate a stickerset to the supergroup: channels.setStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.editBanned.html" name="channels.editBanned">Ban/unban/kick a user in a supergroup/channel: channels.editBanned</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.bindTempAuthKey.html" name="auth.bindTempAuthKey">Binds a temporary authorization key temp_auth_key_id to the permanent authorization key perm_auth_key_id. Each permanent key may only be bound to one temporary key at a time, binding a new temporary key overwrites the previous one: auth.bindTempAuthKey</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.cancelPasswordEmail.html" name="account.cancelPasswordEmail">Cancel the code that was sent to verify an email to use as 2FA recovery method: account.cancelPasswordEmail</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.cancelCode.html" name="auth.cancelCode">Cancel the login verification code: auth.cancelCode</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.discardEncryption.html" name="messages.discardEncryption">Cancels a request for creation and/or delete info on secret chat: messages.discardEncryption</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.editChatTitle.html" name="messages.editChatTitle">Chanages chat name and sends a service message on it: messages.editChatTitle</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.saveAutoDownloadSettings.html" name="account.saveAutoDownloadSettings">Change media autodownload settings: account.saveAutoDownloadSettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.setPrivacy.html" name="account.setPrivacy">Change privacy settings of current account: account.setPrivacy</a>
@ -220,14 +225,16 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.clearRecentStickers.html" name="messages.clearRecentStickers">Clear recent stickers: messages.clearRecentStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.clearSavedInfo.html" name="payments.clearSavedInfo">Clear saved payment information: payments.clearSavedInfo</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.confirmPhone.html" name="account.confirmPhone">Confirm a phone number to cancel account deletion, for more info click here »: account.confirmPhone</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.acceptEncryption.html" name="messages.acceptEncryption">Confirms creation of a secret chat: messages.acceptEncryption</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.receivedMessages.html" name="messages.receivedMessages">Confirms receipt of messages by a client, cancels PUSH-notification sending: messages.receivedMessages</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.receivedQueue.html" name="messages.receivedQueue">Confirms receipt of messages in a secret chat by client, cancels push notifications: messages.receivedQueue</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.createChannel.html" name="channels.createChannel">Create a supergroup/channel: channels.createChannel</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/stickers.createStickerSet.html" name="stickers.createStickerSet">Create a stickerset, bots only: stickers.createStickerSet</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.createTheme.html" name="account.createTheme">Create a theme: account.createTheme</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.uploadWallPaper.html" name="account.uploadWallPaper">Create and upload a new wallpaper: account.uploadWallPaper</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.createChat.html" name="messages.createChat">Creates a new chat: messages.createChat</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.deleteChannel.html" name="channels.deleteChannel">Delete a channel/supergroup: channels.deleteChannel</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/folders.deleteFolder.html" name="folders.deleteFolder">Delete a folder: folders.deleteFolder</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/folders.deleteFolder.html" name="folders.deleteFolder">Delete a peer folder: folders.deleteFolder</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.deleteUserHistory.html" name="channels.deleteUserHistory">Delete all messages sent by a certain user in a supergroup: channels.deleteUserHistory</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.dropTempAuthKeys.html" name="auth.dropTempAuthKeys">Delete all temporary authorization keys except for the ones specified: auth.dropTempAuthKeys</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.deleteByPhones.html" name="contacts.deleteByPhones">Delete contacts by phone number: contacts.deleteByPhones</a>
@ -245,10 +252,11 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/photos.deletePhotos.html" name="photos.deletePhotos">Deletes profile photos: photos.deletePhotos</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.deleteContacts.html" name="contacts.deleteContacts">Deletes several contacts from the list: contacts.deleteContacts</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.unblock.html" name="contacts.unblock">Deletes the user from the blacklist: contacts.unblock</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.getCdnFile.html" name="upload.getCdnFile">Download a CDN file: upload.getCdnFile</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.editInlineBotMessage.html" name="messages.editInlineBotMessage">Edit an inline bot message: messages.editInlineBotMessage</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.editLocation.html" name="channels.editLocation">Edit location of geogroup: channels.editLocation</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.editMessage.html" name="messages.editMessage">Edit message: messages.editMessage</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/folders.editPeerFolders.html" name="folders.editPeerFolders">Edit peers in folder: folders.editPeerFolders</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/folders.editPeerFolders.html" name="folders.editPeerFolders">Edit peers in peer folder: folders.editPeerFolders</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.editChatDefaultBannedRights.html" name="messages.editChatDefaultBannedRights">Edit the default banned rights of a channel/supergroup/group: messages.editChatDefaultBannedRights</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.editChatAbout.html" name="messages.editChatAbout">Edit the description of a group/supergroup/channel: messages.editChatAbout</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.editTitle.html" name="channels.editTitle">Edit the name of a channel/supergroup: channels.editTitle</a>
@ -259,10 +267,17 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getMessageEditData.html" name="messages.getMessageEditData">Find out if a media message's caption can be edited: messages.getMessageEditData</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.finishTakeoutSession.html" name="account.finishTakeoutSession">Finish account takeout session: account.finishTakeoutSession</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.forwardMessages.html" name="messages.forwardMessages">Forwards messages by their IDs: messages.forwardMessages</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.exportLoginToken.html" name="auth.exportLoginToken">Generate a login token, for login via QR code. : auth.exportLoginToken</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getPromoData.html" name="help.getPromoData">Get MTProxy/Public Service Announcement information: help.getPromoData</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.getCdnFileHashes.html" name="upload.getCdnFileHashes">Get SHA256 hashes for verifying downloaded CDN files: upload.getCdnFileHashes</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.getFileHashes.html" name="upload.getFileHashes">Get SHA256 hashes for verifying downloaded files: upload.getFileHashes</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/stats.getBroadcastStats.html" name="stats.getBroadcastStats">Get channel statistics: stats.getBroadcastStats</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getMessages.html" name="channels.getMessages">Get channel/supergroup messages: channels.getMessages</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getAdminedPublicChannels.html" name="channels.getAdminedPublicChannels">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</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getDialogFilters.html" name="messages.getDialogFilters">Get folders: messages.getDialogFilters</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getWebPage.html" name="messages.getWebPage">Get instant view page: messages.getWebPage</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getPassportConfig.html" name="help.getPassportConfig">Get passport configuration: help.getPassportConfig</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getSuggestedDialogFilters.html" name="messages.getSuggestedDialogFilters">Get suggested folders: messages.getSuggestedDialogFilters</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getDocumentByHash.html" name="messages.getDocumentByHash">Get a document by its SHA256 hash, mainly used for gifs: messages.getDocumentByHash</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getLeftChannels.html" name="channels.getLeftChannels">Get a list of channels/supergroups we left: channels.getLeftChannels</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getPaymentForm.html" name="payments.getPaymentForm">Get a payment form: payments.getPaymentForm</a>
@ -273,9 +288,9 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getAllStickers.html" name="messages.getAllStickers">Get all installed stickers: messages.getAllStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getAllSecureValues.html" name="account.getAllSecureValues">Get all saved Telegram Passport documents, for more info see the passport docs »: account.getAllSecureValues</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getMessagesViews.html" name="messages.getMessagesViews">Get and increase the view counter of a message sent or forwarded from a channel: messages.getMessagesViews</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getAppConfig.html" name="help.getAppConfig">Get app-specific configuration: help.getAppConfig</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getAppConfig.html" name="help.getAppConfig">Get app-specific configuration, see client configuration for more info on the result: help.getAppConfig</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getEmojiKeywordsDifference.html" name="messages.getEmojiKeywordsDifference">Get changed emoji keywords: messages.getEmojiKeywordsDifference</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getAppChangelog.html" name="help.getAppChangelog">Get changelog of current app: help.getAppChangelog</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getAppChangelog.html" name="help.getAppChangelog">Get changelog of current app. : help.getAppChangelog</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getCommonChats.html" name="messages.getCommonChats">Get chats in common with a user: messages.getCommonChats</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getCdnConfig.html" name="help.getCdnConfig">Get configuration for CDN file downloads: help.getCdnConfig</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.getContactIDs.html" name="contacts.getContactIDs">Get contact by telegram IDs: contacts.getContactIDs</a>
@ -286,14 +301,18 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getDialogUnreadMarks.html" name="messages.getDialogUnreadMarks">Get dialogs manually marked as unread: messages.getDialogUnreadMarks</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getFavedStickers.html" name="messages.getFavedStickers">Get faved stickers: messages.getFavedStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getFeaturedStickers.html" name="messages.getFeaturedStickers">Get featured stickers: messages.getFeaturedStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getFullChannel.html" name="channels.getFullChannel">Get full info about a channel: channels.getFullChannel</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getInlineGameHighScores.html" name="messages.getInlineGameHighScores">Get highscores of a game sent using an inline bot: messages.getInlineGameHighScores</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getGameHighScores.html" name="messages.getGameHighScores">Get highscores of a game: messages.getGameHighScores</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getInactiveChannels.html" name="channels.getInactiveChannels">Get inactive channels and supergroups: channels.getInactiveChannels</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getChannels.html" name="channels.getChannels">Get info about channels/supergroups: channels.getChannels</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getParticipant.html" name="channels.getParticipant">Get info about a channel/supergroup participant: channels.getParticipant</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getDeepLinkInfo.html" name="help.getDeepLinkInfo">Get info about a t.me link: help.getDeepLinkInfo</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getWallPaper.html" name="account.getWallPaper">Get info about a certain wallpaper: account.getWallPaper</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getBankCardData.html" name="payments.getBankCardData">Get info about a credit card: payments.getBankCardData</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getStickerSet.html" name="messages.getStickerSet">Get info about a stickerset: messages.getStickerSet</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getEmojiKeywordsLanguages.html" name="messages.getEmojiKeywordsLanguages">Get info about an emoji keyword localization: messages.getEmojiKeywordsLanguages</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getMultiWallPapers.html" name="account.getMultiWallPapers">Get info about multiple wallpapers: account.getMultiWallPapers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/langpack.getLanguage.html" name="langpack.getLanguage">Get information about a language in a localization pack: langpack.getLanguage</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/langpack.getLanguages.html" name="langpack.getLanguages">Get information about all languages in a localization pack: langpack.getLanguages</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getMaskStickers.html" name="messages.getMaskStickers">Get installed mask stickers: messages.getMaskStickers</a>
@ -308,15 +327,17 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getSplitRanges.html" name="messages.getSplitRanges">Get message ranges for saving the user's chat history: messages.getSplitRanges</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.requestUrlAuth.html" name="messages.requestUrlAuth">Get more info about a Seamless Telegram Login authorization request, for more info click here »: messages.requestUrlAuth</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.getTopPeers.html" name="contacts.getTopPeers">Get most used peers: contacts.getTopPeers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/updates.getDifference.html" name="updates.getDifference">Get new updates: updates.getDifference</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/langpack.getDifference.html" name="langpack.getDifference">Get new strings in languagepack: langpack.getDifference</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getPaymentReceipt.html" name="payments.getPaymentReceipt">Get payment receipt: payments.getPaymentReceipt</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getPeerSettings.html" name="messages.getPeerSettings">Get peer settings: messages.getPeerSettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.getCallConfig.html" name="phone.getCallConfig">Get phone call configuration to be passed to libtgvoip's shared config: phone.getCallConfig</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getPinnedDialogs.html" name="messages.getPinnedDialogs">Get pinned dialogs: messages.getPinnedDialogs</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getPollVotes.html" name="messages.getPollVotes">Get poll results for non-anonymous polls: messages.getPollVotes</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getPollResults.html" name="messages.getPollResults">Get poll results: messages.getPollResults</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getWebPagePreview.html" name="messages.getWebPagePreview">Get preview of webpage: messages.getWebPagePreview</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getPrivacy.html" name="account.getPrivacy">Get privacy settings of current account: account.getPrivacy</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getProxyData.html" name="help.getProxyData">Get promotion info of the currently-used MTProxy: help.getProxyData</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getPasswordSettings.html" name="account.getPasswordSettings">Get private info associated to the password info (recovery email, telegram passport info & so on): account.getPasswordSettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getRecentStickers.html" name="messages.getRecentStickers">Get recent stickers: messages.getRecentStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getRecentMeUrls.html" name="help.getRecentMeUrls">Get recently used t.me links: help.getRecentMeUrls</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getSavedGifs.html" name="messages.getSavedGifs">Get saved GIFs: messages.getSavedGifs</a>
@ -324,6 +345,7 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getSavedInfo.html" name="payments.getSavedInfo">Get saved payment information: payments.getSavedInfo</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getScheduledHistory.html" name="messages.getScheduledHistory">Get scheduled messages: messages.getScheduledHistory</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getScheduledMessages.html" name="messages.getScheduledMessages">Get scheduled messages: messages.getScheduledMessages</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getContentSettings.html" name="account.getContentSettings">Get sensitive content settings: account.getContentSettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getAttachedStickers.html" name="messages.getAttachedStickers">Get stickers attached to a photo or video: messages.getAttachedStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getStickers.html" name="messages.getStickers">Get stickers by emoji: messages.getStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/langpack.getStrings.html" name="langpack.getStrings">Get strings from a language pack: langpack.getStrings</a>
@ -337,6 +359,7 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.search.html" name="messages.search">Gets back found messages: messages.search</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getHistory.html" name="messages.getHistory">Gets back the conversation history with one interlocutor / within a chat: messages.getHistory</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getNotifySettings.html" name="account.getNotifySettings">Gets current notification settings for a given user/group, from all users/all groups: account.getNotifySettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.hidePromoData.html" name="help.hidePromoData">Hide MTProxy/Public Service Announcement information: help.hidePromoData</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.togglePreHistoryHidden.html" name="channels.togglePreHistoryHidden">Hide/unhide message history for new channel/supergroup users: channels.togglePreHistoryHidden</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.acceptContact.html" name="contacts.acceptContact">If the peer settings of a new user allow us to add him as contact, add that user as contact: contacts.acceptContact</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.setBotShippingResults.html" name="messages.setBotShippingResults">If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the bot will receive an updateBotShippingQuery update. Use this method to reply to shipping queries: messages.setBotShippingResults</a>
@ -361,8 +384,13 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/invokeAfterMsg.html" name="invokeAfterMsg">Invokes a query after successfull completion of one of the previous queries: invokeAfterMsg</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.joinChannel.html" name="channels.joinChannel">Join a channel/supergroup: channels.joinChannel</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.leaveChannel.html" name="channels.leaveChannel">Leave a channel/supergroup: channels.leaveChannel</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/stats.loadAsyncGraph.html" name="stats.loadAsyncGraph">Load channel statistics graph asynchronously: stats.loadAsyncGraph</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.resetAuthorization.html" name="account.resetAuthorization">Log out an active authorized session by its hash: account.resetAuthorization</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.resetWebAuthorization.html" name="account.resetWebAuthorization">Log out an active web telegram login session: account.resetWebAuthorization</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.importBotAuthorization.html" name="auth.importBotAuthorization">Login as a bot: auth.importBotAuthorization</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.importLoginToken.html" name="auth.importLoginToken">Login using a redirected login token, generated in case of DC mismatch during QR code login: auth.importLoginToken</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.importAuthorization.html" name="auth.importAuthorization">Logs in a user using a key transmitted from his native data-centre: auth.importAuthorization</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.logOut.html" name="auth.logOut">Logs out the user: auth.logOut</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getTermsOfServiceUpdate.html" name="help.getTermsOfServiceUpdate">Look for updates of telegram's terms of service: help.getTermsOfServiceUpdate</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.editChatAdmin.html" name="messages.editChatAdmin">Make a user admin in a legacy group: messages.editChatAdmin</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.markDialogUnread.html" name="messages.markDialogUnread">Manually mark dialog as unread: messages.markDialogUnread</a>
@ -373,6 +401,7 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.readFeaturedStickers.html" name="messages.readFeaturedStickers">Mark new featured stickers as read: messages.readFeaturedStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.readHistory.html" name="messages.readHistory">Marks message history as read: messages.readHistory</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.readEncryptedHistory.html" name="messages.readEncryptedHistory">Marks message history within a secret chat as read: messages.readEncryptedHistory</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getOldFeaturedStickers.html" name="messages.getOldFeaturedStickers">Method for fetching previously featured stickers: messages.getOldFeaturedStickers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.editAdmin.html" name="channels.editAdmin">Modify the admin rights of a user in a supergroup/channel: channels.editAdmin</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.readMessageContents.html" name="messages.readMessageContents">Notifies the sender about the recipient having listened a voice message or watched a video: messages.readMessageContents</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.sendScreenshotNotification.html" name="messages.sendScreenshotNotification">Notify the other user in a private chat that a screenshot of the chat was taken: messages.sendScreenshotNotification</a>
@ -385,8 +414,11 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getBotCallbackAnswer.html" name="messages.getBotCallbackAnswer">Press an inline callback button and get a callback answer from the bot: messages.getBotCallbackAnswer</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getInlineBotResults.html" name="messages.getInlineBotResults">Query an inline bot: messages.getInlineBotResults</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.setCallRating.html" name="phone.setCallRating">Rate a call: phone.setCallRating</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.discardCall.html" name="phone.discardCall">Refuse or end running call: phone.discardCall</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.registerDevice.html" name="account.registerDevice">Register device to receive PUSH notifications: account.registerDevice</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.signUp.html" name="auth.signUp">Registers a validated phone number in the system: auth.signUp</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/stickers.removeStickerFromSet.html" name="stickers.removeStickerFromSet">Remove a sticker from the set where it belongs, bots only. The sticker set must have been created by the bot: stickers.removeStickerFromSet</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.updateDialogFiltersOrder.html" name="messages.updateDialogFiltersOrder">Reorder folders: messages.updateDialogFiltersOrder</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.reorderStickerSets.html" name="messages.reorderStickerSets">Reorder installed stickersets: messages.reorderStickerSets</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.reorderPinnedDialogs.html" name="messages.reorderPinnedDialogs">Reorder pinned dialogs: messages.reorderPinnedDialogs</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.report.html" name="messages.report">Report a message in a chat for violation of telegram's Terms of Service: messages.report</a>
@ -394,6 +426,7 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.reportPeer.html" name="account.reportPeer">Report a peer for violation of telegram's Terms of Service: account.reportPeer</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.reportEncryptedSpam.html" name="messages.reportEncryptedSpam">Report a secret chat for spam: messages.reportEncryptedSpam</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.reportSpam.html" name="channels.reportSpam">Reports some messages from a user in a supergroup as spam; requires administrator rights in the supergroup: channels.reportSpam</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.reuploadCdnFile.html" name="upload.reuploadCdnFile">Request a reupload of a certain file to a CDN DC: upload.reuploadCdnFile</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.requestPasswordRecovery.html" name="auth.requestPasswordRecovery">Request recovery code of a 2FA password, only for accounts with a recovery email configured: auth.requestPasswordRecovery</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.resendPasswordEmail.html" name="account.resendPasswordEmail">Resend the code to verify an email to use as 2FA recovery method: account.resendPasswordEmail</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.resendCode.html" name="auth.resendCode">Resend the login code via another medium, the phone code type is determined by the return value of the previous auth.sendCode/auth.resendCode: see login for more info: auth.resendCode</a>
@ -401,20 +434,28 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.resetWebAuthorizations.html" name="account.resetWebAuthorizations">Reset all active web telegram login sessions: account.resetWebAuthorizations</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.recoverPassword.html" name="auth.recoverPassword">Reset the 2FA password using the recovery code sent using auth.requestPasswordRecovery: auth.recoverPassword</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.resetNotifySettings.html" name="account.resetNotifySettings">Resets all notification settings from users and groups: account.resetNotifySettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.resolveUsername.html" name="contacts.resolveUsername">Resolve a @username to get peer info: contacts.resolveUsername</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getStatsURL.html" name="messages.getStatsURL">Returns URL with the chat statistics. Currently this method can be used only for channels: messages.getStatsURL</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getAuthorizationForm.html" name="account.getAuthorizationForm">Returns a Telegram Passport authorization form for sharing data with a service: account.getAuthorizationForm</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/updates.getState.html" name="updates.getState">Returns a current state of updates: updates.getState</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getWallPapers.html" name="account.getWallPapers">Returns a list of available wallpapers: account.getWallPapers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getEmojiURL.html" name="messages.getEmojiURL">Returns an HTTP URL which can be used to automatically log in into translation platform and suggest new emoji replacements. The URL will be valid for 30 seconds after generation: messages.getEmojiURL</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/users.getUsers.html" name="users.getUsers">Returns basic user info according to their identifiers: users.getUsers</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getChats.html" name="messages.getChats">Returns chat basic info on their IDs: messages.getChats</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getDhConfig.html" name="messages.getDhConfig">Returns configuration parameters for Diffie-Hellman key generation. Can also return a random sequence of bytes of required length: messages.getDhConfig</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.getFile.html" name="upload.getFile">Returns content of a whole file or its part: upload.getFile</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.getWebFile.html" name="upload.getWebFile">Returns content of an HTTP file or a part, by proxying the request through telegram: upload.getWebFile</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getConfig.html" name="help.getConfig">Returns current configuration, icluding data center configuration: help.getConfig</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getConfig.html" name="help.getConfig">Returns current configuration, including data center configuration: help.getConfig</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.exportAuthorization.html" name="auth.exportAuthorization">Returns data for copying authorization to another data-centre: auth.exportAuthorization</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/users.getFullUser.html" name="users.getFullUser">Returns extended user info by ID: users.getFullUser</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getFullChat.html" name="messages.getFullChat">Returns full chat info according to its ID: messages.getFullChat</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getNearestDc.html" name="help.getNearestDc">Returns info on data centre nearest to the user: help.getNearestDc</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getAppUpdate.html" name="help.getAppUpdate">Returns information on update availability for the current application: help.getAppUpdate</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getNotifyExceptions.html" name="account.getNotifyExceptions">Returns list of chats with non-default notification settings: account.getNotifyExceptions</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getInviteText.html" name="help.getInviteText">Returns text of a text message with an invitation: help.getInviteText</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.getInviteText.html" name="help.getInviteText">Returns localized text of a text message with an invitation: help.getInviteText</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getDialogs.html" name="messages.getDialogs">Returns the current user dialog list: messages.getDialogs</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.getContacts.html" name="contacts.getContacts">Returns the current user's contact list: contacts.getContacts</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/updates.getChannelDifference.html" name="updates.getChannelDifference">Returns the difference between the current state of updates of a certain channel and transmitted: updates.getChannelDifference</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.getBlocked.html" name="contacts.getBlocked">Returns the list of blocked users: contacts.getBlocked</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.getStatuses.html" name="contacts.getStatuses">Returns the list of contact statuses: contacts.getStatuses</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getMessages.html" name="messages.getMessages">Returns the list of messages by their IDs: messages.getMessages</a>
@ -424,6 +465,8 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.saveDraft.html" name="messages.saveDraft">Save a message draft associated to a chat: messages.saveDraft</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.saveTheme.html" name="account.saveTheme">Save a theme: account.saveTheme</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getAllDrafts.html" name="messages.getAllDrafts">Save get all message drafts: messages.getAllDrafts</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.saveBigFilePart.html" name="upload.saveBigFilePart">Saves a part of a large file (over 10Mb in size) to be later passed to one of the methods: upload.saveBigFilePart</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.saveFilePart.html" name="upload.saveFilePart">Saves a part of file for futher sending to one of the methods: upload.saveFilePart</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/help.saveAppLog.html" name="help.saveAppLog">Saves logs of application on the server: help.saveAppLog</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.searchGifs.html" name="messages.searchGifs">Search for GIFs: messages.searchGifs</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.searchGlobal.html" name="messages.searchGlobal">Search for messages and peers globally: messages.searchGlobal</a>
@ -436,6 +479,7 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.sendConfirmPhoneCode.html" name="account.sendConfirmPhoneCode">Send confirmation code to cancel account deletion, for more info click here »: account.sendConfirmPhoneCode</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.saveCallDebug.html" name="phone.saveCallDebug">Send phone call debug data to server: phone.saveCallDebug</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.sendScheduledMessages.html" name="messages.sendScheduledMessages">Send scheduled messages right away: messages.sendScheduledMessages</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.sendCode.html" name="auth.sendCode">Send the verification code for login: auth.sendCode</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.sendVerifyEmailCode.html" name="account.sendVerifyEmailCode">Send the verification email code for telegram passport: account.sendVerifyEmailCode</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.sendVerifyPhoneCode.html" name="account.sendVerifyPhoneCode">Send the verification phone code for telegram passport: account.sendVerifyPhoneCode</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.setEncryptedTyping.html" name="messages.setEncryptedTyping">Send typing event by the current user to a secret chat: messages.setEncryptedTyping</a>
@ -444,19 +488,28 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/bots.sendCustomRequest.html" name="bots.sendCustomRequest">Sends a custom request; for bots only: bots.sendCustomRequest</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.sendMessage.html" name="messages.sendMessage">Sends a message to a chat: messages.sendMessage</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.sendEncryptedFile.html" name="messages.sendEncryptedFile">Sends a message with a file attachment to a secret chat: messages.sendEncryptedFile</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.requestEncryption.html" name="messages.requestEncryption">Sends a request to start a secret chat to the user: messages.requestEncryption</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.sendEncryptedService.html" name="messages.sendEncryptedService">Sends a service message to a secret chat: messages.sendEncryptedService</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.sendEncrypted.html" name="messages.sendEncrypted">Sends a text message to a secret chat: messages.sendEncrypted</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.updatePasswordSettings.html" name="account.updatePasswordSettings">Set a new 2FA password: account.updatePasswordSettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.setAccountTTL.html" name="account.setAccountTTL">Set account self-destruction period: account.setAccountTTL</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/bots.setBotCommands.html" name="bots.setBotCommands">Set bot command list: bots.setBotCommands</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.setContentSettings.html" name="account.setContentSettings">Set sensitive content settings (for viewing or hiding NSFW content): account.setContentSettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/stickers.setStickerSetThumb.html" name="stickers.setStickerSetThumb">Set stickerset thumbnail: stickers.setStickerSetThumb</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.setBotCallbackAnswer.html" name="messages.setBotCallbackAnswer">Set the callback answer to a user button press (bots only): messages.setBotCallbackAnswer</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.hidePeerSettingsBar.html" name="messages.hidePeerSettingsBar">Should be called after the user hides the report spam/add as contact bar of a new chat, effectively prevents the user from executing the actions specified in the peer's settings: messages.hidePeerSettingsBar</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.signIn.html" name="auth.signIn">Signs in a user with a validated phone number: auth.signIn</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.startBot.html" name="messages.startBot">Start a conversation with a bot using a deep linking parameter: messages.startBot</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.requestCall.html" name="phone.requestCall">Start a telegram phone call: phone.requestCall</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.validateRequestedInfo.html" name="payments.validateRequestedInfo">Submit requested order information for validation: payments.validateRequestedInfo</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.resetAuthorizations.html" name="auth.resetAuthorizations">Terminates all user's authorized sessions except for the current one: auth.resetAuthorizations</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.setContactSignUpNotification.html" name="account.setContactSignUpNotification">Toggle contact sign up notifications: account.setContactSignUpNotification</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.toggleSlowMode.html" name="channels.toggleSlowMode">Toggle supergroup slow mode: if enabled, users will only be able to send one message every seconds seconds: channels.toggleSlowMode</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.editCreator.html" name="channels.editCreator">Transfer channel ownership: channels.editCreator</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.checkPassword.html" name="auth.checkPassword">Try logging to an account protected by a 2FA password: auth.checkPassword</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.migrateChat.html" name="messages.migrateChat">Turn a legacy group into a supergroup: messages.migrateChat</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.uninstallStickerSet.html" name="messages.uninstallStickerSet">Uninstall a stickerset: messages.uninstallStickerSet</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.updateDialogFilter.html" name="messages.updateDialogFilter">Update folder: messages.updateDialogFilter</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.updateTheme.html" name="account.updateTheme">Update theme: account.updateTheme</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/photos.uploadProfilePhoto.html" name="photos.uploadProfilePhoto">Updates current user profile photo: photos.uploadProfilePhoto</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.updateStatus.html" name="account.updateStatus">Updates online user status: account.updateStatus</a>
@ -475,40 +528,7 @@ You can find examples for nearly every MadelineProto function in
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.sendVote.html" name="messages.sendVote">Vote in a poll: messages.sendVote</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.updateDeviceLocked.html" name="account.updateDeviceLocked">When client-side passcode lock feature is enabled, will not show message texts in incoming PUSH notifications: account.updateDeviceLocked</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getContactSignUpNotification.html" name="account.getContactSignUpNotification">Whether the user will receive notifications when contacts sign up: account.getContactSignUpNotification</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.bindTempAuthKey.html" name="auth.bindTempAuthKey">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</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getDhConfig.html" name="messages.getDhConfig">You cannot use this method directly, instead use $MadelineProto->getDhConfig();: messages.getDhConfig</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.acceptEncryption.html" name="messages.acceptEncryption">You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling secret chats: messages.acceptEncryption</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.discardEncryption.html" name="messages.discardEncryption">You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling secret chats: messages.discardEncryption</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.requestEncryption.html" name="messages.requestEncryption">You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling secret chats: messages.requestEncryption</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/updates.getChannelDifference.html" name="updates.getChannelDifference">You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling updates: updates.getChannelDifference</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/updates.getDifference.html" name="updates.getDifference">You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling updates: updates.getDifference</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/updates.getState.html" name="updates.getState">You cannot use this method directly, see https://docs.madelineproto.xyz for more info on handling updates: updates.getState</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.acceptCall.html" name="phone.acceptCall">You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.acceptCall</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.confirmCall.html" name="phone.confirmCall">You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.confirmCall</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.discardCall.html" name="phone.discardCall">You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.discardCall</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.requestCall.html" name="phone.requestCall">You cannot use this method directly, see https://docs.madelineproto.xyz#calls for more info on handling calls: phone.requestCall</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.exportAuthorization.html" name="auth.exportAuthorization">You cannot use this method directly, use $MadelineProto->exportAuthorization() instead, see https://docs.madelineproto.xyz/docs/LOGIN.html: auth.exportAuthorization</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.importAuthorization.html" name="auth.importAuthorization">You cannot use this method directly, use $MadelineProto->importAuthorization($authorization) instead, see https://docs.madelineproto.xyz/docs/LOGIN.html: auth.importAuthorization</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.importBotAuthorization.html" name="auth.importBotAuthorization">You cannot use this method directly, use the botLogin method instead (see https://docs.madelineproto.xyz for more info): auth.importBotAuthorization</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.checkPassword.html" name="auth.checkPassword">You cannot use this method directly, use the complete2falogin method instead (see https://docs.madelineproto.xyz for more info): auth.checkPassword</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.signIn.html" name="auth.signIn">You cannot use this method directly, use the completePhoneLogin method instead (see https://docs.madelineproto.xyz for more info): auth.signIn</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.signUp.html" name="auth.signUp">You cannot use this method directly, use the completeSignup method instead (see https://docs.madelineproto.xyz for more info): auth.signUp</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/channels.getFullChannel.html" name="channels.getFullChannel">You cannot use this method directly, use the getPwrChat, getInfo, getFullInfo methods instead (see https://docs.madelineproto.xyz for more info): channels.getFullChannel</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getFullChat.html" name="messages.getFullChat">You cannot use this method directly, use the getPwrChat, getInfo, getFullInfo methods instead (see https://docs.madelineproto.xyz for more info): messages.getFullChat</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/users.getFullUser.html" name="users.getFullUser">You cannot use this method directly, use the getPwrChat, getInfo, getFullInfo methods instead (see https://docs.madelineproto.xyz for more info): users.getFullUser</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.logOut.html" name="auth.logOut">You cannot use this method directly, use the logout method instead (see https://docs.madelineproto.xyz for more info): auth.logOut</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/auth.sendCode.html" name="auth.sendCode">You cannot use this method directly, use the phoneLogin method instead (see https://docs.madelineproto.xyz for more info): auth.sendCode</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/contacts.resolveUsername.html" name="contacts.resolveUsername">You cannot use this method directly, use the resolveUsername, getPwrChat, getInfo, getFullInfo methods instead (see https://docs.madelineproto.xyz for more info): contacts.resolveUsername</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.getCdnFile.html" name="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.getCdnFile</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.getCdnFileHashes.html" name="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.getCdnFileHashes</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.getFile.html" name="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.getFile</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.getFileHashes.html" name="upload.getFileHashes">You cannot use this method directly, use the upload, downloadToStream, downloadToFile, downloadToDir methods instead; see https://docs.madelineproto.xyz for more info: upload.getFileHashes</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.reuploadCdnFile.html" name="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.reuploadCdnFile</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.saveBigFilePart.html" name="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.saveBigFilePart</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/upload.saveFilePart.html" name="upload.saveFilePart">You cannot use this method directly, use the upload, downloadToStream, downloadToFile, downloadToDir methods instead; see https://docs.madelineproto.xyz for more info: upload.saveFilePart</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.receivedQueue.html" name="messages.receivedQueue">You cannot use this method directly: messages.receivedQueue</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.getPasswordSettings.html" name="account.getPasswordSettings">You cannot use this method directly; use $MadelineProto->update2fa($params), instead (see https://docs.madelineproto.xyz for more info): account.getPasswordSettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/account.updatePasswordSettings.html" name="account.updatePasswordSettings">You cannot use this method directly; use $MadelineProto->update2fa($params), instead (see https://docs.madelineproto.xyz for more info): account.updatePasswordSettings</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/phone.confirmCall.html" name="phone.confirmCall">Complete phone call E2E encryption key exchange »: phone.confirmCall</a>
* [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)

View File

@ -74,7 +74,12 @@
"autoload-dev": {
"psr-4": {
"danog\\MadelineProto\\Test\\": "tests/danog/"
}
},
"files": [
"tools/build_docs/schemas.php",
"tools/build_docs/merge.php",
"tools/build_docs/layerUpgrade.php"
]
},
"repositories": [{
"type": "git",

2
docs

@ -1 +1 @@
Subproject commit f49ae1bcb6ade347ed852d7c588c740d595b09aa
Subproject commit 83cd0b565ea0bf2f73747cb6a41f2ce3cc99280e

View File

@ -21,9 +21,7 @@
use danog\MadelineProto\API;
use danog\MadelineProto\EventHandler;
use danog\MadelineProto\Exception;
use danog\MadelineProto\Logger;
use danog\MadelineProto\RPCErrorException;
/*
* Various ways to load MadelineProto

View File

@ -20,8 +20,8 @@
*/
if (function_exists('memprof_enable')) {
memprof_enable();
if (\function_exists('memprof_enable')) {
\memprof_enable();
}
use Amp\Http\Server\HttpServer;
@ -136,10 +136,10 @@ class MyEventHandler extends \danog\MadelineProto\EventHandler
return $this->messages->sendMessage(['peer' => $peerId, 'message' => self::START, 'parse_mode' => 'Markdown', 'reply_to_msg_id' => $messageId]);
}
if ($update['message']['message'] === '/report' && $peerId === $this->adminId) {
memprof_dump_callgrind($stm = fopen("php://memory", "w"));
fseek($stm, 0);
\memprof_dump_callgrind($stm = \fopen("php://memory", "w"));
\fseek($stm, 0);
yield $this->messages->sendMedia(['peer' => $peerId, 'media' => ['_' => 'inputMediaUploadedDocument', 'file' => $stm, 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'callgrind.out']]]]);
fclose($stm);
\fclose($stm);
return;
}
if (isset($update['message']['media']['_']) && $update['message']['media']['_'] !== 'messageMediaWebPage') {

@ -1 +1 @@
Subproject commit 3027150b5e9a5bb88acbfe97e7c5b0b7748c7bcf
Subproject commit ef59cc0cb6723ebd600643faa50205065e8ee578

View File

@ -223,7 +223,7 @@ abstract class AbstractAPIFactory extends AsyncConstruct
if (\strpos($method, '_') !== false) {
$finalMethods[\strtolower(\str_replace('_', '', $method))] = $actual_method;
} else {
$finalMethods[\strtolower(Tools::toSnakeCase($method))] = $actual_method;
$finalMethods[\strtolower(StrTools::toSnakeCase($method))] = $actual_method;
}
}

View File

@ -105,7 +105,7 @@ class AnnotationsBuilder
if (!\in_array($namespace, $this->TL->getMethodNamespaces())) {
continue;
}
$internalDoc[$namespace][$method]['title'] = \str_replace(['](../', '.md'], ['](https://docs.madelineproto.xyz/API_docs/', '.html'], Lang::$current_lang["method_{$data['method']}"] ?? '');
$internalDoc[$namespace][$method]['title'] = \str_replace(['](../', '.md'], ['](https://docs.madelineproto.xyz/API_docs/', '.html'], Lang::$lang['en']["method_{$data['method']}"] ?? '');
$type = \str_ireplace(['vector<', '>'], [' of ', '[]'], $data['type']);
foreach ($data['params'] as $param) {
if (\in_array($param['name'], ['flags', 'random_id', 'random_bytes'])) {
@ -135,7 +135,7 @@ class AnnotationsBuilder
}
$ptype = $stype === 'type' ? $ptype : "[{$ptype}]";
$opt = $param['pow'] ?? false ? 'Optional: ' : '';
$internalDoc[$namespace][$method]['attr'][$param['name']] = ['type' => $ptype, 'description' => \str_replace(['](../', '.md'], ['](https://docs.madelineproto.xyz/API_docs/', '.html'], $opt.(Lang::$current_lang["method_{$data['method']}_param_{$param['name']}_type_{$param['type']}"] ?? ''))];
$internalDoc[$namespace][$method]['attr'][$param['name']] = ['type' => $ptype, 'description' => \str_replace(['](../', '.md'], ['](https://docs.madelineproto.xyz/API_docs/', '.html'], $opt.(Lang::$lang['en']["method_{$data['method']}_param_{$param['name']}_type_{$param['type']}"] ?? ''))];
}
if ($type === 'Bool') {
$type = \strtolower($type);
@ -193,7 +193,7 @@ class AnnotationsBuilder
$name = \str_ireplace('async', '', $name);
}
}
$name = Tools::toCamelCase($name);
$name = StrTools::toCamelCase($name);
$name = \str_ireplace(['mtproto', 'api'], ['MTProto', 'API'], $name);
$doc = 'public function ';
$doc .= $name;

View File

@ -15,7 +15,7 @@ trait ArrayCacheTrait
* 'ttl' => int
* ],
* ...
* ]
* ].
* @var array
*/
protected array $cache = [];
@ -29,14 +29,14 @@ trait ArrayCacheTrait
if (\is_array($cacheItem)) {
$result = $cacheItem['value'];
$this->cache[$key]['ttl'] = strtotime($this->ttl);
$this->cache[$key]['ttl'] = \strtotime($this->ttl);
}
return $result;
}
/**
* Save item in cache
* Save item in cache.
*
* @param string $key
* @param $value
@ -45,12 +45,12 @@ trait ArrayCacheTrait
{
$this->cache[$key] = [
'value' => $value,
'ttl' => strtotime($this->ttl),
'ttl' => \strtotime($this->ttl),
];
}
/**
* Remove key from cache
* Remove key from cache.
*
* @param string $key
*/
@ -61,15 +61,15 @@ trait ArrayCacheTrait
protected function startCacheCleanupLoop(): void
{
Loop::repeat(strtotime($this->ttlCheckInterval, 0) * 1000, fn() => $this->cleanupCache());
Loop::repeat(\strtotime($this->ttlCheckInterval, 0) * 1000, fn () => $this->cleanupCache());
}
/**
* Remove all keys from cache
* Remove all keys from cache.
*/
protected function cleanupCache(): void
{
$now = time();
$now = \time();
$oldKeys = [];
foreach ($this->cache as $cacheKey => $cacheValue) {
if ($cacheValue['ttl'] < $now) {
@ -81,12 +81,13 @@ trait ArrayCacheTrait
}
Logger::log(
sprintf(
\sprintf(
"cache for table:%s; keys left: %s; keys removed: %s",
$this->table, \count($this->cache), \count($oldKeys)
$this->table,
\count($this->cache),
\count($oldKeys)
),
Logger::VERBOSE
);
}
}
}

View File

@ -25,4 +25,4 @@ interface DbArray extends DbType, \ArrayAccess, \Countable
* @return bool
*/
public function offsetExists($offset);
}
}

View File

@ -23,7 +23,7 @@ class DbPropertiesFabric
{
$class = __NAMESPACE__;
switch (strtolower($dbSettings['type'])) {
switch (\strtolower($dbSettings['type'])) {
case 'memory':
$class .= '\Memory';
break;
@ -36,7 +36,7 @@ class DbPropertiesFabric
}
/** @var DbType $class */
switch (strtolower($propertyType)){
switch (\strtolower($propertyType)) {
case 'array':
$class .= 'Array';
break;
@ -46,5 +46,4 @@ class DbPropertiesFabric
return $class::getInstance($name, $value, $namePrefix, $dbSettings[$dbSettings['type']]??[]);
}
}
}

View File

@ -7,7 +7,6 @@ use danog\MadelineProto\MTProto;
trait DbPropertiesTrait
{
public function initDb(MTProto $MadelineProto, bool $reset = false): \Generator
{
if (empty($this->dbProperies)) {
@ -42,11 +41,11 @@ trait DbPropertiesTrait
$result = $madelineProto->getSelf()['id'] ?? null;
if (!$result) {
$result = 'tmp_';
$result .= str_replace('0','', spl_object_hash($madelineProto));
$result .= \str_replace('0', '', \spl_object_hash($madelineProto));
}
$className = explode('\\',__CLASS__);
$result .= '_' . end($className);
$className = \explode('\\', __CLASS__);
$result .= '_' . \end($className);
return $result;
}
}
}

View File

@ -14,5 +14,5 @@ interface DbType
*
* @return Promise<self>
*/
static function getInstance(string $name, $value = null, string $tablePrefix = '', array $settings = []): Promise;
}
public static function getInstance(string $name, $value = null, string $tablePrefix = '', array $settings = []): Promise;
}

View File

@ -16,7 +16,7 @@ class MemoryArray extends \ArrayIterator implements DbArray
public static function getInstance(string $name, $value = null, string $tablePrefix = '', array $settings = []): Promise
{
return call(static function() use ($value) {
return call(static function () use ($value) {
if ($value instanceof MemoryArray) {
return $value;
}
@ -35,27 +35,27 @@ class MemoryArray extends \ArrayIterator implements DbArray
public function isset($key): Promise
{
return call(fn() => parent::offsetExists($key));
return call(fn () => parent::offsetExists($key));
}
public function offsetGet($offset): Promise
{
return call(fn() => parent::offsetExists($offset) ? parent::offsetGet($offset) : null);
return call(fn () => parent::offsetExists($offset) ? parent::offsetGet($offset) : null);
}
public function offsetUnset($offset): Promise
{
return call(fn() => parent::offsetUnset($offset));
return call(fn () => parent::offsetUnset($offset));
}
public function count(): Promise
{
return call(fn() => parent::count());
return call(fn () => parent::count());
}
public function getArrayCopy(): Promise
{
return call(fn() => parent::getArrayCopy());
return call(fn () => parent::getArrayCopy());
}
public function getIterator(): Producer
@ -66,4 +66,4 @@ class MemoryArray extends \ArrayIterator implements DbArray
}
});
}
}
}

View File

@ -38,8 +38,7 @@ class Mysql
string $db = 'MadelineProto',
int $maxConnections = ConnectionPool::DEFAULT_MAX_CONNECTIONS,
int $idleTimeout = ConnectionPool::DEFAULT_IDLE_TIMEOUT
): Pool
{
): Pool {
$dbKey = "$host:$port:$db";
if (empty(static::$connections[$dbKey])) {
$config = ConnectionConfig::fromString(
@ -62,7 +61,7 @@ class Mysql
*/
private static function createDb(ConnectionConfig $config)
{
wait(call(static function() use($config) {
wait(call(static function () use ($config) {
try {
$db = $config->getDatabase();
$connection = pool($config->withDatabase(null));
@ -76,7 +75,5 @@ class Mysql
Logger::log($e->getMessage(), Logger::ERROR);
}
}));
}
}
}

View File

@ -35,17 +35,16 @@ class MysqlArray implements DbArray
} catch (\Throwable $e) {
Logger::log($e->getMessage(), Logger::ERROR);
}
}
/**
* @param string $name
* @param DbArray|array|null $value
* @param string $tablePrefix
* @param array $settings
*
* @return Promise
*/
/**
* @param string $name
* @param DbArray|array|null $value
* @param string $tablePrefix
* @param array $settings
*
* @return Promise
*/
public static function getInstance(string $name, $value = null, string $tablePrefix = '', array $settings = []): Promise
{
$tableName = "{$tablePrefix}_{$name}";
@ -62,7 +61,7 @@ class MysqlArray implements DbArray
$instance->startCacheCleanupLoop();
return call(static function() use($instance, $value) {
return call(static function () use ($instance, $value) {
yield from $instance->prepareTable();
//Skip migrations if its same object
@ -75,18 +74,18 @@ class MysqlArray implements DbArray
});
}
/**
* @param MysqlArray $instance
* @param DbArray|array|null $value
*
* @return \Generator
*/
/**
* @param MysqlArray $instance
* @param DbArray|array|null $value
*
* @return \Generator
*/
private static function renameTmpTable(MysqlArray $instance, $value): \Generator
{
if ($value instanceof static && $value->table) {
if (
$value->table !== $instance->table &&
mb_strpos($instance->table, 'tmp') !== 0
\mb_strpos($instance->table, 'tmp') !== 0
) {
yield from $instance->renameTable($value->table, $instance->table);
} else {
@ -95,13 +94,13 @@ class MysqlArray implements DbArray
}
}
/**
* @param MysqlArray $instance
* @param DbArray|array|null $value
*
* @return \Generator
* @throws \Throwable
*/
/**
* @param MysqlArray $instance
* @param DbArray|array|null $value
*
* @return \Generator
* @throws \Throwable
*/
private static function migrateDataToDb(MysqlArray $instance, $value): \Generator
{
if (!empty($value) && !$value instanceof MysqlArray) {
@ -113,7 +112,7 @@ class MysqlArray implements DbArray
$value = (array) $value;
}
$counter = 0;
$total = count($value);
$total = \count($value);
foreach ($value as $key => $item) {
$counter++;
if ($counter % 500 === 0) {
@ -122,7 +121,6 @@ class MysqlArray implements DbArray
} else {
$instance->offsetSet($key, $item);
}
}
Logger::log('Converting database done.', Logger::ERROR);
}
@ -134,7 +132,7 @@ class MysqlArray implements DbArray
}
/**
* Check if key isset
* Check if key isset.
*
* @param $key
*
@ -142,13 +140,13 @@ class MysqlArray implements DbArray
*/
public function isset($key): Promise
{
return call(fn() => yield $this->offsetGet($key) !== null);
return call(fn () => yield $this->offsetGet($key) !== null);
}
public function offsetGet($offset): Promise
{
return call(function() use($offset) {
return call(function () use ($offset) {
if ($cached = $this->getCache($offset)) {
return $cached;
}
@ -167,7 +165,7 @@ class MysqlArray implements DbArray
}
/**
* Set value for an offset
* Set value for an offset.
*
* @link https://php.net/manual/en/arrayiterator.offsetset.php
*
@ -182,30 +180,31 @@ class MysqlArray implements DbArray
public function offsetSet($index, $value): Promise
{
if ($this->getCache($index) === $value) {
return call(fn()=>null);
return call(fn () =>null);
}
$this->setCache($index, $value);
$request = $this->request("
$request = $this->request(
"
INSERT INTO `{$this->table}`
SET `key` = :index, `value` = :value
ON DUPLICATE KEY UPDATE `value` = :value
",
[
'index' => $index,
'value' => serialize($value),
'value' => \serialize($value),
]
);
//Ensure that cache is synced with latest insert in case of concurrent requests.
$request->onResolve(fn() => $this->setCache($index, $value));
$request->onResolve(fn () => $this->setCache($index, $value));
return $request;
}
/**
* Unset value for an offset
* Unset value for an offset.
*
* @link https://php.net/manual/en/arrayiterator.offsetunset.php
*
@ -220,7 +219,8 @@ class MysqlArray implements DbArray
{
$this->unsetCache($index);
return $this->request("
return $this->request(
"
DELETE FROM `{$this->table}`
WHERE `key` = :index
",
@ -229,14 +229,14 @@ class MysqlArray implements DbArray
}
/**
* Get array copy
* Get array copy.
*
* @return Promise<array>
* @throws \Throwable
*/
public function getArrayCopy(): Promise
{
return call(function(){
return call(function () {
$iterator = $this->getIterator();
$result = [];
while (yield $iterator->advance()) {
@ -260,7 +260,7 @@ class MysqlArray implements DbArray
}
/**
* Count elements
* Count elements.
*
* @link https://php.net/manual/en/arrayiterator.count.php
* @return Promise<int> The number of elements or public properties in the associated
@ -269,7 +269,7 @@ class MysqlArray implements DbArray
*/
public function count(): Promise
{
return call(function(){
return call(function () {
$row = yield $this->request("SELECT count(`key`) as `count` FROM `{$this->table}`");
return $row[0]['count'] ?? 0;
});
@ -279,9 +279,9 @@ class MysqlArray implements DbArray
{
if ($row) {
if (!empty($row[0]['value'])) {
$row = reset($row);
$row = \reset($row);
}
return unserialize($row['value']);
return \unserialize($row['value']);
}
return null;
}
@ -300,7 +300,7 @@ class MysqlArray implements DbArray
}
/**
* Create table for property
* Create table for property.
*
* @return array|null
* @throws \Throwable
@ -335,7 +335,7 @@ class MysqlArray implements DbArray
}
/**
* Perform async request to db
* Perform async request to db.
*
* @param string $query
* @param array $params
@ -345,8 +345,7 @@ class MysqlArray implements DbArray
*/
private function request(string $query, array $params = []): Promise
{
return call(function() use($query, $params) {
return call(function () use ($query, $params) {
Logger::log([$query, $params], Logger::VERBOSE);
if (empty($this->db) || !$this->db->isAlive()) {
@ -370,4 +369,4 @@ class MysqlArray implements DbArray
return $result;
});
}
}
}

View File

@ -24,6 +24,17 @@ use danog\MadelineProto\TL\TL;
// This code was written a few years ago: it is garbage, and has to be rewritten
class DocsBuilder
{
const DEFAULT_TEMPLATES = [
'User' => ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputDialogPeer', 'DialogPeer', 'InputPeer', 'NotifyPeer', 'InputNotifyPeer'],
'InputFile' => ['InputFile', 'InputEncryptedFile'],
'InputEncryptedChat' => ['InputEncryptedChat'],
'PhoneCall' => ['PhoneCall'],
'InputPhoto' => ['InputPhoto'],
'InputDocument' => ['InputDocument'],
'InputMedia' => ['InputMedia'],
'InputMessage' => ['InputMessage'],
'KeyboardButton' => ['KeyboardButton'],
];
use \danog\MadelineProto\DocsBuilder\Methods;
use \danog\MadelineProto\DocsBuilder\Constructors;
public $td = false;
@ -47,28 +58,26 @@ class DocsBuilder
}
\chdir($this->settings['output_dir']);
$this->index = $settings['readme'] ? 'README.md' : 'index.md';
foreach (\glob($this->settings['template']."/*") as $template) {
$this->templates[\basename($template, '.md')] = \file_get_contents($template);
}
}
/**
* Documentation templates.
*
* @var array
*/
protected $templates = [];
public $types = [];
public $any = '*';
public function mkDocs()
{
\danog\MadelineProto\Logger::log('Generating documentation index...', \danog\MadelineProto\Logger::NOTICE);
\file_put_contents($this->index, '---
title: '.$this->settings['title'].'
description: '.$this->settings['description'].'
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
# '.$this->settings['description'].'
\file_put_contents($this->index, $this->template('index', $this->settings['title'], $this->settings['description']));
[Back to main documentation](..)
[Methods](methods/)
[Constructors](constructors/)
[Types](types/)');
$this->mkmethodS();
$this->mkMethods();
$this->mkConstructors();
foreach (\glob('types/*') as $unlink) {
\unlink($unlink);
@ -80,548 +89,75 @@ image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
\ksort($this->types);
$index = '';
\danog\MadelineProto\Logger::log('Generating types documentation...', \danog\MadelineProto\Logger::NOTICE);
$last_namespace = '';
foreach ($this->types as $otype => $keys) {
$new_namespace = \preg_replace('/_.*/', '', $otype);
//$br = $new_namespace != $last_namespace ? '***<br><br>' : '';
$type = \str_replace(['<', '>'], ['_of_', ''], $otype);
$type = \preg_replace('/.*_of_/', '', $type);
$index .= '['.\str_replace('_', '\\_', $type).']('.$type.'.md)<a name="'.$type.'"></a>
$type = StrTools::typeEscape($otype);
$index .= '['.StrTools::markdownEscape($type).']('.$type.'.md)<a name="'.$type.'"></a>
';
$constructors = '';
foreach ($keys['constructors'] as $data) {
$predicate = $data['predicate'].(isset($data['layer']) && $data['layer'] !== '' ? '_'.$data['layer'] : '');
$md_predicate = \str_replace('_', '\\_', $predicate);
$constructors .= '['.$md_predicate.'](../constructors/'.$predicate.'.md)
';
$md_predicate = StrTools::markdownEscape($predicate);
$constructors .= "[$md_predicate](../constructors/$predicate.md) \n\n";
}
$methods = '';
foreach ($keys['methods'] as $data) {
$name = $data['method'];
$md_name = \str_replace(['.', '_'], ['->', '\\_'], $name);
$methods .= '[$MadelineProto->'.$md_name.'](../methods/'.$name.'.md)
';
$methods .= "[\$MadelineProto->$md_name](../methods/$name.md) \n\n";
}
$description = isset($this->td_descriptions['types'][$otype]) ? $this->td_descriptions['types'][$otype] : 'constructors and methods of type '.$type;
$symFile = \str_replace('.', '_', $type);
$redir = $symFile !== $type ? "\nredirect_from: /API_docs/types/{$symFile}.html" : '';
$header = '---
title: '.$type.'
description: constructors and methods of type '.$type.'
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png'.$redir.'
---
# Type: '.\str_replace('_', '\\_', $type).'
[Back to types index](index.md)
';
$header .= isset($this->td_descriptions['types'][$otype]) ? $this->td_descriptions['types'][$otype].PHP_EOL.PHP_EOL : '';
$header = '';
if (!isset($this->settings['td'])) {
if (\in_array($type, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputDialogPeer', 'DialogPeer', 'InputPeer', 'NotifyPeer', 'InputNotifyPeer'])) {
$header .= 'You can directly provide the [Update](Update.md) or [Message](Message.md) object here, MadelineProto will automatically extract the destination chat id.
The following syntaxes can also be used:
```
$'.$type." = '@username'; // Username\n\n\$".$type." = 'me'; // The currently logged-in user\n\n\$".$type.' = 44700; // bot API id (users)
$'.$type.' = -492772765; // bot API id (chats)
$'.$type.' = -10038575794; // bot API id (channels)
$'.$type." = 'https://t.me/danogentili'; // t.me URLs\n\$".$type." = 'https://t.me/joinchat/asfln1-21fa_'; // t.me invite links\n\n\$".$type." = 'user#44700'; // tg-cli style id (users)\n\$".$type." = 'chat#492772765'; // tg-cli style id (chats)\n\$".$type." = 'channel#38575794'; // tg-cli style id (channels)\n```\n\nA [Chat](Chat.md), a [User](User.md), an [InputPeer](InputPeer.md), an [InputDialogPeer](InputDialogPeer.md), an [InputNotifyPeer](InputNotifyPeer.md), an [InputUser](InputUser.md), an [InputChannel](InputChannel.md), a [Peer](Peer.md), an [DialogPeer](DialogPeer.md), [NotifyPeer](NotifyPeer.md), or a [Chat](Chat.md) object can also be used.\n\n\n";
}
if (\in_array($type, ['InputEncryptedChat'])) {
$header .= 'You can directly provide the [Update](Update.md) or [EncryptedMessage](EncryptedMessage.md) object here, MadelineProto will automatically extract the destination chat id.
The following syntax can also be used:
```
$'.$type.' = -147286699; // Numeric chat id returned by requestSecretChat, can be positive or negative
```
';
}
if (\in_array($type, ['InputFile', 'InputEncryptedFile'])) {
$header .= 'The following syntax can also be used:
```
$'.$type.' = \'filename.mp4\'; // The file path can also be used
```
';
}
if (\in_array($type, ['InputPhoto'])) {
$header .= 'You can also provide a [MessageMedia](MessageMedia.md), [Message](Message.md), [Update](Update.md), [Photo](Photo.md) here, MadelineProto will automatically convert it to the right type.
';
}
if (\in_array($type, ['InputDocument'])) {
$header .= 'You can also provide a [MessageMedia](MessageMedia.md), [Message](Message.md), [Update](Update.md), [Document](Document.md) here, MadelineProto will automatically convert it to the right type.
';
}
if (\in_array($type, ['InputMedia'])) {
$header .= 'You can also provide a [MessageMedia](MessageMedia.md), [Message](Message.md), [Update](Update.md), [Document](Document.md), [Photo](Photo.md), [InputDocument](InputDocument.md), [InputPhoto](InputPhoto.md) here, MadelineProto will automatically convert it to the right type.
';
}
if (\in_array($type, ['InputMessage'])) {
$header .= 'The following syntax can also be used:
```
$'.$type.' = 142; // Numeric message ID
```
';
}
if (\in_array($type, ['KeyboardButton'])) {
$header .= 'Clicking these buttons:
To click these buttons simply run the `click` method:
```
$result = $'.$type.'->click();
```
`$result` can be one of the following:
* A string - If the button is a keyboardButtonUrl
* [Updates](Updates.md) - If the button is a keyboardButton, the message will be sent to the chat, in reply to the message with the keyboard
* [messages.BotCallbackAnswer](messages.BotCallbackAnswer.md) - If the button is a keyboardButtonCallback or a keyboardButtonGame the button will be pressed and the result will be returned
* `false` - If the button is an unsupported button, like keyboardButtonRequestPhone, keyboardButtonRequestGeoLocation, keyboardButtonSwitchInlinekeyboardButtonBuy; you will have to parse data from these buttons manually
You can also access the properties of the constructor as a normal array, for example $button[\'name\']
';
foreach (self::DEFAULT_TEMPLATES as $template => $types) {
if (\in_array($type, $types)) {
$header .= $this->template($template, $type);
}
}
}
$constructors = '### Possible values (constructors):
'.$constructors.'
';
$methods = '### Methods that return an object of this type (methods):
'.$methods.'
';
if (!isset($this->settings['td'])) {
if (\in_array($type, ['PhoneCall'])) {
$methods = '';
$constructors = '';
$header .= 'This is an object of type `\\danog\\MadelineProto\\VoIP`.
It will only be available if the [php-libtgvoip](https://github.com/danog/php-libtgvoip) extension is installed, see [the main docs](https://docs.madelineproto.xyz#calls) for an easy installation script.
You MUST know [OOP](http://php.net/manual/en/language.oop5.php) to use this class.
## Constants:
VoIPController states (these constants are incrementing integers, thus can be compared like numbers):
* `STATE_CREATED` - controller created
* `STATE_WAIT_INIT` - controller inited
* `STATE_WAIT_INIT_ACK` - controller inited
* `STATE_ESTABLISHED` - connection established
* `STATE_FAILED` - connection failed
* `STATE_RECONNECTING` - reconnecting
VoIPController errors:
* `TGVOIP_ERROR_UNKNOWN` - An unknown error occurred
* `TGVOIP_ERROR_INCOMPATIBLE` - The other side is using an unsupported client/protocol
* `TGVOIP_ERROR_TIMEOUT` - A timeout occurred
* `TGVOIP_ERROR_AUDIO_IO` - An I/O error occurred
Network types (these constants are incrementing integers, thus can be compared like numbers):
* `NET_TYPE_UNKNOWN` - Unknown network type
* `NET_TYPE_GPRS` - GPRS connection
* `NET_TYPE_EDGE` - EDGE connection
* `NET_TYPE_3G` - 3G connection
* `NET_TYPE_HSPA` - HSPA connection
* `NET_TYPE_LTE` - LTE connection
* `NET_TYPE_WIFI` - WIFI connection
* `NET_TYPE_ETHERNET` - Ethernet connection (this guarantees high audio quality)
* `NET_TYPE_OTHER_HIGH_SPEED` - Other high speed connection
* `NET_TYPE_OTHER_LOW_SPEED` - Other low speed connection
* `NET_TYPE_DIALUP` - Dialup connection
* `NET_TYPE_OTHER_MOBILE` - Other mobile network connection
Data saving modes (these constants are incrementing integers, thus can be compared like numbers):
* `DATA_SAVING_NEVER` - Never save data (this guarantees high audio quality)
* `DATA_SAVING_MOBILE` - Use mobile data saving profiles
* `DATA_SAVING_ALWAYS` - Always use data saving profiles
Proxy settings (these constants are incrementing integers, thus can be compared like numbers):
* `PROXY_NONE` - No proxy
* `PROXY_SOCKS5` - Use the socks5 protocol
Audio states (these constants are incrementing integers, thus can be compared like numbers):
* `AUDIO_STATE_NONE` - The audio module was not created yet
* `AUDIO_STATE_CREATED` - The audio module was created
* `AUDIO_STATE_CONFIGURED` - The audio module was configured
* `AUDIO_STATE_RUNNING` - The audio module is running
Call states (these constants are incrementing integers, thus can be compared like numbers):
* `CALL_STATE_NONE` - The call was not created yet
* `CALL_STATE_REQUESTED` - This is an outgoing call
* `CALL_STATE_INCOMING` - This is an incoming call
* `CALL_STATE_ACCEPTED` - The incoming call was accepted, but not yet ready
* `CALL_STATE_CONFIRMED` - The outgoing call was accepted, but not yet ready
* `CALL_STATE_READY` - The call is ready. Audio data is being sent and received
* `CALL_STATE_ENDED` - The call is over.
## Methods:
* `getState()` - Gets the controller state, as a VoIPController state constant
* `getCallState()` - Gets the call state, as a call state constant
* `getVisualization()` - Gets the visualization of the encryption key, as an array of emojis, can be called only when the call state is bigger than or equal to `CALL_STATE_READY`. If called sooner, returns false.
* `getStats()` Gets connection stats
* `getOtherID()` - Gets the id of the other call participant, as a bot API ID
* `getProtocol()` - Gets the protocol used by the current call, as a [PhoneCallProtocol](https://docs.madelineproto.xyz/API_docs/types/PhoneCallProtocol.html) object
* `getCallID()` - Gets the call ID, as an [InputPhoneCall](https://docs.madelineproto.xyz/API_docs/types/InputPhoneCall.html) object
* `isCreator()` - Returns a boolean that indicates whether you are the creator of the call
* `whenCreated()` - Returns the unix timestamp of when the call was started (when was the call state set to `CALL_STATE_READY`)
* `getOutputState()` - Returns the state of the audio output module, as an audio state constant
* `getInputState()` - Returns the state of the audio input module, as an audio state constant
* `getDebugLog()` - Gets VoIPController debug log
* `getDebugString()` - Gets VoIPController debug string
* `getLastError()` - Gets the last error as a VoIPController error constant
* `getVersion()` - Gets VoIPController version
* `getSignalBarsCount()` - Gets number of signal bars (0-4)
* `parseConfig()` - Parses the configuration
* `accept()` - Accepts the phone call, returns `$this`
* `discard($reason = ["_" => "phoneCallDiscardReasonDisconnect"], $rating = [])` - Ends the phone call.
Accepts two optional parameters:
`$reason` - can be a [PhoneCallDiscardReason](https://docs.madelineproto.xyz/API_docs/types/PhoneCallDiscardReason.html) object (defaults to a [phoneCallDiscardReasonDisconnect](https://docs.madelineproto.xyz/API_docs/constructors/phoneCallDiscardReasonDisconnect.html) object).
`$rating` - Can be an array that must contain a rating, and a comment (`["rating" => 5, "comment" => "MadelineProto is very easy to use!"]). Defaults to an empty array.`
* `getOutputParams()` - Returns the output audio configuration
MadelineProto works using raw signed PCM audio, internally split in packets with `sampleNumber` samples.
The audio configuration is an array structured in the following way:
```
[
"bitsPerSample" => int. // Bits in each PCM sample
"sampleRate" => int, // PCM sample rate
"channels" => int, // Number of PCM audio channels
"sampleNumber" => int, // The audio data is internally split in packets, each having this number of samples
"samplePeriod" => double, // PCM sample period in seconds, useful if you want to generate audio data manually
"writePeriod" => double, // PCM write period in seconds (samplePeriod*sampleNumber), useful if you want to generate audio data manually
"samplesSize" => int, // The audio data is internally split in packets, each having this number of bytes (sampleNumber*bitsPerSample/8)
"level" => int // idk
];
```
* `getInputParams()` - Returns the input audio configuration
MadelineProto works using raw signed PCM audio, internally split in packets with `sampleNumber` samples.
The audio configuration is an array structured in the following way:
```
[
"bitsPerSample" => int. // Bits in each PCM sample
"sampleRate" => int, // PCM sample rate
"channels" => int, // Number of PCM audio channels
"sampleNumber" => int, // The audio data is internally split in packets, each having this number of samples
"samplePeriod" => double, // PCM sample period in seconds, useful if you want to generate audio data manually
"writePeriod" => double, // PCM write period in seconds (samplePeriod*sampleNumber), useful if you want to generate audio data manually
"samplesSize" => int, // The audio data is internally split in packets, each having this number of bytes (sampleNumber*bitsPerSample/8)
];
```
* `play(string $file)` and `then(string $file)` - Play a certain audio file encoded in PCM, with the audio input configuration, returns `$this`
* `playOnHold(array $files)` - Array of audio files encoded in PCM, with the audio input configuration to loop on hold (when the files given with play/then have finished playing). If not called, no data will be played, returns `$this`
* `isPlaying()` - Returns true if MadelineProto is still playing the files given with play/then, false if the hold files (or nothing) is being played
* `setMicMute(bool $mute)` - Stops/resumes playing files/hold files, returns `$this`
* `setOutputFile(string $outputfile)` - Writes incoming audio data to file encoded in PCM, with the audio output configuration, returns `$this`
* `unsetOutputFile()` - Stops writing audio data to previously set file, returns `$this`
## Properties:
* `storage`: An array that can be used to store data related to this call.
Easy as pie:
```
$call->storage["pony"] = "fluttershy";
\\danog\\MadelineProto\\Logger::log($call->storage["pony"]); // fluttershy
```
Note: when modifying this property, *never* overwrite the previous values. Always either modify the values of the array separately like showed above, or use array_merge.
* `configuration`: An array containing the libtgvoip configuration.
You can only modify the data saving mode, the network type, the logging file path and the stats dump file path:
Example:
```
$call->configuration["log_file_path"] = "logs".$call->getOtherID().".log"; // Default is /dev/null
$call->configuration["stats_dump_file_path"] = "stats".$call->getOtherID().".log"; // Default is /dev/null
$call->configuration["network_type"] = \\danog\\MadelineProto\\VoIP::NET_TYPE_WIFI; // Default is NET_TYPE_ETHERNET
$call->configuration["data_saving"] = \\danog\\MadelineProto\\VoIP::DATA_SAVING_MOBILE; // Default is DATA_SAVING_NEVER
$call->parseConfig(); // Always call this after changing settings
```
Note: when modifying this property, *never* overwrite the previous values. Always either modify the values of the array separately like showed above, or use array_merge.
After modifying it, you must always parse the new configuration with a call to `parseConfig`.
';
}
}
if (\file_exists('types/'.$type.'.md')) {
\danog\MadelineProto\Logger::log($type);
if (isset($this->td_descriptions['types'][$otype])) {
$header = "{$this->td_descriptions['types'][$otype]}\n\n$header";
}
$header = \sprintf(
$this->templates['Type'],
$type,
$redir,
StrTools::markdownEscape($type),
$header,
$constructors,
$methods
);
\file_put_contents('types/'.$type.'.md', $header.$constructors.$methods);
$last_namespace = $new_namespace;
}
\danog\MadelineProto\Logger::log('Generating types index...', \danog\MadelineProto\Logger::NOTICE);
\file_put_contents('types/'.$this->index, '---
title: Types
description: List of types
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
# Types
[Back to API documentation index](..)
\file_put_contents('types/'.$this->index, $this->templates['types-index'].$index);
'.$index);
\danog\MadelineProto\Logger::log('Generating additional types...', \danog\MadelineProto\Logger::NOTICE);
\file_put_contents('types/string.md', '---
title: string
description: A UTF8 string of variable length
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: string
[Back to constructor index](index.md)
A UTF8 string of variable length. The total length in bytes of the string must not be bigger than 16777215.
');
\file_put_contents('types/bytes.md', '---
title: bytes
description: A string of variable length
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: bytes
[Back to constructor index](index.md)
```php
$bytes = "simple string of bytes";
```
Internally, an object of type `\\danog\\MadelineProto\\TL\\Types\\Bytes`.
When casted to string, turns into a string of bytes of variable length, with length smaller than or equal to 16777215.
When JSON-serialized, turns into an array of the following format:
```
[
\'_\' => \'bytes\',
\'bytes\' => base64_encode($contents)
];
```
');
\file_put_contents('types/int.md', '---
title: integer
description: A 32 bit signed integer ranging from -2147483648 to 2147483647
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: int
[Back to constructor index](index.md)
A 32 bit signed integer ranging from `-2147483648` to `2147483647`.
');
\file_put_contents('types/int53.md', '---
title: integer
description: A 53 bit signed integer
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: int53
[Back to constructor index](index.md)
A 53 bit signed integer.
');
\file_put_contents('types/long.md', '---
title: long
description: A 32 bit signed integer ranging from -9223372036854775808 to 9223372036854775807
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: long
[Back to constructor index](index.md)
A 64 bit signed integer ranging from `-9223372036854775808` to `9223372036854775807`.
');
\file_put_contents('types/int128.md', '---
title: int128
description: A 128 bit signed integer
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: int128
[Back to constructor index](index.md)
A 128 bit signed integer represented in little-endian base256 (`string`) format.
');
\file_put_contents('types/int256.md', '---
title: int256
description: A 256 bit signed integer
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: int256
[Back to constructor index](index.md)
A 256 bit signed integer represented in little-endian base256 (`string`) format.
');
\file_put_contents('types/int512.md', '---
title: int512
description: A 512 bit signed integer
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: int512
[Back to constructor index](index.md)
A 512 bit signed integer represented in little-endian base256 (`string`) format.
');
\file_put_contents('types/double.md', '---
title: double
description: A double precision floating point number
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: double
[Back to constructor index](index.md)
A double precision floating point number, single precision can also be used (float).
');
\file_put_contents('types/!X.md', '---
title: !X
description: Represents a TL serialized payload
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: !X
[Back to constructor index](index.md)
Represents a TL serialized payload.
');
\file_put_contents('types/X.md', '---
title: X
description: Represents a TL serialized payload
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: X
[Back to constructor index](index.md)
Represents a TL serialized payload.
');
\file_put_contents('constructors/boolFalse.md', '---
title: boolFalse
description: Represents a boolean with value equal to false
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
# boolFalse
[Back to constructor index](index.md)
Represents a boolean with value equal to `false`.
');
\file_put_contents('constructors/boolTrue.md', '---
title: boolTrue
description: Represents a boolean with value equal to true
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
# boolTrue
[Back to constructor index](index.md)
Represents a boolean with value equal to `true`.
');
\file_put_contents('constructors/null.md', '---
title: null
description: Represents a null value
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
# null
[Back to constructor index](index.md)
Represents a `null` value.
');
\file_put_contents('types/Bool.md', '---
title: Bool
description: Represents a boolean.
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
# Bool
[Back to types index](index.md)
Represents a boolean.
');
\file_put_contents('types/DataJSON.md', '---
title: DataJSON
description: Any json-encodable data
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
## Type: DataJSON
[Back to constructor index](index.md)
Any json-encodable data.
');
foreach (['string', 'bytes', 'int', 'int53', 'long', 'int128', 'int256', 'int512', 'double', 'Bool', 'DataJSON'] as $type) {
\file_put_contents("types/$type.md", $this->templates[$type]);
}
foreach (['boolFalse', 'boolTrue', 'null'] as $constructor) {
\file_put_contents("constructors/$constructor.md", $this->templates[$constructor]);
}
\danog\MadelineProto\Logger::log('Done!', \danog\MadelineProto\Logger::NOTICE);
}
public static $template = '<?php
/**
* Lang module
*
* This file is part of MadelineProto.
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU General Public License along with MadelineProto.
* If not, see <http://www.gnu.org/licenses/>.
*
* @author Daniil Gentili <daniil@daniil.it>
* @copyright 2016-2020 Daniil Gentili <daniil@daniil.it>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/
namespace danog\\MadelineProto;
class Lang
{
public static $lang = %s;
// THIS WILL BE OVERWRITTEN BY $lang["en"]
public static $current_lang = %s;
}';
public static function addToLang(string $key, string $value = '', bool $force = false)
{
if (!isset(\danog\MadelineProto\Lang::$lang['en'][$key]) || $force) {
\danog\MadelineProto\Lang::$lang['en'][$key] = $value;
//\file_put_contents(__DIR__.'/Lang.php', \sprintf(self::$template, \var_export(\danog\MadelineProto\Lang::$lang, true), \var_export(\danog\MadelineProto\Lang::$lang['en'], true)));
}
}
/**
* Get formatted template string.
*
* @param string $name Template name
* @param string[] ...$params Params
*
* @return string
*/
protected function template(string $name, ...$params): string
{
return \sprintf($this->templates[$name], ...$params);
}
}

View File

@ -19,6 +19,7 @@
namespace danog\MadelineProto\DocsBuilder;
use danog\MadelineProto\StrTools;
use danog\MadelineProto\Tools;
trait Constructors
@ -41,15 +42,11 @@ trait Constructors
$data['layer'] = '';
}
$got[$id] = '';
/*
if (preg_match('/%/', $type)) {
$type = $this->TL->getConstructors($this->td)->findByType(str_replace('%', '', $type))['predicate'];
}*/
$layer = isset($data['layer']) && $data['layer'] !== '' ? '_'.$data['layer'] : '';
$type = \str_replace(['<', '>'], ['_of_', ''], $data['type']);
$php_type = \preg_replace('/.*_of_/', '', $type);
$constructor = \str_replace(['<', '>'], ['_of_', ''], $data['predicate']);
$php_constructor = \preg_replace('/.*_of_/', '', $constructor);
$type = $data['type'];
$constructor = $data['predicate'];
$php_type = Tools::typeEscape($type);
$php_constructor = Tools::typeEscape($constructor);
if (!isset($this->types[$php_type])) {
$this->types[$php_type] = ['constructors' => [], 'methods' => []];
}
@ -78,7 +75,7 @@ trait Constructors
$param[$type_or_subtype] = '['.Tools::markdownEscape($param[$type_or_subtype]).'](../'.$type_or_bare_type.'/'.$param[$type_or_subtype].'.md)';
$params .= (isset($param['subtype']) ? '\\['.$param[$type_or_subtype].'\\]' : $param[$type_or_subtype]).', ';
}
$md_constructor = \str_replace('_', '\\_', $constructor.$layer);
$md_constructor = StrTools::markdownEscape($constructor.$layer);
$this->docs_constructors[$constructor] = '[$'.$md_constructor.'](../constructors/'.$php_constructor.$layer.'.md) = \\['.$params.'\\];<a name="'.$constructor.$layer.'"></a>
';
@ -87,13 +84,13 @@ trait Constructors
| Name | Type | Required |
|----------|---------------|----------|
';
if (!isset($this->TL->getDescriptions()['constructors'][$data['predicate']])) {
$this->addToLang('object_'.$data['predicate']);
if (\danog\MadelineProto\Lang::$lang['en']['object_'.$data['predicate']] !== '') {
$this->TL->getDescriptions()['constructors'][$data['predicate']]['description'] = \danog\MadelineProto\Lang::$lang['en']['object_'.$data['predicate']];
if (!isset($this->TL->getDescriptions()['constructors'][$constructor])) {
$this->addToLang('object_'.$constructor);
if (\danog\MadelineProto\Lang::$lang['en']['object_'.$constructor] !== '') {
$this->TL->getDescriptions()['constructors'][$constructor]['description'] = \danog\MadelineProto\Lang::$lang['en']['object_'.$constructor];
}
}
if (isset($this->TL->getDescriptions()['constructors'][$data['predicate']]) && !empty($data['params'])) {
if (isset($this->TL->getDescriptions()['constructors'][$constructor]) && !empty($data['params'])) {
$table = '### Attributes:
| Name | Type | Required | Description |
@ -114,16 +111,10 @@ trait Constructors
$param['type'] = 'DecryptedMessage';
}
if ($type === 'DecryptedMessageMedia' && \in_array($param['name'], ['key', 'iv'])) {
unset(\danog\MadelineProto\Lang::$lang['en']['object_'.$data['predicate'].'_param_'.$param['name'].'_type_'.$param['type']]);
unset(\danog\MadelineProto\Lang::$lang['en']['object_'.$constructor.'_param_'.$param['name'].'_type_'.$param['type']]);
continue;
}
$ptype = $param[isset($param['subtype']) ? 'subtype' : 'type'];
//$type_or_bare_type = 'types';
/*if (isset($param['subtype'])) {
if ($param['type'] === 'vector') {
$type_or_bare_type = 'constructors';
}
}*/
if (\preg_match('/%/', $ptype)) {
$ptype = $this->TL->getConstructors($this->td)->findByType(\str_replace('%', '', $ptype))['predicate'];
}
@ -155,15 +146,15 @@ trait Constructors
if (\in_array($ptype, ['InputEncryptedFile']) && !isset($this->settings['td'])) {
$human_ptype = 'File path or '.$ptype;
}
$table .= '|'.\str_replace('_', '\\_', $param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.\str_replace('_', '\\_', $human_ptype).'](../'.$type_or_bare_type.'/'.$ptype.'.md) | '.(isset($param['pow']) || $this->TL->getConstructors($this->td)->findByPredicate(\lcfirst($param['type']).'Empty') || $data['type'] === 'InputMedia' && $param['name'] === 'mime_type' || $data['type'] === 'DocumentAttribute' && \in_array($param['name'], ['w', 'h', 'duration']) ? 'Optional' : 'Yes').'|';
if (!isset($this->TL->getDescriptions()['constructors'][$data['predicate']]['params'][$param['name']])) {
$this->addToLang('object_'.$data['predicate'].'_param_'.$param['name'].'_type_'.$param['type']);
if (isset($this->TL->getDescriptions()['constructors'][$data['predicate']]['description'])) {
$this->TL->getDescriptions()['constructors'][$data['predicate']]['params'][$param['name']] = \danog\MadelineProto\Lang::$lang['en']['object_'.$data['predicate'].'_param_'.$param['name'].'_type_'.$param['type']];
$table .= '|'.StrTools::markdownEscape($param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.StrTools::markdownEscape($human_ptype).'](../'.$type_or_bare_type.'/'.$ptype.'.md) | '.(isset($param['pow']) || $this->TL->getConstructors($this->td)->findByPredicate(\lcfirst($param['type']).'Empty') || $data['type'] === 'InputMedia' && $param['name'] === 'mime_type' || $data['type'] === 'DocumentAttribute' && \in_array($param['name'], ['w', 'h', 'duration']) ? 'Optional' : 'Yes').'|';
if (!isset($this->TL->getDescriptions()['constructors'][$constructor]['params'][$param['name']])) {
$this->addToLang('object_'.$constructor.'_param_'.$param['name'].'_type_'.$param['type']);
if (isset($this->TL->getDescriptions()['constructors'][$constructor]['description'])) {
$this->TL->getDescriptions()['constructors'][$constructor]['params'][$param['name']] = \danog\MadelineProto\Lang::$lang['en']['object_'.$constructor.'_param_'.$param['name'].'_type_'.$param['type']];
}
}
if (isset($this->TL->getDescriptions()['constructors'][$data['predicate']]['params'][$param['name']])) {
$table .= $this->TL->getDescriptions()['constructors'][$data['predicate']]['params'][$param['name']].'|';
if (isset($this->TL->getDescriptions()['constructors'][$constructor]['params'][$param['name']]) && $this->TL->getDescriptions()['constructors'][$constructor]['params'][$param['name']]) {
$table .= $this->TL->getDescriptions()['constructors'][$constructor]['params'][$param['name']].'|';
}
$table .= PHP_EOL;
$pptype = \in_array($ptype, ['string', 'bytes']) ? "'".$ptype."'" : $ptype;
@ -178,18 +169,18 @@ trait Constructors
$hasreplymarkup = true;
}
}
$params = "['_' => '".$data['predicate']."'".$params.']';
$lua_params = "{_='".$data['predicate']."'".$lua_params.'}';
$pwr_params = '{"_": "'.$data['predicate'].'"'.$pwr_params.'}';
$description = isset($this->TL->getDescriptions()['constructors'][$data['predicate']]) ? $this->TL->getDescriptions()['constructors'][$data['predicate']]['description'] : $constructor.' attributes, type and example';
$params = "['_' => '".$constructor."'".$params.']';
$lua_params = "{_='".$constructor."'".$lua_params.'}';
$pwr_params = '{"_": "'.$constructor.'"'.$pwr_params.'}';
$description = isset($this->TL->getDescriptions()['constructors'][$constructor]) ? $this->TL->getDescriptions()['constructors'][$constructor]['description'] : $constructor.' attributes, type and example';
$symFile = \str_replace('.', '_', $constructor.$layer);
$redir = $symFile !== $constructor.$layer ? "\nredirect_from: /API_docs/constructors/{$symFile}.html" : '';
$header = '---
title: '.$data['predicate'].'
title: '.$constructor.'
description: '.$description.'
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png'.$redir.'
---
# Constructor: '.\str_replace('_', '\\_', $data['predicate'].$layer).'
# Constructor: '.StrTools::markdownEscape($constructor.$layer).'
[Back to constructors index](index.md)
@ -199,73 +190,21 @@ image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png'.$redi
';
if (isset($this->TL->getDescriptions()['constructors'][$data['predicate']])) {
$header .= $this->TL->getDescriptions()['constructors'][$data['predicate']]['description'].PHP_EOL.PHP_EOL;
if (isset($this->TL->getDescriptions()['constructors'][$constructor])) {
$header .= $this->TL->getDescriptions()['constructors'][$constructor]['description'].PHP_EOL.PHP_EOL;
}
$type = '### Type: ['.\str_replace('_', '\\_', $php_type).'](../types/'.$php_type.'.md)
$type = '### Type: ['.StrTools::markdownEscape($php_type).'](../types/'.$php_type.'.md)
';
$example = '';
if (!isset($this->settings['td'])) {
$example = '### Example:
```php
$'.$constructor.$layer.' = '.$params.';
```
Or, if you\'re into Lua:
```lua
'.$constructor.$layer.'='.$lua_params.'
```
';
$example = $this->template('constructor-example', $constructor.$layer, $params, $lua_params);
if ($hasreplymarkup) {
$example .= '
## Usage of reply_markup
You can provide bot API reply_markup objects here.
';
$example .= $this->template('reply_markup');
}
if ($hasentities) {
$example .= '
## Usage of parseMode:
Set parseMode to html to enable HTML parsing of the message.
Set parseMode to Markdown to enable markown AND html parsing of the message.
The following tags are currently supported:
```html
<br>a newline
<b><i>bold works ok, internal tags are stripped</i> </b>
<strong>bold</strong>
<em>italic</em>
<i>italic</i>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>
<a href="https://github.com">URL</a>
<a href="mention:@danogentili">Mention by username</a>
<a href="mention:186785362">Mention by user id</a>
<pre language="json">Pre tags can have a language attribute</pre>
```
You can also use normal markdown, note that to create mentions you must use the `mention:` syntax like in html:
```markdown
[Mention by username](mention:@danogentili)
[Mention by user id](mention:186785362)
```
MadelineProto supports all html entities supported by [html_entity_decode](http://php.net/manual/en/function.html-entity-decode.php).
';
$example .= $this->template('parse_mode');
}
}
\file_put_contents('constructors/'.$constructor.$layer.'.md', $header.$table.$type.$example);
@ -275,19 +214,10 @@ MadelineProto supports all html entities supported by [html_entity_decode](http:
$last_namespace = '';
foreach ($this->docs_constructors as $constructor => &$value) {
$new_namespace = \preg_replace('/_.*/', '', $constructor);
$br = $new_namespace != $last_namespace ? '***
<br><br>' : '';
$br = $new_namespace != $last_namespace ? "***\n<br><br>" : '';
$value = $br.$value;
$last_namespace = $new_namespace;
}
\file_put_contents('constructors/'.$this->index, '---
title: Constructors
description: List of constructors
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
# Constructors
[Back to API documentation index](..)
'.\implode('', $this->docs_constructors));
\file_put_contents('constructors/'.$this->index, $this->template('constructors-index', \implode('', $this->docs_constructors)));
}
}

View File

@ -19,6 +19,7 @@
namespace danog\MadelineProto\DocsBuilder;
use danog\MadelineProto\StrTools;
use danog\MadelineProto\Tools;
trait Methods
@ -56,7 +57,7 @@ trait Methods
$this->logger->logger('Generating methods documentation...', \danog\MadelineProto\Logger::NOTICE);
foreach ($this->TL->getMethods($this->td)->by_id as $id => $data) {
$method = $data['method'];
$php_method = \str_replace('.', '->', $data['method']);
$phpMethod = StrTools::methodEscape($method);
$type = \str_replace(['<', '>'], ['_of_', ''], $data['type']);
$php_type = \preg_replace('/.*_of_/', '', $type);
if (!isset($this->types[$php_type])) {
@ -74,31 +75,31 @@ trait Methods
$param['name'] = 'message';
$param['type'] = 'DecryptedMessage';
}
if ($param['name'] === 'chat_id' && $data['method'] !== 'messages.discardEncryption' && !isset($this->settings['td'])) {
if ($param['name'] === 'chat_id' && $method !== 'messages.discardEncryption' && !isset($this->settings['td'])) {
$param['type'] = 'InputPeer';
}
$type_or_subtype = isset($param['subtype']) ? 'subtype' : 'type';
$type_or_bare_type = \ctype_upper(Tools::end(\explode('.', $param[$type_or_subtype]))[0]) || \in_array($param[$type_or_subtype], ['!X', 'X', 'bytes', 'true', 'false', 'double', 'string', 'Bool', 'int', 'long', 'int128', 'int256', 'int512', 'int53']) ? 'types' : 'constructors';
$param[$type_or_subtype] = \str_replace(['true', 'false'], ['Bool', 'Bool'], $param[$type_or_subtype]);
$param[$type_or_subtype] = '['.Tools::markdownEscape($param[$type_or_subtype]).'](../'.$type_or_bare_type.'/'.$param[$type_or_subtype].'.md)';
$param[$type_or_subtype] = '['.StrTools::markdownEscape($param[$type_or_subtype]).'](../'.$type_or_bare_type.'/'.$param[$type_or_subtype].'.md)';
$params .= "'".$param['name']."' => ".(isset($param['subtype']) ? '\\['.$param[$type_or_subtype].'\\]' : $param[$type_or_subtype]).', ';
}
if (!isset($this->td_descriptions['methods'][$data['method']])) {
$this->addToLang('method_'.$data['method']);
if (\danog\MadelineProto\Lang::$lang['en']['method_'.$data['method']] !== '') {
$this->td_descriptions['methods'][$data['method']]['description'] = \danog\MadelineProto\Lang::$lang['en']['method_'.$data['method']];
if (!isset($this->td_descriptions['methods'][$method])) {
$this->addToLang('method_'.$method);
if (\danog\MadelineProto\Lang::$lang['en']['method_'.$method] !== '') {
$this->td_descriptions['methods'][$method]['description'] = \danog\MadelineProto\Lang::$lang['en']['method_'.$method];
}
}
$md_method = '['.$php_method.']('.$method.'.md)';
$this->docs_methods[$method] = '$MadelineProto->'.$md_method.'(\\['.$params.'\\]) === [$'.\str_replace('_', '\\_', $type).'](../types/'.$php_type.'.md)<a name="'.$method.'"></a>
$md_method = '['.$phpMethod.']('.$method.'.md)';
$this->docs_methods[$method] = '$MadelineProto->'.$md_method.'(\\['.$params.'\\]) === [$'.StrTools::markdownEscape($type).'](../types/'.$php_type.'.md)<a name="'.$method.'"></a>
';
if (isset($this->td_descriptions['methods'][$data['method']])) {
$desc = \Parsedown::instance()->line(\trim(\explode("\n", $this->td_descriptions['methods'][$data['method']]['description'])[0], '.'));
if (isset($this->td_descriptions['methods'][$method])) {
$desc = \Parsedown::instance()->line(\trim(\explode("\n", $this->td_descriptions['methods'][$method]['description'])[0], '.'));
$dom = new \DOMDocument();
$dom->loadHTML(\mb_convert_encoding($desc, 'HTML-ENTITIES', 'UTF-8'));
$desc = $dom->textContent;
$this->human_docs_methods[$this->td_descriptions['methods'][$data['method']]['description'].': '.$data['method']] = '* <a href="'.$method.'.html" name="'.$method.'">'.$desc.': '.$data['method'].'</a>
$this->human_docs_methods[$this->td_descriptions['methods'][$method]['description'].': '.$method] = '* <a href="'.$method.'.html" name="'.$method.'">'.$desc.': '.$method.'</a>
';
}
@ -111,7 +112,7 @@ trait Methods
| Name | Type | Required |
|----------|---------------|----------|
';
if (isset($this->td_descriptions['methods'][$data['method']]) && !empty($data['params'])) {
if (isset($this->td_descriptions['methods'][$method]) && !empty($data['params'])) {
$table = '### Parameters:
| Name | Type | Description | Required |
@ -129,7 +130,7 @@ trait Methods
$param['name'] = 'message';
$param['type'] = 'DecryptedMessage';
}
if ($param['name'] === 'chat_id' && $data['method'] !== 'messages.discardEncryption' && !isset($this->settings['td'])) {
if ($param['name'] === 'chat_id' && $method !== 'messages.discardEncryption' && !isset($this->settings['td'])) {
$param['type'] = 'InputPeer';
}
if ($param['name'] === 'hash' && $param['type'] === 'int') {
@ -163,16 +164,15 @@ trait Methods
$human_ptype = 'File path or '.$ptype;
}
$type_or_bare_type = \ctype_upper(Tools::end(\explode('.', $param[$type_or_subtype]))[0]) || \in_array($param[$type_or_subtype], ['!X', 'X', 'bytes', 'true', 'false', 'double', 'string', 'Bool', 'int', 'long', 'int128', 'int256', 'int512', 'int53']) ? 'types' : 'constructors';
if (!isset($this->td_descriptions['methods'][$data['method']]['params'][$param['name']])) {
$this->addToLang('method_'.$data['method'].'_param_'.$param['name'].'_type_'.$param['type']);
if (isset($this->td_descriptions['methods'][$data['method']]['description'])) {
$this->td_descriptions['methods'][$data['method']]['params'][$param['name']] = \danog\MadelineProto\Lang::$lang['en']['method_'.$data['method'].'_param_'.$param['name'].'_type_'.$param['type']];
if (!isset($this->td_descriptions['methods'][$method]['params'][$param['name']])) {
if (isset($this->td_descriptions['methods'][$method]['description'])) {
$this->td_descriptions['methods'][$method]['params'][$param['name']] = \danog\MadelineProto\Lang::$lang['en']['method_'.$method.'_param_'.$param['name'].'_type_'.$param['type']] ?? '';
}
}
if (isset($this->td_descriptions['methods'][$data['method']])) {
$table .= '|'.\str_replace('_', '\\_', $param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.\str_replace('_', '\\_', $human_ptype).'](../'.$type_or_bare_type.'/'.$ptype.'.md) | '.$this->td_descriptions['methods'][$data['method']]['params'][$param['name']].' | '.(isset($param['pow']) || ($id = $this->TL->getConstructors($this->td)->findByPredicate(\lcfirst($param['type']).'Empty')) && $id['type'] === $param['type'] || ($id = $this->TL->getConstructors($this->td)->findByPredicate('input'.$param['type'].'Empty')) && $id['type'] === $param['type'] ? 'Optional' : 'Yes').'|';
if (isset($this->td_descriptions['methods'][$method])) {
$table .= '|'.StrTools::markdownEscape($param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.StrTools::markdownEscape($human_ptype).'](../'.$type_or_bare_type.'/'.$ptype.'.md) | '.$this->td_descriptions['methods'][$method]['params'][$param['name']].' | '.(isset($param['pow']) || ($id = $this->TL->getConstructors($this->td)->findByPredicate(\lcfirst($param['type']).'Empty')) && $id['type'] === $param['type'] || ($id = $this->TL->getConstructors($this->td)->findByPredicate('input'.$param['type'].'Empty')) && $id['type'] === $param['type'] ? 'Optional' : 'Yes').'|';
} else {
$table .= '|'.\str_replace('_', '\\_', $param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.\str_replace('_', '\\_', $human_ptype).'](../'.$type_or_bare_type.'/'.$ptype.'.md) | '.(isset($param['pow']) || ($id = $this->TL->getConstructors($this->td)->findByPredicate(\lcfirst($param['type']).'Empty')) && $id['type'] === $param['type'] || ($id = $this->TL->getConstructors($this->td)->findByPredicate('input'.$param['type'].'Empty')) && $id['type'] === $param['type'] ? 'Optional' : 'Yes').'|';
$table .= '|'.StrTools::markdownEscape($param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.StrTools::markdownEscape($human_ptype).'](../'.$type_or_bare_type.'/'.$ptype.'.md) | '.(isset($param['pow']) || ($id = $this->TL->getConstructors($this->td)->findByPredicate(\lcfirst($param['type']).'Empty')) && $id['type'] === $param['type'] || ($id = $this->TL->getConstructors($this->td)->findByPredicate('input'.$param['type'].'Empty')) && $id['type'] === $param['type'] ? 'Optional' : 'Yes').'|';
}
$table .= PHP_EOL;
$pptype = \in_array($ptype, ['string', 'bytes']) ? "'".$ptype."'" : $ptype;
@ -200,128 +200,41 @@ trait Methods
$pwr_params = "parseMode - string\n";
}
}
$description = isset($this->td_descriptions['methods'][$data['method']]) ? $this->td_descriptions['methods'][$data['method']]['description'] : $data['method'].' parameters, return type and example';
$description = isset($this->td_descriptions['methods'][$method]) ? $this->td_descriptions['methods'][$method]['description'] : $method.' parameters, return type and example';
$symFile = \str_replace('.', '_', $method);
$redir = $symFile !== $method ? "\nredirect_from: /API_docs/methods/{$symFile}.html" : '';
$header = '---
title: '.$data['method'].'
description: '.$description.'
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png'.$redir.'
---
# Method: '.\str_replace('_', '\\_', $data['method']).'
[Back to methods index](index.md)
';
/*
if (isset(\danog\MadelineProto\MTProto::DISALLOWED_METHODS[$data['method']])) {
$header .= '**'.\danog\MadelineProto\MTProto::DISALLOWED_METHODS[$data['method']]."**\n\n\n\n\n";
file_put_contents('methods/'.$method.'.md', $header);
continue;
}*/
$header = $this->template('Method', $method, $description, $redir, StrTools::markdownEscape($method));
if ($this->td) {
$header .= 'YOU CANNOT USE THIS METHOD IN MADELINEPROTO
';
$header .= "YOU CANNOT USE THIS METHOD IN MADELINEPROTO\n\n\n\n\n";
}
$header .= isset($this->td_descriptions['methods'][$data['method']]) ? $this->td_descriptions['methods'][$data['method']]['description'].PHP_EOL.PHP_EOL : '';
$header .= isset($this->td_descriptions['methods'][$method]) ? $this->td_descriptions['methods'][$method]['description'].PHP_EOL.PHP_EOL : '';
$table .= '
';
$return = '### Return type: ['.\str_replace('_', '\\_', $type).'](../types/'.$php_type.'.md)
$return = '### Return type: ['.StrTools::markdownEscape($type).'](../types/'.$php_type.'.md)
';
$bot = !\in_array($data['method'], $bots);
$bot = !\in_array($method, $bots);
$example = '';
if (!isset($this->settings['td'])) {
$example .= '### Can bots use this method: **'.($bot ? 'YES' : 'NO')."**\n\n\n";
$example .= \str_replace('[]', '', '### MadelineProto Example ([now async for huge speed and parallelism!](https://docs.madelineproto.xyz/docs/ASYNC.html)):
```php
if (!file_exists(\'madeline.php\')) {
copy(\'https://phar.madelineproto.xyz/madeline.php\', \'madeline.php\');
}
include \'madeline.php\';
$MadelineProto = new \\danog\\MadelineProto\\API(\'session.madeline\');
$MadelineProto->start();
$'.$type.' = $MadelineProto->'.$php_method.'(['.$params.']);
```
Or, if you\'re into Lua:
```lua
'.$type.' = '.$data['method'].'({'.$lua_params.'})
```
');
$example .= \str_replace('[]', '', $this->template('method-example', $type, $phpMethod, $params, $method, $lua_params));
if ($hasreplymarkup) {
$example .= '
## Usage of reply_markup
You can provide bot API reply_markup objects here.
';
$example .= $this->template('reply_markup');
}
if ($hasmessage) {
$example .= '
## Return value
If the length of the provided message is bigger than 4096, the message will be split in chunks and the method will be called multiple times, with the same parameters (except for the message), and an array of ['.\str_replace('_', '\\_', $type).'](../types/'.$php_type.'.md) will be returned instead.
';
$example .= $this->template('chunks', StrTools::markdownEscape($type), $php_type);
}
if ($hasentities) {
$example .= '
## Usage of parseMode:
Set parseMode to html to enable HTML parsing of the message.
Set parseMode to Markdown to enable markown AND html parsing of the message.
The following tags are currently supported:
```html
<br>a newline
<b><i>bold works ok, internal tags are stripped</i> </b>
<strong>bold</strong>
<em>italic</em>
<i>italic</i>
<u>underline</u>
<s>strikethrough</s>
<del>strikethrough</del>
<strike>strikethrough</strike>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>
<blockquote>pre-formatted fixed-width code block</blockquote>
<a href="https://github.com">URL</a>
<a href="mention:@danogentili">Mention by username</a>
<a href="mention:186785362">Mention by user id</a>
<pre language="json">Pre tags can have a language attribute</pre>
```
You can also use normal markdown, note that to create mentions you must use the `mention:` syntax like in html:
```markdown
[Mention by username](mention:@danogentili)
[Mention by user id](mention:186785362)
```
MadelineProto supports all html entities supported by [html_entity_decode](http://php.net/manual/en/function.html-entity-decode.php).
';
$example .= $this->template('parse_mode');
}
if (isset($new['result'][$data['method']])) {
if (isset($new['result'][$method])) {
$example .= '### Errors
| Code | Type | Description |
|------|----------|---------------|
';
foreach ($new['result'][$data['method']] as $error) {
foreach ($new['result'][$method] as $error) {
[$error, $code] = $error;
$example .= "|{$code}|{$error}|".$errors['human_result'][$error][0].'|'."\n";
}
@ -342,75 +255,7 @@ MadelineProto supports all html entities supported by [html_entity_decode](http:
$value = $br.$value;
$last_namespace = $new_namespace;
}
\file_put_contents('methods/api_'.$this->index, '---
title: Methods
description: List of methods
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
# Methods
[Back to API documentation index](..)
[Go to the new description-version method index]('.$this->index.')
$MadelineProto->[logout](https://docs.madelineproto.xyz/logout.html)();
$MadelineProto->[phoneLogin](https://docs.madelineproto.xyz/phoneLogin.html)($number);
$MadelineProto->[completePhoneLogin](https://docs.madelineproto.xyz/completePhoneLogin.html)($code);
$MadelineProto->[complete2FALogin](https://docs.madelineproto.xyz/complete2FAlogin.html)($password);
$MadelineProto->[botLogin](https://docs.madelineproto.xyz/botLogin.html)($token);
$MadelineProto->[getDialogs](https://docs.madelineproto.xyz/getDialogs.html)();
$MadelineProto->[getPwrChat](https://docs.madelineproto.xyz/getPwrChat.html)($id);
$MadelineProto->[getInfo](https://docs.madelineproto.xyz/getInfo.html)($id);
$MadelineProto->[getFullInfo](https://docs.madelineproto.xyz/getFullInfo.html)($id);
$MadelineProto->[getSelf](https://docs.madelineproto.xyz/getSelf.html)();
$MadelineProto->[requestCall](https://docs.madelineproto.xyz/requestCall.html)($id);
$MadelineProto->[requestSecretChat](https://docs.madelineproto.xyz/requestSecretChat.html)($id);
'.\implode('', $this->docs_methods));
\file_put_contents('methods/'.$this->index, '---
title: Methods
description: What do you want to do?
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
# What do you want to do?
[Go back to API documentation index](..)
[Go to the old code-version method index](api_'.$this->index.')
* [Logout](https://docs.madelineproto.xyz/logout.html)
* [Login](https://docs.madelineproto.xyz/docs/LOGIN.html)
* [Change 2FA password](https://docs.madelineproto.xyz/update2fa.html)
* [Get all chats, broadcast a message to all chats](https://docs.madelineproto.xyz/docs/DIALOGS.html)
* [Get the full participant list of a channel/group/supergroup](https://docs.madelineproto.xyz/getPwrChat.html)
* [Get full info about a user/chat/supergroup/channel](https://docs.madelineproto.xyz/getFullInfo.html)
* [Get info about a user/chat/supergroup/channel](https://docs.madelineproto.xyz/getInfo.html)
* [Get info about the currently logged-in user](https://docs.madelineproto.xyz/getSelf.html)
* [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)
'.\implode('', $this->human_docs_methods));
\file_put_contents('methods/api_'.$this->index, $this->template('methods-api-index', $this->index, \implode('', $this->docs_methods)));
\file_put_contents('methods/'.$this->index, $this->template('methods-index', $this->index, \implode('', $this->human_docs_methods)));
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -7,53 +7,53 @@ use danog\MadelineProto\Logger;
class GarbageCollector
{
/**
* Ensure only one instance of GarbageCollector
* when multiple instances of MadelineProto running.
* @var bool
*/
public static bool $lock = false;
/**
* Ensure only one instance of GarbageCollector
* when multiple instances of MadelineProto running.
* @var bool
*/
public static bool $lock = false;
/**
* How often will check memory
* @var int
*/
public static int $checkIntervalMs = 1000;
/**
* How often will check memory.
* @var int
*/
public static int $checkIntervalMs = 1000;
/**
* Next cleanup will be triggered when memory consumption will increase by this amount
* @var int
*/
public static int $memoryDiffMb = 1;
/**
* Next cleanup will be triggered when memory consumption will increase by this amount.
* @var int
*/
public static int $memoryDiffMb = 1;
/**
* Memory consumption after last cleanup
* @var int
*/
private static int $memoryConsumption = 0;
/**
* Memory consumption after last cleanup.
* @var int
*/
private static int $memoryConsumption = 0;
public static function start(): void
{
if (static::$lock) {
return;
}
static::$lock = true;
public static function start(): void
{
if (static::$lock) {
return;
}
static::$lock = true;
Loop::repeat(static::$checkIntervalMs, static function() {
$currentMemory = static::getMemoryConsumption();
if ($currentMemory > static::$memoryConsumption + static::$memoryDiffMb) {
gc_collect_cycles();
static::$memoryConsumption = static::getMemoryConsumption();
$cleanedMemory = $currentMemory - static::$memoryConsumption;
Logger::log("gc_collect_cycles done. Cleaned memory: $cleanedMemory Mb", Logger::NOTICE);
}
});
}
Loop::repeat(static::$checkIntervalMs, static function () {
$currentMemory = static::getMemoryConsumption();
if ($currentMemory > static::$memoryConsumption + static::$memoryDiffMb) {
\gc_collect_cycles();
static::$memoryConsumption = static::getMemoryConsumption();
$cleanedMemory = $currentMemory - static::$memoryConsumption;
Logger::log("gc_collect_cycles done. Cleaned memory: $cleanedMemory Mb", Logger::NOTICE);
}
});
}
private static function getMemoryConsumption(): int
{
$memory = round(memory_get_usage()/1024/1024, 1);
Logger::log("Memory consumption: $memory Mb", Logger::VERBOSE);
return (int) $memory;
}
}
private static function getMemoryConsumption(): int
{
$memory = \round(\memory_get_usage()/1024/1024, 1);
Logger::log("Memory consumption: $memory Mb", Logger::VERBOSE);
return (int) $memory;
}
}

View File

@ -208,7 +208,7 @@ trait PeerHandler
private function cacheChatUsername(int $id, array $chat)
{
if ($id && !empty($chat['username'])) {
$this->usernames[strtolower($chat['username'])] = $id;
$this->usernames[\strtolower($chat['username'])] = $id;
}
}

View File

@ -23,7 +23,7 @@ class RPCErrorException extends \Exception
{
use TL\PrettyException;
/**
* RPC error code
* RPC error code.
*/
public string $rpc = '';
private $fetched = false;

View File

@ -0,0 +1,88 @@
<?php
/**
* Tools module.
*
* This file is part of MadelineProto.
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU General Public License along with MadelineProto.
* If not, see <http://www.gnu.org/licenses/>.
*
* @author Daniil Gentili <daniil@daniil.it>
* @copyright 2016-2020 Daniil Gentili <daniil@daniil.it>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
*
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/
namespace danog\MadelineProto;
/**
* Some tools.
*/
abstract class StrTools
{
/**
* Convert to camelCase.
*
* @param string $input String
*
* @return string
*/
public static function toCamelCase(string $input): string
{
return \lcfirst(\str_replace('_', '', \ucwords($input, '_')));
}
/**
* Convert to snake_case.
*
* @param string $input String
*
* @return string
*/
public static function toSnakeCase(string $input): string
{
\preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
$ret = $matches[0];
foreach ($ret as &$match) {
$match = $match == \strtoupper($match) ? \strtolower($match) : \lcfirst($match);
}
return \implode('_', $ret);
}
/**
* Escape string for markdown.
*
* @param string $hwat String to escape
*
* @return string
*/
public static function markdownEscape(string $hwat): string
{
return \str_replace('_', '\\_', $hwat);
}
/**
* Escape type name.
*
* @param string $type String to escape
*
* @return string
*/
public static function typeEscape(string $type): string
{
$type = \str_replace(['<', '>'], ['_of_', ''], $type);
return \preg_replace('/.*_of_/', '', $type);
}
/**
* Escape method name.
*
* @param string $method Method name
*
* @return string
*/
public static function methodEscape(string $method): string
{
return \str_replace('.', '->', $method);
}
}

View File

@ -208,7 +208,7 @@ class BufferedRawStream implements BufferedStreamInterface, BufferInterface, Raw
return $this->write($data);
}
/**
* Get remaining data from buffer
* Get remaining data from buffer.
*
* @return string
*/
@ -217,8 +217,8 @@ class BufferedRawStream implements BufferedStreamInterface, BufferInterface, Raw
$size = \fstat($this->memory_stream)['size'];
$offset = \ftell($this->memory_stream);
$buffer_length = $size - $offset;
$data = fread($this->memory_stream, $buffer_length);
fclose($this->memory_stream);
$data = \fread($this->memory_stream, $buffer_length);
\fclose($this->memory_stream);
$this->memory_stream = null;
return $data;
}

View File

@ -30,7 +30,6 @@ use danog\MadelineProto\Stream\BufferedStreamInterface;
use danog\MadelineProto\Stream\ConnectionContext;
use danog\MadelineProto\Stream\RawStreamInterface;
use danog\MadelineProto\Stream\ReadBufferInterface;
use danog\MadelineProto\Stream\StreamInterface;
use danog\MadelineProto\Stream\Transport\DefaultStream;
use danog\MadelineProto\Stream\WriteBufferInterface;
@ -135,7 +134,7 @@ class UdpBufferedStream extends DefaultStream implements BufferedStreamInterface
private RawStreamInterface $stream;
private string $data = '';
/**
* Constructor function
* Constructor function.
*
* @param integer $length
* @param string $append
@ -172,7 +171,7 @@ class UdpBufferedStream extends DefaultStream implements BufferedStreamInterface
throw new Exception('Tried to send too much out of frame data, cannot append');
}
}
return new Success(strlen($data));
return new Success(\strlen($data));
}
});
}

View File

@ -0,0 +1,19 @@
bot_thumbnail#0 dc_id:int id:long access_hash:long volume_id:long = File;
bot_profile_photo#1 dc_id:int id:long access_hash:long volume_id:long = File;
bot_photo#2 dc_id:int id:long access_hash:long volume_id:long = File;
bot_voice#3 dc_id:int id:long access_hash:long = File;
bot_video#4 dc_id:int id:long access_hash:long = File;
bot_document#5 dc_id:int id:long access_hash:long = File;
bot_encrypted#6 dc_id:int id:long access_hash:long = File;
bot_temp#7 dc_id:int id:long access_hash:long = File;
bot_sticker#8 dc_id:int id:long access_hash:long = File;
bot_audio#9 dc_id:int id:long access_hash:long = File;
bot_gif#A dc_id:int id:long access_hash:long = File;
bot_encrypted_thumbnail#B dc_id:int id:long access_hash:long = File;
bot_wallpaper#C dc_id:int id:long access_hash:long = File;
bot_video_note#D dc_id:int id:long access_hash:long = File;
bot_secure_raw#F dc_id:int id:long access_hash:long = File;
bot_secure#10 dc_id:int id:long access_hash:long = File;
bot_background#11 dc_id:int id:long access_hash:long = File;
bot_size#12 dc_id:int id:long access_hash:long = File;

View File

@ -0,0 +1,86 @@
resPQ#05162463 nonce:int128 server_nonce:int128 pq:string server_public_key_fingerprints:Vector<long> = ResPQ;
vector {t:Type} # [ t ] = Vector t;
p_q_inner_data_dc#a9f55f95 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 dc:int = P_Q_inner_data;
p_q_inner_data_temp_dc#56fddf88 pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 dc:int expires_in:int = P_Q_inner_data;
p_q_inner_data pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 = P_Q_inner_data;
p_q_inner_data_temp pq:string p:string q:string nonce:int128 server_nonce:int128 new_nonce:int256 expires_in:int = P_Q_inner_data;
server_DH_params_fail#79cb045d nonce:int128 server_nonce:int128 new_nonce_hash:int128 = Server_DH_Params;
server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:string = Server_DH_Params;
server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:string g_a:string server_time:int = Server_DH_inner_data;
client_DH_inner_data#6643b654 nonce:int128 server_nonce:int128 retry_id:long g_b:string = Client_DH_Inner_Data;
dh_gen_ok#3bcbf734 nonce:int128 server_nonce:int128 new_nonce_hash1:int128 = Set_client_DH_params_answer;
dh_gen_retry#46dc1fb9 nonce:int128 server_nonce:int128 new_nonce_hash2:int128 = Set_client_DH_params_answer;
dh_gen_fail#a69dae02 nonce:int128 server_nonce:int128 new_nonce_hash3:int128 = Set_client_DH_params_answer;
bind_auth_key_inner#75a3f765 nonce:long temp_auth_key_id:long perm_auth_key_id:long temp_session_id:long expires_at:int = BindAuthKeyInner;
rpc_result#f35c6d01 req_msg_id:long result:Object = RpcResult;
rpc_error#2144ca19 error_code:int error_message:string = RpcError;
rpc_answer_unknown#5e2ad36e = RpcDropAnswer;
rpc_answer_dropped_running#cd78e586 = RpcDropAnswer;
rpc_answer_dropped#a43ad8b7 msg_id:long seq_no:int bytes:int = RpcDropAnswer;
future_salt#0949d9dc valid_since:int valid_until:int salt:long = FutureSalt;
future_salts#ae500895 req_msg_id:long now:int salts:vector<future_salt> = FutureSalts;
pong#347773c5 msg_id:long ping_id:long = Pong;
destroy_session_ok#e22045fc session_id:long = DestroySessionRes;
destroy_session_none#62d350c9 session_id:long = DestroySessionRes;
new_session_created#9ec20908 first_msg_id:long unique_id:long server_salt:long = NewSession;
msg_container#73f1f8dc messages:vector<%Message> = MessageContainer;
message msg_id:long seqno:int bytes:int body:Object = Message;
msg_copy#e06046b2 orig_message:Message = MessageCopy;
gzip_packed#3072cfa1 packed_data:bytes = Object;
msgs_ack#62d6b459 msg_ids:Vector<long> = MsgsAck;
bad_msg_notification#a7eff811 bad_msg_id:long bad_msg_seqno:int error_code:int = BadMsgNotification;
bad_server_salt#edab447b bad_msg_id:long bad_msg_seqno:int error_code:int new_server_salt:long = BadMsgNotification;
msg_resend_ans_req#8610baeb msg_ids:Vector<long> = MsgResendReq;
msg_resend_req#7d861a08 msg_ids:Vector<long> = MsgResendReq;
msgs_state_req#da69fb52 msg_ids:Vector<long> = MsgsStateReq;
msgs_state_info#04deb57d req_msg_id:long info:string = MsgsStateInfo;
msgs_all_info#8cc0d131 msg_ids:Vector<long> info:string = MsgsAllInfo;
msg_detailed_info#276d3ec6 msg_id:long answer_msg_id:long bytes:int status:int = MsgDetailedInfo;
msg_new_detailed_info#809db6df answer_msg_id:long bytes:int status:int = MsgDetailedInfo;
rsa_public_key n:string e:string = RSAPublicKey;
http_wait#9299359f max_delay:int wait_after:int max_wait:int = HttpWait;
---functions---
req_pq_multi#be7e8ef1 nonce:int128 = ResPQ;
req_pq nonce:int128 = ResPQ;
req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:string q:string public_key_fingerprint:long encrypted_data:string = Server_DH_Params;
set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:string = Set_client_DH_params_answer;
rpc_drop_answer#58e4a740 req_msg_id:long = RpcDropAnswer;
get_future_salts#b921bd04 num:int = FutureSalts;
ping#7abe77ec ping_id:long = Pong;
ping_delay_disconnect#f3427b8c ping_id:long disconnect_delay:int = Pong;
destroy_session#e7512126 session_id:long = DestroySessionRes;
//test.useGzipPacked = GzipPacked;
//test.useServerDhInnerData = Server_DH_inner_data;
//test.useNewSessionCreated = NewSession;
//test.useMsgsAck = MsgsAck;
//test.useBadMsgNotification = BadMsgNotification;
//test.useOther key:rsa_public_key p_q_data:P_Q_inner_data dh_data:client_DH_inner_data = RpcError;

View File

@ -0,0 +1,76 @@
===8===
decryptedMessage#1f814f1f random_id:long random_bytes:bytes message:string media:DecryptedMessageMedia = DecryptedMessage;
decryptedMessageService#aa48327d random_id:long random_bytes:bytes action:DecryptedMessageAction = DecryptedMessage;
decryptedMessageMediaEmpty#89f5c4a = DecryptedMessageMedia;
decryptedMessageMediaPhoto#32798a8c thumb:bytes thumb_w:int thumb_h:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaVideo#4cee6ef3 thumb:bytes thumb_w:int thumb_h:int duration:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaGeoPoint#35480a59 lat:double long:double = DecryptedMessageMedia;
decryptedMessageMediaContact#588a0a97 phone_number:string first_name:string last_name:string user_id:int = DecryptedMessageMedia;
decryptedMessageActionSetMessageTTL#a1733aec ttl_seconds:int = DecryptedMessageAction;
decryptedMessageMediaDocument#b095434b thumb:bytes thumb_w:int thumb_h:int file_name:string mime_type:string size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaAudio#6080758f duration:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageActionReadMessages#c4f40be random_ids:Vector<long> = DecryptedMessageAction;
decryptedMessageActionDeleteMessages#65614304 random_ids:Vector<long> = DecryptedMessageAction;
decryptedMessageActionScreenshotMessages#8ac1f475 random_ids:Vector<long> = DecryptedMessageAction;
decryptedMessageActionFlushHistory#6719e45c = DecryptedMessageAction;
===17===
decryptedMessage#204d3878 random_id:long ttl:int message:string media:DecryptedMessageMedia = DecryptedMessage;
decryptedMessageService#73164160 random_id:long action:DecryptedMessageAction = DecryptedMessage;
decryptedMessageMediaVideo#524a415d thumb:bytes thumb_w:int thumb_h:int duration:int mime_type:string w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaAudio#57e0a9cb duration:int mime_type:string size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageLayer#1be31789 random_bytes:bytes layer:int in_seq_no:int out_seq_no:int message:DecryptedMessage = DecryptedMessageLayer;
sendMessageTypingAction#16bf744e = SendMessageAction;
sendMessageCancelAction#fd5ec8f5 = SendMessageAction;
sendMessageRecordVideoAction#a187d66f = SendMessageAction;
sendMessageUploadVideoAction#92042ff7 = SendMessageAction;
sendMessageRecordAudioAction#d52f73f7 = SendMessageAction;
sendMessageUploadAudioAction#e6ac8a6f = SendMessageAction;
sendMessageUploadPhotoAction#990a3c1a = SendMessageAction;
sendMessageUploadDocumentAction#8faee98e = SendMessageAction;
sendMessageGeoLocationAction#176f8ba1 = SendMessageAction;
sendMessageChooseContactAction#628cbc6f = SendMessageAction;
decryptedMessageActionResend#511110b0 start_seq_no:int end_seq_no:int = DecryptedMessageAction;
decryptedMessageActionNotifyLayer#f3048883 layer:int = DecryptedMessageAction;
decryptedMessageActionTyping#ccb27641 action:SendMessageAction = DecryptedMessageAction;
===20===
decryptedMessageActionRequestKey#f3c9611b exchange_id:long g_a:bytes = DecryptedMessageAction;
decryptedMessageActionAcceptKey#6fe1735b exchange_id:long g_b:bytes key_fingerprint:long = DecryptedMessageAction;
decryptedMessageActionAbortKey#dd05ec6b exchange_id:long = DecryptedMessageAction;
decryptedMessageActionCommitKey#ec2e0b9b exchange_id:long key_fingerprint:long = DecryptedMessageAction;
decryptedMessageActionNoop#a82fdd63 = DecryptedMessageAction;
===23===
documentAttributeImageSize#6c37c15c w:int h:int = DocumentAttribute;
documentAttributeAnimated#11b58939 = DocumentAttribute;
documentAttributeSticker#fb0a5727 = DocumentAttribute;
documentAttributeVideo#5910cccb duration:int w:int h:int = DocumentAttribute;
documentAttributeAudio#51448e5 duration:int = DocumentAttribute;
documentAttributeFilename#15590068 file_name:string = DocumentAttribute;
photoSizeEmpty#e17e23c type:string = PhotoSize;
photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize;
photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileLocation;
fileLocation#53d69076 dc_id:int volume_id:long local_id:int secret:long = FileLocation;
decryptedMessageMediaExternalDocument#fa95b0dd id:long access_hash:long date:int mime_type:string size:int thumb:PhotoSize dc_id:int attributes:Vector<DocumentAttribute> = DecryptedMessageMedia;
===45===
decryptedMessage#36b091de flags:# random_id:long ttl:int message:string media:flags.9?DecryptedMessageMedia entities:flags.7?Vector<MessageEntity> via_bot_name:flags.11?string reply_to_random_id:flags.3?long = DecryptedMessage;
decryptedMessageMediaPhoto#f1fa8d78 thumb:bytes thumb_w:int thumb_h:int w:int h:int size:int key:bytes iv:bytes caption:string = DecryptedMessageMedia;
decryptedMessageMediaVideo#970c8c0e thumb:bytes thumb_w:int thumb_h:int duration:int mime_type:string w:int h:int size:int key:bytes iv:bytes caption:string = DecryptedMessageMedia;
decryptedMessageMediaDocument#7afe8ae2 thumb:bytes thumb_w:int thumb_h:int mime_type:string size:int key:bytes iv:bytes attributes:Vector<DocumentAttribute> caption:string = DecryptedMessageMedia;
===46===
decryptedMessageMediaVenue#8a0df56f lat:double long:double title:string address:string provider:string venue_id:string = DecryptedMessageMedia;
documentAttributeAudio#ded218e0 duration:int title:string performer:string = DocumentAttribute;
decryptedMessageMediaWebPage#e50511d8 url:string = DecryptedMessageMedia;
===55===
documentAttributeSticker#3a556302 alt:string stickerset:InputStickerSet = DocumentAttribute;
===66===
documentAttributeVideo#ef02ce6 flags:# round_message:flags.0?true duration:int w:int h:int = DocumentAttribute;
===73===
decryptedMessage#91cc4674 flags:# random_id:long ttl:int message:string media:flags.9?DecryptedMessageMedia entities:flags.7?Vector<MessageEntity> via_bot_name:flags.11?string reply_to_random_id:flags.3?long grouped_id:flags.17?long = DecryptedMessage;

File diff suppressed because it is too large Load Diff

View File

@ -918,6 +918,8 @@ class InternalDoc extends APIFactory
* @param \Generator|Promise $a Promise A
* @param \Generator|Promise $b Promise B
*
* @psalm-suppress InvalidScope
*
* @return Promise
*/
public function after($a, $b)
@ -1009,6 +1011,8 @@ class InternalDoc extends APIFactory
* @param ?\Generator|Promise $actual Promise to resolve instead of $promise
* @param string $file File
*
* @psalm-suppress InvalidScope
*
* @return Promise|mixed
*/
public function callFork($promise, $actual = null, $file = '')
@ -1078,7 +1082,7 @@ class InternalDoc extends APIFactory
* @param integer $operation Locking mode
* @param float $polling Polling interval
*
* @return Promise
* @return Promise<callable>
*/
public function flock(string $file, int $operation, float $polling = 0.1)
{
@ -1110,6 +1114,8 @@ class InternalDoc extends APIFactory
* @param object $obj Object
* @param string $var Attribute name
*
* @psalm-suppress InvalidScope
*
* @return mixed
* @access public
*/
@ -1177,11 +1183,11 @@ class InternalDoc extends APIFactory
*
* @param string $hwat String to escape
*
* @return void
* @return string
*/
public function markdownEscape(string $hwat): string
{
return \danog\MadelineProto\Tools::markdownEscape($hwat);
return \danog\MadelineProto\StrTools::markdownEscape($hwat);
}
/**
* Call lite method.
@ -1197,6 +1203,17 @@ class InternalDoc extends APIFactory
{
return $this->__call(__FUNCTION__, [$methodName, $args, $aargs, $extra]);
}
/**
* Escape method name.
*
* @param string $method Method name
*
* @return string
*/
public function methodEscape(string $method): string
{
return \danog\MadelineProto\StrTools::methodEscape($method);
}
/**
* Convert double to binary version.
*
@ -1281,7 +1298,7 @@ class InternalDoc extends APIFactory
*
* @param string $prompt Prompt
*
* @return Promise
* @return Promise<string>
*/
public function readLine(string $prompt = '')
{
@ -1293,6 +1310,8 @@ class InternalDoc extends APIFactory
* @param \Throwable $e Exception
* @param string $file File where the strand started
*
* @psalm-suppress InvalidScope
*
* @return void
*/
public function rethrow(\Throwable $e, $file = ''): void
@ -1328,6 +1347,8 @@ class InternalDoc extends APIFactory
* @param string $var Attribute name
* @param mixed $val Attribute value
*
* @psalm-suppress InvalidScope
*
* @return mixed
* @access public
*/
@ -1379,7 +1400,7 @@ class InternalDoc extends APIFactory
*/
public function toCamelCase(string $input): string
{
return \danog\MadelineProto\Tools::toCamelCase($input);
return \danog\MadelineProto\StrTools::toCamelCase($input);
}
/**
* Convert to snake_case.
@ -1390,7 +1411,18 @@ class InternalDoc extends APIFactory
*/
public function toSnakeCase(string $input): string
{
return \danog\MadelineProto\Tools::toSnakeCase($input);
return \danog\MadelineProto\StrTools::toSnakeCase($input);
}
/**
* Escape type name.
*
* @param string $type String to escape
*
* @return string
*/
public function typeEscape(string $type): string
{
return \danog\MadelineProto\StrTools::typeEscape($type);
}
/**
* Unpack binary double.

View File

@ -41,7 +41,7 @@ use function Amp\Promise\wait;
/**
* Some tools.
*/
abstract class Tools
abstract class Tools extends StrTools
{
/**
* Sanify TL obtained from JSON for TL serialization.
@ -628,33 +628,6 @@ abstract class Tools
{
return \is_array($var) || $var instanceof \ArrayAccess && $var instanceof \Traversable && $var instanceof \Countable;
}
/**
* Convert to camelCase.
*
* @param string $input String
*
* @return string
*/
public static function toCamelCase(string $input): string
{
return \lcfirst(\str_replace('_', '', \ucwords($input, '_')));
}
/**
* Convert to snake_case.
*
* @param string $input String
*
* @return string
*/
public static function toSnakeCase(string $input): string
{
\preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
$ret = $matches[0];
foreach ($ret as &$match) {
$match = $match == \strtoupper($match) ? \strtolower($match) : \lcfirst($match);
}
return \implode('_', $ret);
}
/**
* Create array.
*
@ -801,17 +774,6 @@ abstract class Tools
{
return \end($what);
}
/**
* Escape string for markdown.
*
* @param string $hwat String to escape
*
* @return void
*/
public static function markdownEscape(string $hwat): string
{
return \str_replace('_', '\\_', $hwat);
}
/**
* Whether this is altervista.
*

View File

@ -13,6 +13,8 @@
use danog\MadelineProto\API;
use danog\MadelineProto\APIFactory;
use danog\MadelineProto\Logger;
use danog\MadelineProto\Magic;
use danog\MadelineProto\MTProto;
use danog\MadelineProto\TON\API as TONAPI;
use danog\MadelineProto\TON\APIFactory as TONAPIFactory;
@ -22,83 +24,43 @@ use danog\MadelineProto\TON\Lite;
require 'vendor/autoload.php';
$param = 1;
\danog\MadelineProto\Magic::classExists();
\danog\MadelineProto\Logger::constructor($param);
$logger = \danog\MadelineProto\Logger::$default;
Magic::classExists();
Logger::constructor(1);
$logger = Logger::$default;
\set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
\danog\MadelineProto\Logger::log('Copying readme...', \danog\MadelineProto\Logger::NOTICE);
$logger->logger('Merging constructor localization...', Logger::NOTICE);
mergeExtracted();
\file_put_contents('docs/docs/index.md', '---
title: MadelineProto documentation
description: PHP client/server for the telegram MTProto protocol (a better tg-cli)
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
'.\str_replace('<img', '<amp-img', \file_get_contents('README.md')));
$logger->logger('Loading schemas...', Logger::NOTICE);
$schemas = loadSchemas();
$layer_list = '';
$tempRes = \glob("$d/schemas/TL_telegram_*");
$res = [];
foreach ($tempRes as $file) {
$layer = \preg_replace(['/.*telegram_v/', '/\..+/'], '', $file);
$res[$layer] = $file;
}
\ksort($res);
foreach (\array_slice($res, 0, -1) as $layer => $file) {
$layer = "v$layer";
$docs[] = [
'tl_schema' => ['telegram' => $file],
'title' => 'MadelineProto API documentation (layer '.$layer.')',
'description' => 'MadelineProto API documentation (layer '.$layer.')',
'output_dir' => "$d/docs/old_docs/API_docs_".$layer,
'readme' => true,
];
$layer_list .= '[Layer '.$layer.'](API_docs_'.$layer.'/)
';
}
$layer = \array_keys($res);
$layer = \end($layer);
$logger->logger('Upgrading layer...', Logger::NOTICE);
$layer = maxLayer($schemas);
layerUpgrade($layer);
$logger->logger('Initing docs...', Logger::NOTICE);
$docs = [
/* [
'tl_schema' => ['td' => "$d/schemas/TL_td.tl"],
'title' => 'MadelineProto API documentation (td-lib)',
'description' => 'MadelineProto API documentation (td-lib)',
'output_dir' => "$d/docs/docs/TD_docs",
'readme' => false,
'td' => true,
],*/
[
'tl_schema' => ['mtproto' => "$d/schemas/TL_mtproto_v1.json"],
'tl_schema' => ['mtproto' => "$d/schemas/TL_mtproto_v1.tl"],
'title' => 'MadelineProto API documentation (mtproto)',
'description' => 'MadelineProto API documentation (mtproto)',
'output_dir' => "$d/docs/docs/MTProto_docs",
'template' => "$d/docs/template",
'readme' => false,
],
[
'tl_schema' => ['telegram' => "$d/schemas/TL_telegram_v$layer.tl", 'calls' => "$d/schemas/TL_calls.tl", 'secret' => "$d/schemas/TL_secret.tl", 'td' => "$d/schemas/TL_td.tl"],
'tl_schema' => ['telegram' => "$d/schemas/TL_telegram_v$layer.tl", 'secret' => "$d/schemas/TL_secret.tl", 'td' => "$d/schemas/TL_td.tl"],
'title' => "MadelineProto API documentation (layer $layer)",
'description' => "MadelineProto API documentation (layer $layer)",
'output_dir' => "$d/docs/docs/API_docs",
'template' => "$d/docs/template",
'readme' => false,
],
];
$docs = \array_merge($docs, initDocs($schemas));
$doc = \file_get_contents('docs/docs/docs/USING_METHODS.md');
$doc = \preg_replace('|here \(layer \d+\)|', "here (layer $layer)", $doc);
\file_put_contents('docs/docs/docs/USING_METHODS.md', $doc);
\file_put_contents('docs/old_docs/README.md', '---
title: Documentations of old mtproto layers
description: Documentation of old mtproto layers
---
# Documentation of old mtproto layers
'.$layer_list);
$logger->logger('Creating annotations...', Logger::NOTICE);
$doc = new \danog\MadelineProto\AnnotationsBuilder(
$logger,
$docs[1],
@ -112,17 +74,15 @@ $doc = new \danog\MadelineProto\AnnotationsBuilder(
);
$doc->mkAnnotations();
$ton = [
'tl_schema' => [
'lite_api' => "$d/schemas/TON/lite_api.tl",
'ton_api' => "$d/schemas/TON/ton_api.tl",
//'tonlib_api' => "$d/schemas/TON/tonlib_api.tl",
]
];
$doc = new \danog\MadelineProto\AnnotationsBuilder(
$logger,
$ton,
[
'tl_schema' => [
'lite_api' => "$d/schemas/TON/lite_api.tl",
'ton_api' => "$d/schemas/TON/ton_api.tl",
//'tonlib_api' => "$d/schemas/TON/tonlib_api.tl",
]
],
\dirname(__FILE__).'/../src/danog/MadelineProto/TON/InternalDoc.php',
[
'API' => TONAPI::class,
@ -132,6 +92,10 @@ $doc = new \danog\MadelineProto\AnnotationsBuilder(
'danog\\MadelineProto\\TON'
);
$doc->mkAnnotations();
$logger->logger('Creating docs...', Logger::NOTICE);
foreach ($docs as $settings) {
$doc = new \danog\MadelineProto\DocsBuilder($logger, $settings);
$doc->mkDocs();
@ -139,6 +103,7 @@ foreach ($docs as $settings) {
\chdir(__DIR__.'/..');
$logger->logger('Fixing readme...', Logger::NOTICE);
$orderedfiles = [];
$order = [
'CREATING_A_CLIENT',
@ -228,6 +193,7 @@ foreach ($orderedfiles as $key => $filename) {
}
}
$logger->logger('Fixing readme...', Logger::NOTICE);
$readme = \explode('## ', \file_get_contents('README.md'));
foreach ($readme as &$section) {
if (\explode("\n", $section)[0] === 'Documentation') {

View File

@ -0,0 +1,46 @@
<?php
/**
* Upgrade layer number.
*
* @param integer $layer Layer number
*
* @return void
*/
function layerUpgrade(int $layer): void
{
$doc = \file_get_contents('docs/docs/docs/USING_METHODS.md');
$doc = \preg_replace('|here \(layer \d+\)|', "here (layer $layer)", $doc);
\file_put_contents('docs/docs/docs/USING_METHODS.md', $doc);
\array_map(unlink::class, \glob('src/danog/MadelineProto/*.tl'));
foreach (['TL_mtproto_v1', "TL_telegram_v$layer", 'TL_secret', 'TL_botAPI'] as $schema) {
\copy("schemas/$schema.tl", "src/danog/MadelineProto/$schema.tl");
}
$doc = \file_get_contents('src/danog/MadelineProto/MTProto.php');
\preg_match("/'layer' => (\d+)/", $doc, $matches);
$prevLayer = (int) $matches[1];
if ($prevLayer === $layer) {
return;
}
\preg_match_all("/const V = (\d+)/", $doc, $matches);
$prevVersion = $matches[1][1];
$version = $prevVersion + 1;
$doc = \str_replace(
[
"'layer' => $prevLayer",
"TL_telegram_$prevLayer",
"const V = $prevVersion"
],
[
"'layer' => $layer",
"TL_telegram_$layer",
"const V = $version"
],
$doc
);
\file_put_contents('src/danog/MadelineProto/MTProto.php', $doc);
}

View File

@ -0,0 +1,25 @@
<?php
use danog\MadelineProto\Lang;
/**
* Merge extracted docs.
*
* @return void
*/
function mergeExtracted(): void
{
foreach (\json_decode(\file_get_contents('extracted.json'), true) as $key => $value) {
$key = \preg_replace(['|flags\.\d+[?]|', '/Vector[<].*/'], ['', 'Vector t'], $key);
$key = \str_replace('param_hash_type_int', 'param_hash_type_Vector t', $key);
Lang::$lang['en'][$key] = $value;
}
foreach (Lang::$lang['en'] as $key => $value) {
if ($value === '') {
unset(Lang::$lang['en'][$key]);
}
}
foreach (\json_decode(\file_get_contents('docs/template/disallow.json'), true) as $key => $value) {
Lang::$lang['en'][$key] = $value;
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* Load schema file names.
*
* @return array
*/
function loadSchemas(): array
{
$res = [];
foreach (\glob(\getcwd().'/schemas/TL_telegram_*') as $file) {
\preg_match("/telegram_v(\d+)/", $file, $matches);
$res[$matches[1]] = $file;
}
\ksort($res);
return $res;
}
/**
* Return max available layer number.
*
* @param array $schemas Scheme array
*
* @return integer
*/
function maxLayer(array $schemas): int
{
$schemas = \array_keys($schemas);
return \end($schemas);
}
/**
* Init docs.
*
* @param array $layers Scheme array
*
* @return array Documentation information for old docs
*/
function initDocs(array $layers): array
{
$docs = [];
$layer_list = '';
foreach (\array_slice($layers, 0, -1) as $layer => $file) {
$layer = "v$layer";
$docs[] = [
'tl_schema' => ['telegram' => $file],
'title' => 'MadelineProto API documentation (layer '.$layer.')',
'description' => 'MadelineProto API documentation (layer '.$layer.')',
'output_dir' => \getcwd()."/docs/old_docs/API_docs_".$layer,
'template' => \getcwd()."/docs/template",
'readme' => true,
];
$layer_list .= "[Layer $layer](API_docs_$layer/) \n";
}
\file_put_contents('docs/old_docs/README.md', '---
title: Documentation of old mtproto layers
description: Documentation of old mtproto layers
---
# Documentation of old mtproto layers
'.$layer_list);
return $docs;
}

View File

@ -1,16 +0,0 @@
<?php
require 'vendor/autoload.php';
use danog\MadelineProto\DocsBuilder;
use danog\MadelineProto\Lang;
foreach (\json_decode(\file_get_contents('extracted.json'), true) as $key => $value) {
$key = \preg_replace(['|flags\.\d+[?]|', '|[<]|', '|[>]|'], ['', ' ', ''], $key);
Lang::$lang['en'][$key] = $value;
}
foreach (Lang::$lang['en'] as $key => $value) {
if ($value === '') {
unset(Lang::$lang['en'][$key]);
}
}
DocsBuilder::addToLang($key, $value, true);

View File

@ -47,8 +47,8 @@ foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryI
}
$filename = 'README.md';
$new = \str_replace($findDocs, $replaceDocs, $old = \file_get_contents($filename));
do {
\file_put_contents($filename, $new);
$new = \str_replace($findDocs, $replaceDocs, $old = \file_get_contents($filename));
do {
\file_put_contents($filename, $new);
$new = \str_replace($findDocs, $replaceDocs, $old = \file_get_contents($filename));
} while ($old !== $new);
} while ($old !== $new);