diff --git a/packages/client/src/client.ts b/packages/client/src/client.ts index 0b2b56c7..5b3dd794 100644 --- a/packages/client/src/client.ts +++ b/packages/client/src/client.ts @@ -242,11 +242,11 @@ import { getUsers } from './methods/users/get-users.js' import { iterProfilePhotos } from './methods/users/iter-profile-photos.js' import { resolvePeer } from './methods/users/resolve-peer.js' import { resolvePeerMany } from './methods/users/resolve-peer-many.js' -import { setEmojiStatus } from './methods/users/set-emoji-status.js' import { setGlobalTtl } from './methods/users/set-global-ttl.js' +import { setMyEmojiStatus } from './methods/users/set-my-emoji-status.js' +import { setMyProfilePhoto } from './methods/users/set-my-profile-photo.js' +import { setMyUsername } from './methods/users/set-my-username.js' import { setOffline } from './methods/users/set-offline.js' -import { setProfilePhoto } from './methods/users/set-profile-photo.js' -import { setUsername } from './methods/users/set-username.js' import { unblockUser } from './methods/users/unblock-user.js' import { updateProfile } from './methods/users/update-profile.js' import { Conversation } from './types/conversation.js' @@ -365,6 +365,14 @@ interface TelegramClientOptions extends Omit - /** - * Set an emoji status for the current user - * - * **Available**: 👤 users only - * - * @param emoji Custom emoji ID or `null` to remove the emoji - */ - setEmojiStatus( - emoji: tl.Long | null, - params?: { - /** - * Date when the emoji status should expire (only if `emoji` is not `null`) - */ - until?: number | Date - }, - ): Promise /** * Changes the current default value of the Time-To-Live setting, * applied to all new chats. @@ -5154,21 +5146,29 @@ export interface TelegramClient extends BaseTelegramClient { */ setGlobalTtl(period: number): Promise /** - * Change user status to offline or online + * Set an emoji status for the current user * * **Available**: 👤 users only * - * @param [offline=true] Whether the user is currently offline + * @param emoji Custom emoji ID or `null` to remove the emoji */ - setOffline(offline?: boolean): Promise + setMyEmojiStatus( + emoji: tl.Long | null, + params?: { + /** + * Date when the emoji status should expire (only if `emoji` is not `null`) + */ + until?: number | Date + }, + ): Promise /** - * Set a new profile photo or video. + * Set a new profile photo or video for the current user. * * You can also pass a file ID or an InputPhoto to re-use existing photo. * **Available**: ✅ both users and bots * */ - setProfilePhoto(params: { + setMyProfilePhoto(params: { /** Media type (photo or video) */ type: 'photo' | 'video' /** Input media file */ @@ -5186,7 +5186,15 @@ export interface TelegramClient extends BaseTelegramClient { * * @param username New username (5-32 chars, allowed chars: `a-zA-Z0-9_`), or `null` to remove */ - setUsername(username: string | null): Promise + setMyUsername(username: string | null): Promise + /** + * Change user status to offline or online + * + * **Available**: 👤 users only + * + * @param [offline=true] Whether the user is currently offline + */ + setOffline(offline?: boolean): Promise /** * Unblock a user * @@ -5238,6 +5246,7 @@ export class TelegramClient extends BaseTelegramClient { super(opts) /* eslint-enable @typescript-eslint/no-unsafe-call */ this._disableUpdatesManager = opts.disableUpdatesManager ?? false + const skipConversationUpdates = opts.skipConversationUpdates ?? true if (!opts.disableUpdates && !opts.disableUpdatesManager) { const { messageGroupingInterval, ...managerParams } = opts.updates ?? {} @@ -5247,7 +5256,8 @@ export class TelegramClient extends BaseTelegramClient { onUpdate: makeParsedUpdateHandler({ messageGroupingInterval, onUpdate: (update) => { - Conversation.handleUpdate(this, update) + if (Conversation.handleUpdate(this, update) && skipConversationUpdates) return + this.emit('update', update) this.emit(update.name, update.data) }, @@ -6214,26 +6224,26 @@ TelegramClient.prototype.resolvePeer = function (...args) { return resolvePeer(this, ...args) } -TelegramClient.prototype.setEmojiStatus = function (...args) { - return setEmojiStatus(this, ...args) -} - TelegramClient.prototype.setGlobalTtl = function (...args) { return setGlobalTtl(this, ...args) } +TelegramClient.prototype.setMyEmojiStatus = function (...args) { + return setMyEmojiStatus(this, ...args) +} + +TelegramClient.prototype.setMyProfilePhoto = function (...args) { + return setMyProfilePhoto(this, ...args) +} + +TelegramClient.prototype.setMyUsername = function (...args) { + return setMyUsername(this, ...args) +} + TelegramClient.prototype.setOffline = function (...args) { return setOffline(this, ...args) } -TelegramClient.prototype.setProfilePhoto = function (...args) { - return setProfilePhoto(this, ...args) -} - -TelegramClient.prototype.setUsername = function (...args) { - return setUsername(this, ...args) -} - TelegramClient.prototype.unblockUser = function (...args) { return unblockUser(this, ...args) } diff --git a/packages/client/src/methods/users/set-emoji-status.ts b/packages/client/src/methods/users/set-my-emoji-status.ts similarity index 96% rename from packages/client/src/methods/users/set-emoji-status.ts rename to packages/client/src/methods/users/set-my-emoji-status.ts index 3322b989..0294b4f9 100644 --- a/packages/client/src/methods/users/set-emoji-status.ts +++ b/packages/client/src/methods/users/set-my-emoji-status.ts @@ -7,7 +7,7 @@ import { assertTrue, normalizeDate } from '../../utils/index.js' * * @param emoji Custom emoji ID or `null` to remove the emoji */ -export async function setEmojiStatus( +export async function setMyEmojiStatus( client: BaseTelegramClient, emoji: tl.Long | null, params?: { diff --git a/packages/client/src/methods/users/set-profile-photo.ts b/packages/client/src/methods/users/set-my-profile-photo.ts similarity index 94% rename from packages/client/src/methods/users/set-profile-photo.ts rename to packages/client/src/methods/users/set-my-profile-photo.ts index 610980a7..b88fe373 100644 --- a/packages/client/src/methods/users/set-profile-photo.ts +++ b/packages/client/src/methods/users/set-my-profile-photo.ts @@ -5,11 +5,11 @@ import { InputFileLike, Photo } from '../../types/index.js' import { _normalizeInputFile } from '../files/normalize-input-file.js' /** - * Set a new profile photo or video. + * Set a new profile photo or video for the current user. * * You can also pass a file ID or an InputPhoto to re-use existing photo. */ -export async function setProfilePhoto( +export async function setMyProfilePhoto( client: BaseTelegramClient, params: { /** Media type (photo or video) */ diff --git a/packages/client/src/methods/users/set-username.ts b/packages/client/src/methods/users/set-my-username.ts similarity index 85% rename from packages/client/src/methods/users/set-username.ts rename to packages/client/src/methods/users/set-my-username.ts index f2a58c41..e738d198 100644 --- a/packages/client/src/methods/users/set-username.ts +++ b/packages/client/src/methods/users/set-my-username.ts @@ -11,7 +11,7 @@ import { getAuthState } from '../auth/_state.js' * * @param username New username (5-32 chars, allowed chars: `a-zA-Z0-9_`), or `null` to remove */ -export async function setUsername(client: BaseTelegramClient, username: string | null): Promise { +export async function setMyUsername(client: BaseTelegramClient, username: string | null): Promise { if (username === null) username = '' const res = await client.call({