build(deps): bumped prettier to 3.0.3
This commit is contained in:
parent
75021648eb
commit
a6726ccb40
55 changed files with 271 additions and 82 deletions
|
@ -44,7 +44,7 @@
|
|||
"mocha": "10.2.0",
|
||||
"node-forge": "1.3.1",
|
||||
"nyc": "15.1.0",
|
||||
"prettier": "2.8.8",
|
||||
"prettier": "3.0.3",
|
||||
"rimraf": "5.0.1",
|
||||
"semver": "7.5.1",
|
||||
"ts-node": "10.9.1",
|
||||
|
|
|
@ -42,7 +42,9 @@ export async function hideMyStoriesViews(
|
|||
|
||||
const upd = res.updates.find(hasValueAtKey('_', 'updateStoriesStealthMode'))
|
||||
|
||||
if (!upd) { throw new MtTypeAssertionError('hideMyStoriesViews (@ res.updates[*])', 'updateStoriesStealthMode', 'none') }
|
||||
if (!upd) {
|
||||
throw new MtTypeAssertionError('hideMyStoriesViews (@ res.updates[*])', 'updateStoriesStealthMode', 'none')
|
||||
}
|
||||
|
||||
return new StoriesStealthMode(upd.stealthMode)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,11 @@ import { PeersIndex, User } from '../peers'
|
|||
* Game high score
|
||||
*/
|
||||
export class GameHighScore {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawHighScore, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawHighScore,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
private _user?: User
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,10 @@ export class Conversation {
|
|||
|
||||
private _pendingRead: Map<number, QueuedHandler<void>> = new Map()
|
||||
|
||||
constructor(readonly client: TelegramClient, readonly chat: InputPeerLike) {
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly chat: InputPeerLike,
|
||||
) {
|
||||
this._onNewMessage = this._onNewMessage.bind(this)
|
||||
this._onEditMessage = this._onEditMessage.bind(this)
|
||||
this._onHistoryRead = this._onHistoryRead.bind(this)
|
||||
|
|
|
@ -11,7 +11,11 @@ export class MtPeerNotFoundError extends MtcuteError {}
|
|||
* Could not find a message by the provided information
|
||||
*/
|
||||
export class MtMessageNotFoundError extends MtcuteError {
|
||||
constructor(readonly peerId: number, readonly messageId: number, readonly context?: string) {
|
||||
constructor(
|
||||
readonly peerId: number,
|
||||
readonly messageId: number,
|
||||
readonly context?: string,
|
||||
) {
|
||||
super(`Message${context ? ' ' + context : ''} ${messageId} not found in ${peerId}`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ const STUB_LOCATION = () => {
|
|||
* > To be sure, check `isDownloadable` property.
|
||||
*/
|
||||
export class WebDocument extends FileLocation {
|
||||
constructor(client: TelegramClient, readonly raw: tl.TypeWebDocument) {
|
||||
constructor(
|
||||
client: TelegramClient,
|
||||
readonly raw: tl.TypeWebDocument,
|
||||
) {
|
||||
super(
|
||||
client,
|
||||
raw._ === 'webDocument' ?
|
||||
|
|
|
@ -15,7 +15,11 @@ export class Audio extends RawDocument {
|
|||
return tdFileId.FileType.Audio
|
||||
}
|
||||
|
||||
constructor(client: TelegramClient, doc: tl.RawDocument, readonly attr: tl.RawDocumentAttributeAudio) {
|
||||
constructor(
|
||||
client: TelegramClient,
|
||||
doc: tl.RawDocument,
|
||||
readonly attr: tl.RawDocumentAttributeAudio,
|
||||
) {
|
||||
super(client, doc)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@ import { Thumbnail } from './thumbnail'
|
|||
export abstract class RawDocument extends FileLocation {
|
||||
abstract type: string
|
||||
|
||||
constructor(client: TelegramClient, readonly raw: tl.RawDocument) {
|
||||
constructor(
|
||||
client: TelegramClient,
|
||||
readonly raw: tl.RawDocument,
|
||||
) {
|
||||
super(
|
||||
client,
|
||||
{
|
||||
|
|
|
@ -8,7 +8,10 @@ import { Video } from './video'
|
|||
export class Game {
|
||||
readonly type = 'game' as const
|
||||
|
||||
constructor(readonly client: TelegramClient, readonly game: tl.RawGame) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly game: tl.RawGame,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Unique identifier of the game.
|
||||
|
|
|
@ -15,7 +15,10 @@ import { Thumbnail } from './thumbnail'
|
|||
export type InvoiceExtendedMediaState = 'none' | 'preview' | 'full'
|
||||
|
||||
export class InvoiceExtendedMediaPreview {
|
||||
constructor(public readonly client: TelegramClient, public readonly raw: tl.RawMessageExtendedMediaPreview) {}
|
||||
constructor(
|
||||
public readonly client: TelegramClient,
|
||||
public readonly raw: tl.RawMessageExtendedMediaPreview,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Width of the preview, in pixels (if available, else 0)
|
||||
|
@ -55,7 +58,10 @@ export class InvoiceExtendedMediaPreview {
|
|||
export class Invoice {
|
||||
readonly type = 'invoice' as const
|
||||
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawMessageMediaInvoice) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawMessageMediaInvoice,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Whether the shipping address was requested
|
||||
|
|
|
@ -8,7 +8,10 @@ import { FileLocation } from '../files'
|
|||
* A point on the map
|
||||
*/
|
||||
export class RawLocation {
|
||||
constructor(readonly client: TelegramClient, readonly geo: tl.RawGeoPoint) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly geo: tl.RawGeoPoint,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Geo point latitude
|
||||
|
@ -107,7 +110,10 @@ export class Location extends RawLocation {
|
|||
export class LiveLocation extends RawLocation {
|
||||
readonly type = 'live_location' as const
|
||||
|
||||
constructor(client: TelegramClient, readonly live: tl.RawMessageMediaGeoLive) {
|
||||
constructor(
|
||||
client: TelegramClient,
|
||||
readonly live: tl.RawMessageMediaGeoLive,
|
||||
) {
|
||||
super(client, live.geo as tl.RawGeoPoint)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,11 @@ export class Photo extends FileLocation {
|
|||
|
||||
private _bestSize?: tl.RawPhotoSize | tl.RawPhotoSizeProgressive
|
||||
|
||||
constructor(client: TelegramClient, readonly raw: tl.RawPhoto, readonly media?: tl.RawMessageMediaPhoto) {
|
||||
constructor(
|
||||
client: TelegramClient,
|
||||
readonly raw: tl.RawPhoto,
|
||||
readonly media?: tl.RawMessageMediaPhoto,
|
||||
) {
|
||||
const location = {
|
||||
_: 'inputPhotoFileLocation',
|
||||
id: raw.id,
|
||||
|
|
|
@ -30,7 +30,10 @@ export interface VenueSource {
|
|||
export class Venue {
|
||||
readonly type = 'venue' as const
|
||||
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawMessageMediaVenue) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawMessageMediaVenue,
|
||||
) {}
|
||||
|
||||
private _location?: Location
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,11 @@ export class Voice extends RawDocument {
|
|||
return tdFileId.FileType.VoiceNote
|
||||
}
|
||||
|
||||
constructor(client: TelegramClient, doc: tl.RawDocument, readonly attr: tl.RawDocumentAttributeAudio) {
|
||||
constructor(
|
||||
client: TelegramClient,
|
||||
doc: tl.RawDocument,
|
||||
readonly attr: tl.RawDocumentAttributeAudio,
|
||||
) {
|
||||
super(client, doc)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,10 @@ import { Photo } from './photo'
|
|||
export class WebPage {
|
||||
readonly type = 'web_page' as const
|
||||
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawWebPage) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawWebPage,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Unique ID of the preview
|
||||
|
|
|
@ -8,7 +8,10 @@ import { MessageEntity } from './message-entity'
|
|||
* A draft message
|
||||
*/
|
||||
export class DraftMessage {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawDraftMessage) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawDraftMessage,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Text of the draft message
|
||||
|
|
|
@ -56,7 +56,10 @@ export type MessageEntityKind = MessageEntityParams['kind']
|
|||
* One special entity in a text message (like mention, hashtag, URL, etc.)
|
||||
*/
|
||||
export class MessageEntity {
|
||||
constructor(readonly raw: tl.TypeMessageEntity, readonly _text?: string) {}
|
||||
constructor(
|
||||
readonly raw: tl.TypeMessageEntity,
|
||||
readonly _text?: string,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Offset in UTF-16 code units to the start of the entity.
|
||||
|
|
|
@ -102,7 +102,10 @@ export class StickerSet {
|
|||
*/
|
||||
readonly isFull: boolean
|
||||
|
||||
constructor(readonly client: TelegramClient, raw: tl.TypeStickerSet | tl.messages.TypeStickerSet) {
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
raw: tl.TypeStickerSet | tl.messages.TypeStickerSet,
|
||||
) {
|
||||
if (raw._ === 'messages.stickerSet') {
|
||||
this.full = raw
|
||||
this.brief = raw.set
|
||||
|
|
|
@ -12,7 +12,10 @@ export class TakeoutSession {
|
|||
*/
|
||||
readonly id: tl.Long
|
||||
|
||||
constructor(readonly client: TelegramClient, session: tl.account.RawTakeout) {
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
session: tl.account.RawTakeout,
|
||||
) {
|
||||
this.id = session.id
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,10 @@ export class FormattedString<T extends string = never> {
|
|||
* @param value Value that the string holds
|
||||
* @param mode Name of the parse mode used
|
||||
*/
|
||||
constructor(readonly value: string, readonly mode?: T) {}
|
||||
constructor(
|
||||
readonly value: string,
|
||||
readonly mode?: T,
|
||||
) {}
|
||||
|
||||
toString(): string {
|
||||
return this.value
|
||||
|
|
|
@ -6,7 +6,11 @@ import { PeersIndex } from './peers-index'
|
|||
import { User } from './user'
|
||||
|
||||
export class ChatInviteLinkMember {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawChatInviteImporter, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawChatInviteImporter,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
private _user?: User
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,11 @@ import { User } from './user'
|
|||
export class ChatInviteLink {
|
||||
raw: tl.RawChatInviteExported
|
||||
|
||||
constructor(readonly client: TelegramClient, raw: tl.TypeExportedChatInvite, readonly _peers?: PeersIndex) {
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
raw: tl.TypeExportedChatInvite,
|
||||
readonly _peers?: PeersIndex,
|
||||
) {
|
||||
assertTypeIsNot('ChatInviteLink', raw, 'chatInvitePublicJoinRequests')
|
||||
this.raw = raw
|
||||
}
|
||||
|
|
|
@ -8,7 +8,10 @@ import { Location } from '../media'
|
|||
* Geolocation of a supergroup
|
||||
*/
|
||||
export class ChatLocation {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawChannelLocation) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawChannelLocation,
|
||||
) {}
|
||||
|
||||
private _location?: Location
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,10 @@ export class User {
|
|||
*/
|
||||
readonly raw: tl.RawUser
|
||||
|
||||
constructor(readonly client: TelegramClient, user: tl.TypeUser) {
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
user: tl.TypeUser,
|
||||
) {
|
||||
assertTypeIs('User#init', user, 'user')
|
||||
|
||||
this.raw = user
|
||||
|
|
|
@ -9,7 +9,10 @@ import { StoriesStealthMode } from './stealth-mode'
|
|||
* Returned by {@link TelegramClient.getAllStories}
|
||||
*/
|
||||
export class AllStories {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.stories.RawAllStories) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.stories.RawAllStories,
|
||||
) {}
|
||||
|
||||
readonly _peers = PeersIndex.from(this.raw)
|
||||
|
||||
|
|
|
@ -8,7 +8,11 @@ import { PeersIndex, User } from '../peers'
|
|||
* Information about a user who is boosting a channel
|
||||
*/
|
||||
export class Booster {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawBooster, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawBooster,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Date when this boost will automatically expire.
|
||||
|
|
|
@ -5,7 +5,10 @@ import { TelegramClient } from '../../../client'
|
|||
export abstract class StoryInteractiveArea {
|
||||
abstract type: string
|
||||
|
||||
constructor(readonly client: TelegramClient, readonly raw: Exclude<tl.TypeMediaArea, tl.RawInputMediaAreaVenue>) {
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: Exclude<tl.TypeMediaArea, tl.RawInputMediaAreaVenue>,
|
||||
) {
|
||||
this.raw = raw
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ import { StoryInteractiveArea } from './base'
|
|||
export class StoryInteractiveLocation extends StoryInteractiveArea {
|
||||
readonly type = 'location' as const
|
||||
|
||||
constructor(client: TelegramClient, readonly raw: tl.RawMediaAreaGeoPoint) {
|
||||
constructor(
|
||||
client: TelegramClient,
|
||||
readonly raw: tl.RawMediaAreaGeoPoint,
|
||||
) {
|
||||
super(client, raw)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ import { StoryInteractiveArea } from './base'
|
|||
export class StoryInteractiveReaction extends StoryInteractiveArea {
|
||||
readonly type = 'reaction' as const
|
||||
|
||||
constructor(client: TelegramClient, readonly raw: tl.RawMediaAreaSuggestedReaction) {
|
||||
constructor(
|
||||
client: TelegramClient,
|
||||
readonly raw: tl.RawMediaAreaSuggestedReaction,
|
||||
) {
|
||||
super(client, raw)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ import { StoryInteractiveArea } from './base'
|
|||
export class StoryInteractiveVenue extends StoryInteractiveArea {
|
||||
readonly type = 'venue' as const
|
||||
|
||||
constructor(client: TelegramClient, readonly raw: tl.RawMediaAreaVenue) {
|
||||
constructor(
|
||||
client: TelegramClient,
|
||||
readonly raw: tl.RawMediaAreaVenue,
|
||||
) {
|
||||
super(client, raw)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,11 @@ import { Chat, PeersIndex, User } from '../peers'
|
|||
import { Story } from './story'
|
||||
|
||||
export class PeerStories {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawPeerStories, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawPeerStories,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
private _peer?: User | Chat
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,11 @@ import { ReactionCount } from '../reactions/reaction-count'
|
|||
* Brief information about story views/interactions
|
||||
*/
|
||||
export class StoryInteractions {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawStoryViews, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawStoryViews,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Whether information about viewers is available.
|
||||
|
|
|
@ -9,7 +9,11 @@ import { ReactionEmoji, toReactionEmoji } from '../reactions'
|
|||
* Information about a single user who has viewed a story.
|
||||
*/
|
||||
export class StoryViewer {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawStoryView, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawStoryView,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
/** Whether this user is in current user's global blacklist */
|
||||
get isBlocked(): boolean {
|
||||
|
@ -46,7 +50,10 @@ makeInspectable(StoryViewer)
|
|||
* List of story viewers.
|
||||
*/
|
||||
export class StoryViewersList {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.stories.RawStoryViewsList) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.stories.RawStoryViewsList,
|
||||
) {}
|
||||
|
||||
readonly _peers = PeersIndex.from(this.raw)
|
||||
|
||||
|
|
|
@ -22,7 +22,11 @@ export type StoryVisibility = 'public' | 'contacts' | 'selected_contacts' | 'clo
|
|||
export type StoryMedia = Photo | Video
|
||||
|
||||
export class Story {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawStoryItem, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawStoryItem,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
/** Whether this story is pinned */
|
||||
get isPinned(): boolean {
|
||||
|
|
|
@ -11,7 +11,11 @@ import { PeersIndex, User } from '../peers'
|
|||
* interacts with the bot.
|
||||
*/
|
||||
export class BotStoppedUpdate {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateBotStopped, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawUpdateBotStopped,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* ID of the user who stopped or restarted the bot
|
||||
|
|
|
@ -5,7 +5,11 @@ import { makeInspectable } from '../../utils'
|
|||
* A story was deleted
|
||||
*/
|
||||
export class DeleteStoryUpdate {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateStory, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawUpdateStory,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
private _peer?: User | Chat
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,11 @@ import { PeersIndex, Poll } from '../'
|
|||
* polls which were sent by this bot
|
||||
*/
|
||||
export class PollUpdate {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateMessagePoll, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawUpdateMessagePoll,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Unique poll ID
|
||||
|
|
|
@ -8,7 +8,11 @@ import { assertTypeIs, makeInspectable } from '../../utils'
|
|||
* > is to store known stories IDs and compare them to the one in the update.
|
||||
*/
|
||||
export class StoryUpdate {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateStory, readonly _peers: PeersIndex) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawUpdateStory,
|
||||
readonly _peers: PeersIndex,
|
||||
) {}
|
||||
|
||||
private _peer?: User | Chat
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,10 @@ import { User, UserParsedStatus, UserStatus } from '../'
|
|||
* User status has changed
|
||||
*/
|
||||
export class UserStatusUpdate {
|
||||
constructor(readonly client: TelegramClient, readonly raw: tl.RawUpdateUserStatus) {}
|
||||
constructor(
|
||||
readonly client: TelegramClient,
|
||||
readonly raw: tl.RawUpdateUserStatus,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* ID of the user whose status has updated
|
||||
|
|
|
@ -4,7 +4,10 @@ export class RpsMeter {
|
|||
_hits: Deque<bigint>
|
||||
time: bigint
|
||||
|
||||
constructor(readonly size = 500, time = 5000) {
|
||||
constructor(
|
||||
readonly size = 500,
|
||||
time = 5000,
|
||||
) {
|
||||
if (typeof process === 'undefined' || !process.hrtime.bigint) {
|
||||
throw new Error('RPS meter is not supported on this platform')
|
||||
}
|
||||
|
|
|
@ -15,7 +15,11 @@ export class AuthKey {
|
|||
clientSalt!: Buffer
|
||||
serverSalt!: Buffer
|
||||
|
||||
constructor(readonly _crypto: ICryptoProvider, readonly log: Logger, readonly _readerMap: TlReaderMap) {}
|
||||
constructor(
|
||||
readonly _crypto: ICryptoProvider,
|
||||
readonly log: Logger,
|
||||
readonly _readerMap: TlReaderMap,
|
||||
) {}
|
||||
|
||||
match(keyId: Buffer): boolean {
|
||||
return this.ready && buffersEqual(keyId, this.id)
|
||||
|
|
|
@ -12,7 +12,12 @@ export class MultiSessionConnection extends EventEmitter {
|
|||
readonly _sessions: MtprotoSession[]
|
||||
private _enforcePfs = false
|
||||
|
||||
constructor(readonly params: SessionConnectionParams, private _count: number, log: Logger, logPrefix = '') {
|
||||
constructor(
|
||||
readonly params: SessionConnectionParams,
|
||||
private _count: number,
|
||||
log: Logger,
|
||||
logPrefix = '',
|
||||
) {
|
||||
super()
|
||||
this._log = log.create('multi')
|
||||
if (logPrefix) this._log.prefix = `[${logPrefix}] `
|
||||
|
|
|
@ -365,7 +365,10 @@ export class NetworkManager {
|
|||
private _lastUpdateTime = 0
|
||||
private _updateHandler: (upd: tl.TypeUpdates) => void = () => {}
|
||||
|
||||
constructor(readonly params: NetworkManagerParams & NetworkManagerExtraParams, readonly config: ConfigManager) {
|
||||
constructor(
|
||||
readonly params: NetworkManagerParams & NetworkManagerExtraParams,
|
||||
readonly config: ConfigManager,
|
||||
) {
|
||||
let deviceModel = 'mtcute on '
|
||||
let appVersion = 'unknown'
|
||||
if (typeof process !== 'undefined' && typeof require !== 'undefined') {
|
||||
|
|
|
@ -50,7 +50,10 @@ export abstract class PersistentConnection extends EventEmitter {
|
|||
|
||||
protected abstract onMessage(data: Buffer): void
|
||||
|
||||
protected constructor(params: PersistentConnectionParams, readonly log: Logger) {
|
||||
protected constructor(
|
||||
params: PersistentConnectionParams,
|
||||
readonly log: Logger,
|
||||
) {
|
||||
super()
|
||||
this.params = params
|
||||
this.changeTransport(params.transportFactory)
|
||||
|
|
|
@ -73,7 +73,10 @@ export class SessionConnection extends PersistentConnection {
|
|||
private _readerMap: TlReaderMap
|
||||
private _writerMap: TlWriterMap
|
||||
|
||||
constructor(params: SessionConnectionParams, readonly _session: MtprotoSession) {
|
||||
constructor(
|
||||
params: SessionConnectionParams,
|
||||
readonly _session: MtprotoSession,
|
||||
) {
|
||||
super(params, _session.log.create('conn'))
|
||||
this._flushTimer.onTimeout(this._flush.bind(this))
|
||||
|
||||
|
@ -433,11 +436,14 @@ export class SessionConnection extends PersistentConnection {
|
|||
this.onConnectionUsable()
|
||||
|
||||
// set a timeout to update temp auth key in advance to avoid interruption
|
||||
this._pfsUpdateTimeout = setTimeout(() => {
|
||||
this._pfsUpdateTimeout = setTimeout(
|
||||
() => {
|
||||
this._pfsUpdateTimeout = undefined
|
||||
this.log.debug('temp key is expiring soon')
|
||||
this._authorizePfs(true)
|
||||
}, (TEMP_AUTH_KEY_EXPIRY - 60) * 1000)
|
||||
},
|
||||
(TEMP_AUTH_KEY_EXPIRY - 60) * 1000,
|
||||
)
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
this.log.error('PFS Authorization error: %s', err.message)
|
||||
|
|
|
@ -9,8 +9,9 @@ const b64urlAvailable = Buffer.isEncoding('base64url')
|
|||
* @param arr Typed array to convert
|
||||
*/
|
||||
export function typedArrayToBuffer(arr: NodeJS.TypedArray): Buffer {
|
||||
return ArrayBuffer.isView(arr) ? // To avoid a copy, use the typed array's underlying ArrayBuffer to back
|
||||
// To avoid a copy, use the typed array's underlying ArrayBuffer to back
|
||||
// new Buffer, respecting the "view", i.e. byteOffset and byteLength
|
||||
return ArrayBuffer.isView(arr) ?
|
||||
Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength) : // Pass through all other types to `Buffer.from`
|
||||
Buffer.from(arr)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,10 @@ export class Deque<T> {
|
|||
protected _tail = 0
|
||||
protected _capacity: number
|
||||
|
||||
constructor(minCapacity = MIN_INITIAL_CAPACITY, readonly maxLength = Infinity) {
|
||||
constructor(
|
||||
minCapacity = MIN_INITIAL_CAPACITY,
|
||||
readonly maxLength = Infinity,
|
||||
) {
|
||||
let capacity = minCapacity
|
||||
|
||||
if (capacity >= MIN_INITIAL_CAPACITY) {
|
||||
|
|
|
@ -26,7 +26,11 @@ export class Logger {
|
|||
|
||||
prefix = ''
|
||||
|
||||
constructor(readonly mgr: LogManager, readonly tag: string, readonly parent: Logger = mgr) {
|
||||
constructor(
|
||||
readonly mgr: LogManager,
|
||||
readonly tag: string,
|
||||
readonly parent: Logger = mgr,
|
||||
) {
|
||||
let hash = 0
|
||||
|
||||
for (let i = 0; i < tag.length; i++) {
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
export class SortedArray<T> {
|
||||
readonly raw: T[]
|
||||
|
||||
constructor(array: T[] = [], readonly comparator: (a: T, b: T) => number) {
|
||||
constructor(
|
||||
array: T[] = [],
|
||||
readonly comparator: (a: T, b: T) => number,
|
||||
) {
|
||||
this.raw = array.sort(comparator)
|
||||
this.comparator = comparator
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ export class CallbackDataBuilder<T extends string> {
|
|||
* @param prefix Prefix for the data. Use something unique across your bot.
|
||||
* @param fields Field names in the order they will be serialized.
|
||||
*/
|
||||
constructor(public prefix: string, ...fields: T[]) {
|
||||
constructor(
|
||||
public prefix: string,
|
||||
...fields: T[]
|
||||
) {
|
||||
this._fields = fields
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,9 @@ export const chatMember: {
|
|||
* @link User.Status
|
||||
*/
|
||||
export const userStatus: {
|
||||
<T extends UserStatus>(status: T): UpdateFilter<
|
||||
<T extends UserStatus>(
|
||||
status: T,
|
||||
): UpdateFilter<
|
||||
UserStatusUpdate,
|
||||
{
|
||||
type: T
|
||||
|
|
|
@ -285,7 +285,8 @@ export class SqliteStorage implements ITelegramStorage, IStateStorage {
|
|||
|
||||
this._wal = !params?.disableWal
|
||||
|
||||
this._saveUnimportantLater = throttle(() => {
|
||||
this._saveUnimportantLater = throttle(
|
||||
() => {
|
||||
// unimportant changes are changes about cached in memory entities,
|
||||
// that don't really need to be cached right away.
|
||||
// to avoid redundant DB calls, these changes are persisted
|
||||
|
@ -301,7 +302,9 @@ export class SqliteStorage implements ITelegramStorage, IStateStorage {
|
|||
|
||||
this._updateManyPeers(items)
|
||||
this._pendingUnimportant = {}
|
||||
}, params?.unimportantSavesDelay ?? 30000)
|
||||
},
|
||||
params?.unimportantSavesDelay ?? 30000,
|
||||
)
|
||||
|
||||
this._vacuumInterval = params?.vacuumInterval ?? 300_000
|
||||
|
||||
|
|
|
@ -42,7 +42,11 @@ export class TlBinaryReader {
|
|||
* @param data Buffer to read from
|
||||
* @param start Position to start reading from
|
||||
*/
|
||||
constructor(readonly objectsMap: TlReaderMap | undefined, data: Buffer, start = 0) {
|
||||
constructor(
|
||||
readonly objectsMap: TlReaderMap | undefined,
|
||||
data: Buffer,
|
||||
start = 0,
|
||||
) {
|
||||
this.data = data
|
||||
this.pos = start
|
||||
}
|
||||
|
|
|
@ -147,7 +147,11 @@ export class TlBinaryWriter {
|
|||
* @param buffer Buffer to write to
|
||||
* @param start Position to start writing at
|
||||
*/
|
||||
constructor(readonly objectMap: TlWriterMap | undefined, buffer: Buffer, start = 0) {
|
||||
constructor(
|
||||
readonly objectMap: TlWriterMap | undefined,
|
||||
buffer: Buffer,
|
||||
start = 0,
|
||||
) {
|
||||
this.buffer = buffer
|
||||
this.pos = start
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ importers:
|
|||
specifier: 15.1.0
|
||||
version: 15.1.0
|
||||
prettier:
|
||||
specifier: 2.8.8
|
||||
version: 2.8.8
|
||||
specifier: 3.0.3
|
||||
version: 3.0.3
|
||||
rimraf:
|
||||
specifier: 5.0.1
|
||||
version: 5.0.1
|
||||
|
@ -4235,9 +4235,9 @@ packages:
|
|||
engines: {node: '>= 0.8.0'}
|
||||
dev: true
|
||||
|
||||
/prettier@2.8.8:
|
||||
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
/prettier@3.0.3:
|
||||
resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
|
|
Loading…
Reference in a new issue