Skip to content

Commit

Permalink
add support for Bot API v6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nitreojs committed Jun 21, 2022
1 parent ba536a5 commit 64a46af
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
13 changes: 12 additions & 1 deletion packages/puregram/src/common/attachments/sticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { inspectable } from 'inspectable'

import * as Interfaces from '../../generated/telegram-interfaces'

import { PhotoSize, MaskPosition } from '../structures'
import { PhotoSize, MaskPosition, File } from '../structures'

import { FileAttachment } from './file-attachment'

Expand Down Expand Up @@ -51,6 +51,17 @@ export class StickerAttachment extends FileAttachment<Interfaces.TelegramSticker
return this.payload.set_name
}

/** Premium animation for the sticker, if the sticker is premium */
get premiumAnimation() {
const { premium_animation } = this.payload

if (!premium_animation) {
return
}

return new File(premium_animation)
}

/** For mask stickers, the position where the mask should be placed */
get maskPosition() {
const { mask_position } = this.payload
Expand Down
27 changes: 26 additions & 1 deletion packages/puregram/src/common/structures/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@ export class Chat {
return this.payload.has_private_forwards as true | undefined
}

/**
* `true`, if users need to join the supergroup before they can send messages.
*
* Returned only in `getChat`.
*/
get joinToSendMessages() {
return this.payload.join_to_send_messages as true | undefined
}

/**
* `true`, if all users directly joining the supergroup need to be approved
* by supergroup administrators.
*
* Returned only in `getChat`.
*/
get joinByRequest() {
return this.payload.join_by_request as true | undefined
}

/**
* For supergroups, the location to which the supergroup is connected
*
Expand Down Expand Up @@ -225,13 +244,19 @@ inspectable(Chat, {
firstName: struct.firstName,
lastName: struct.lastName,
photo: struct.photo,
bio: struct.bio,
hasPrivateForwards: struct.hasPrivateForwards,
joinToSendMessages: struct.joinToSendMessages,
joinByRequest: struct.joinByRequest,
location: struct.location,
description: struct.description,
inviteLink: struct.inviteLink,
pinnedMessage: struct.pinnedMessage,
permissions: struct.permissions,
slowModeDelay: struct.slowModeDelay,
stickerSetName: struct.stickerSetName,
canSetStickerSet: struct.canSetStickerSet
canSetStickerSet: struct.canSetStickerSet,
linkedChatId: struct.linkedChatId
}

return filterPayload(payload)
Expand Down
10 changes: 10 additions & 0 deletions packages/puregram/src/common/structures/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ export class User {
return this.payload.language_code
}

/** `true`, if this user is a Telegram Premium user */
get isPremium() {
return this.payload.is_premium as true | undefined
}

/** `true`, if this user added the bot to the attachment menu */
get addedToAttachmentMenu() {
return this.payload.added_to_attachment_menu as true | undefined
}

/**
* `true`, if the bot can be invited to groups.
*
Expand Down

0 comments on commit 64a46af

Please sign in to comment.