|
| 1 | +--- |
| 2 | +title: Account and App Settings |
| 3 | +parent: /#walkthrough |
| 4 | +walkthrough: |
| 5 | + track: user |
| 6 | + order: 25 |
| 7 | +--- |
| 8 | + |
| 9 | +Users can manage general account behavior and retrieve Telegram app information. |
| 10 | + |
| 11 | +## Updating the Profile |
| 12 | + |
| 13 | +{{ "updateProfile" |> m }} changes the current user's name or bio. |
| 14 | + |
| 15 | +```ts |
| 16 | +await client.updateProfile({ firstName: "Ada", bio: "Hello" }); |
| 17 | +``` |
| 18 | + |
| 19 | +{{ "setIsOnline" |> m }} updates the account's online status. |
| 20 | + |
| 21 | +```ts |
| 22 | +await client.setIsOnline(true); |
| 23 | +``` |
| 24 | + |
| 25 | +## Emoji Statuses |
| 26 | + |
| 27 | +{{ "setEmojiStatus" |> m }} and {{ "removeEmojiStatus" |> m }} set or remove the account's status. |
| 28 | + |
| 29 | +```ts |
| 30 | +await client.setEmojiStatus({ type: "customEmoji", customEmojiId }); |
| 31 | +await client.removeEmojiStatus(); |
| 32 | +``` |
| 33 | + |
| 34 | +Channels have corresponding {{ "setChannelEmojiStatus" |> m }} and {{ "removeChannelEmojiStatus" |> m }} methods. |
| 35 | + |
| 36 | +```ts |
| 37 | +await client.setChannelEmojiStatus(channelId, { type: "customEmoji", customEmojiId }); |
| 38 | +await client.removeChannelEmojiStatus(channelId); |
| 39 | +``` |
| 40 | + |
| 41 | +Recent statuses come from {{ "getRecentEmojiStatuses" |> m }} and can be cleared with {{ "clearRecentEmojiStatuses" |> m }}. |
| 42 | + |
| 43 | +```ts |
| 44 | +const statuses = await client.getRecentEmojiStatuses(); |
| 45 | +await client.clearRecentEmojiStatuses(); |
| 46 | +``` |
| 47 | + |
| 48 | +## Bot Permissions |
| 49 | + |
| 50 | +{{ "allowBotToSetCustomEmojiStatus" |> m }} and {{ "disallowBotToSetCustomEmojiStatus" |> m }} grant or revoke a bot's permission to change the status. |
| 51 | + |
| 52 | +```ts |
| 53 | +await client.allowBotToSetCustomEmojiStatus(botId); |
| 54 | +await client.disallowBotToSetCustomEmojiStatus(botId); |
| 55 | +``` |
| 56 | + |
| 57 | +Attachment-menu bots are managed through {{ "addBotToAttachmentsMenu" |> m }} and {{ "removeBotFromAttachmentsMenu" |> m }}. |
| 58 | + |
| 59 | +```ts |
| 60 | +await client.addBotToAttachmentsMenu(botId); |
| 61 | +await client.removeBotFromAttachmentsMenu(botId); |
| 62 | +``` |
| 63 | + |
| 64 | +## Paid Messages |
| 65 | + |
| 66 | +Exceptions for paid incoming messages are managed by {{ "allowUnpaidMessagesFromUser" |> m }} and {{ "disallowUnpaidMessagesFromUser" |> m }}. |
| 67 | + |
| 68 | +```ts |
| 69 | +await client.allowUnpaidMessagesFromUser(userId); |
| 70 | +await client.disallowUnpaidMessagesFromUser(userId); |
| 71 | +``` |
| 72 | + |
| 73 | +## New Chats |
| 74 | + |
| 75 | +{{ "getArchiveAndMuteNewChatsFromUnknownUsers" |> m }} reads the automatic-archiving setting, and {{ "setArchiveAndMuteNewChatsFromUnknownUsers" |> m }} changes it. |
| 76 | + |
| 77 | +```ts |
| 78 | +const isEnabled = await client.getArchiveAndMuteNewChatsFromUnknownUsers(); |
| 79 | +await client.setArchiveAndMuteNewChatsFromUnknownUsers(true); |
| 80 | +``` |
| 81 | + |
| 82 | +{{ "getNewChatPrivacy" |> m }} and {{ "setNewChatPrivacy" |> m }} control who can start new chats with the account. |
| 83 | + |
| 84 | +```ts |
| 85 | +const privacy = await client.getNewChatPrivacy(); |
| 86 | +await client.setNewChatPrivacy({ |
| 87 | + isNewChatFromNonPremiumUsersAllowed: true, |
| 88 | + messagePrice: 0, |
| 89 | +}); |
| 90 | +``` |
| 91 | + |
| 92 | +## Gifts |
| 93 | + |
| 94 | +Gift visibility is available through {{ "getGiftPrivacy" |> m }} and {{ "setGiftPrivacy" |> m }}. |
| 95 | + |
| 96 | +```ts |
| 97 | +const privacy = await client.getGiftPrivacy(); |
| 98 | +await client.setGiftPrivacy({ |
| 99 | + isGiftButtonDisplayed: true, |
| 100 | + isRegularGiftAccepted: true, |
| 101 | +}); |
| 102 | +``` |
| 103 | + |
| 104 | +## Sponsored Messages |
| 105 | + |
| 106 | +Sponsored messages are controlled by {{ "enableSponsoredMessages" |> m }} and {{ "disableSponsoredMessages" |> m }}. |
| 107 | + |
| 108 | +```ts |
| 109 | +await client.enableSponsoredMessages(); |
| 110 | +await client.disableSponsoredMessages(); |
| 111 | +``` |
| 112 | + |
| 113 | +## Deleting the Account |
| 114 | + |
| 115 | +Permanently delete the current account through {{ "deleteAccount" |> m }}. |
| 116 | + |
| 117 | +```ts |
| 118 | +await client.deleteAccount("No longer needed"); |
| 119 | +``` |
0 commit comments