feat: updated to layer 173

This commit is contained in:
alina 🌸 2024-02-04 18:28:27 +03:00
parent c18d2fe367
commit e6c7af6ed2
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
6 changed files with 52 additions and 4 deletions

View file

@ -6,6 +6,7 @@ import { makeInspectable } from '../../utils/index.js'
import { memoizeGetters } from '../../utils/memoize.js'
import { Photo } from '../media/photo.js'
import { MessageEntity } from '../messages/message-entity.js'
import { EmojiStatus } from '../reactions/emoji-status.js'
import { ChatColors } from './chat-colors.js'
import { ChatLocation } from './chat-location.js'
import { ChatPermissions } from './chat-permissions.js'
@ -620,6 +621,33 @@ export class Chat {
return new ChatColors(this.peer.id, color)
}
/**
* Chat's emoji status, if any.
*/
get emojiStatus(): EmojiStatus | null {
if (this.peer._ !== 'user' && this.peer._ !== 'channel') return null
if (!this.peer.emojiStatus || this.peer.emojiStatus._ === 'emojiStatusEmpty') return null
return new EmojiStatus(this.peer.emojiStatus)
}
/**
* Color that should be used when rendering the header of
* the user's profile
*
* If `null`, a generic header should be used instead
*/
get profileColors(): ChatColors {
const color = this.peer._ === 'user' || this.peer._ === 'channel' ? this.peer.profileColor : undefined
return new ChatColors(this.peer.id, color)
}
/** Boosts level this chat has (0 if none or is not a channel) */
get boostsLevel(): number {
return this.peer._ === 'channel' ? this.peer.level ?? 0 : 0
}
/**
* Get a {@link User} from this chat.
*

View file

@ -26,6 +26,7 @@ export interface UserParsedStatus {
status: UserStatus
lastOnline: Date | null
nextOffline: Date | null
byMe: boolean
}
export class User {
@ -167,6 +168,11 @@ export class User {
return this.raw.premium!
}
/** Whether Premium is required to contact this user */
get isPremiumRequired(): boolean {
return this.raw.contactRequirePremium!
}
/** User's or bot's first name */
get firstName(): string {
return this.raw.firstName ?? 'Deleted Account'
@ -180,6 +186,7 @@ export class User {
static parseStatus(status?: tl.TypeUserStatus, bot = false): UserParsedStatus {
let ret: UserStatus
let date: Date
let byMe = false
const us = status
@ -199,12 +206,15 @@ export class User {
break
case 'userStatusRecently':
ret = 'recently'
byMe = us.byMe!
break
case 'userStatusLastWeek':
ret = 'within_week'
byMe = us.byMe!
break
case 'userStatusLastMonth':
ret = 'within_month'
byMe = us.byMe!
break
default:
ret = 'long_time_ago'
@ -216,6 +226,7 @@ export class User {
status: ret,
lastOnline: ret === 'offline' ? date! : null,
nextOffline: ret === 'online' ? date! : null,
byMe,
}
}
@ -228,6 +239,15 @@ export class User {
return this._parsedStatus.status
}
/**
* Whether user's online status is hidden because
* we have hidden our own online status from them,
* and we don't have Premium subscription.
*/
get statusHiddenByMe(): boolean {
return this._parsedStatus.byMe
}
/**
* Last time this user was seen online.
* Only available if {@link status} is `offline`

View file

@ -2,7 +2,7 @@
TL schema and related utils used for mtcute.
Generated from TL layer **169** (last updated on 24.12.2023).
Generated from TL layer **173** (last updated on 04.02.2024).
## About

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "@mtcute/tl",
"version": "169.0.0",
"version": "173.0.0",
"description": "TL schema used for mtcute",
"main": "index.js",
"author": "Alina Sireneva <alina@tei.su>",