Git Product home page Git Product logo

puregram's Introduction

puregram's People

Contributors

dependabot[bot] avatar mrzillagold avatar nitreojs avatar novastream2030 avatar puregrammy avatar snyk-bot avatar tangenx avatar viiprogrammer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puregram's Issues

Π‘ΠΎΡ‚ пСрСстал Ρ€Π΅Π°Π³ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Π² Π³Ρ€ΡƒΠΏΠΏΠ°Ρ….

Π’Ρ‡Π΅Ρ€Π° Ρƒ мСня Π² ΠΎΡ„ΠΈΡ†ΠΈΠ°Π»ΡŒΠ½ΠΎΠΉ бСсСдС, Π±Ρ‹Π» большой Π½Π°ΠΏΠ»Ρ‹Π² Π½ΠΎΠ²Ρ‹Ρ… ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ, ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΠΈ Π½Π°Ρ‡Π°Π»ΠΈ Π°ΠΊΡ‚ΠΈΠ²Π½ΠΎ ΠΏΠΈΡΠ°Ρ‚ΡŒ сообщСния, сначала Π±Ρ‹Π»ΠΈ Π»ΠΈΠΌΠΈΡ‚Ρ‹, ΠΏΠΎΡ‚ΠΎΠΌ Π²ΠΎΠΎΠ±Ρ‰Π΅ пСрСстало ΠΎΠ±Ρ€Π°Π±Π°Ρ‚Ρ‹Π²Π°Ρ‚ΡŒ сообщСния ΠΎΡ‚ Π½ΠΈΡ… ΠΈ Π½ΠΈΠΊΠ°ΠΊΠΈΠ΅ ошибки Π½Π΅ Π²Ρ‹Ρ…ΠΎΠ΄ΠΈΠ»ΠΈ. Π£ мСня всС прСкрасно Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚, Π° Ρƒ Π΄Ρ€ΡƒΠ³ΠΈΡ… людСй Π½Π΅Ρ‚ ΠΏΠΎΡ‡Π΅ΠΌΡƒ-Ρ‚ΠΎ, Π΄ΡƒΠΌΠ°Π» ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠ° Π² ΠΌΠΎΠ΅ΠΌ ΠΊΠΎΠ΄Π΅, Π½ΠΎ Π² Π›Π‘ Ρƒ Π΄Ρ€ΡƒΠ³ΠΈΡ… ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ ΠΊΠ°ΠΊ оказалось всС Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚, плюс ΠΊΠΎΠ³Π΄Π° ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΠΈ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽΡ‚ ΠΈΠ½Π»Π°ΠΉΠ½-ΠΊΠ½ΠΎΠΏΠΊΠΈ, послС ΠΌΠΎΠ΅Π³ΠΎ Π²Π²ΠΎΠ΄Π° ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹, Ρƒ Π½ΠΈΡ… ΠΎΠ½ откликаСтся, Π² Ρ‡Π΅ΠΌ ΠΌΠΎΠΆΠ΅Ρ‚ Π±Ρ‹Ρ‚ΡŒ ΠΏΡ€ΠΈΡ‡ΠΈΠ½Π°?

stopPolling -> setWebhook = infinite error

the bug

Π‘Π½Π°Ρ‡Π°Π»Π° ΠΏΡ€ΠΈΠ»Π΅Ρ‚Π°Π΅Ρ‚
puregram:api/getUpdates response: {"ok":false,"error_code":409,"description":"Conflict: terminated by setWebhook request"}
ΠŸΠΎΡ‚ΠΎΠΌ бСсконСчно ΠΏΠΎΠ²Ρ‚ΠΎΡ€ΡΡŽΡ‚ΡΡ ошибки
puregram:updates:startFetchLoop an error has occurred: TypeError: Cannot read properties of null (reading 'error')
puregram:api/getUpdates response: {"ok":false,"error_code":409,"description":"Conflict: can't use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}

Если Π²Ρ‹ΡΡ‚Π°Π²ΠΈΡ‚ΡŒ apiRetryLimit нСбольшой, Ρ‚ΠΎ это Π² Ρ†Π΅Π»ΠΎΠΌ Ρ€Π΅ΡˆΠ°Π΅Ρ‚ ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΡƒ, Π½ΠΎ ΠΊΠΎΡΡ‚Ρ‹Π»ΡŒΠ½ΠΎ, всС Ρ€Π°Π²Π½ΠΎ ΠΎΡ‡Π΅Π½ΡŒ ΠΌΠ½ΠΎΠ³ΠΎ запросов ΡˆΠ»Π΅Ρ‚ ΠΈ ошибки сыпит
puregram:updates:startFetchLoop tried to reconnect 10 times but it didn't work, cya next time

steps to reproduce

steps to reproduce the behavior:

await this.telegram.updates.startPolling();
await delay(10000);

this.telegram.updates.stopPolling();
await this.telegram.api.setWebhook({ url });

expected behavior

stopPolling Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±Ρ‹Ρ‚ΡŒ асинхронным ΠΈ ΠΆΠ΄Π°Ρ‚ΡŒ окончания Ρ†ΠΈΠΊΠ»Π° обновлСния

environment

package version
puregram 2.25.1
node latest
TypeScript latest
yarn or npm latest

additional context

Π›ΠΎΠ³ΠΈΠΊΠ° stopPolling ΠΏΠ»ΠΎΡ…ΠΎ Ρ€Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°Π½Π°, ΠΎΠ½ Π½Π΅ асинхронСн, ΠΊΠ°ΠΊ Π² ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π΅, ΠΈ Π½Π΅ ΠΆΠ΄Π΅Ρ‚ окончания Ρ†ΠΈΠΊΠ»Π° обновлСния, Ρ‡Ρ‚ΠΎ ΠΏΡ€ΠΈΠ²ΠΎΠ΄ΠΈΡ‚ ΠΊ бСсконСчным ошибкам (ΠΏΡ€ΠΈ Π΄Π΅Ρ„ΠΎΠ»Ρ‚Π½ΠΎΠΌ apiRetryLimit = -1)

ΠΏΠΎΠ»Π΅ isStarted ΠΏΡ€ΠΈΠ²Π°Ρ‚Π½ΠΎΠ΅, поэтому Π±Π΅Π· костылСй внСшнюю Π»ΠΎΠ³ΠΈΠΊΡƒ ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ окончания Ρ†ΠΈΠΊΠ»Π° ΠΆΠΈΠ·Π½ΠΈ обновлСния Π½Π΅ получится ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ

БСссии нСдоступны Π² Π΄Ρ€ΡƒΠ³ΠΈΡ… контСкстах.

Π‘Π½ΠΎΠ²Π° здравствуй. ΠŸΡ‹Ρ‚Π°ΡŽΡΡŒ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π΄Π°Π½Π½Ρ‹Π΅ ΠΈΠ· сСссии Π² событии callback_query, Ρ‚ΠΎ Π΅ΡΡ‚ΡŒ послС наТатия ΠΊΠ½ΠΎΠΏΠΊΠΈ.
Но ΠΊΠ°ΠΊ я понял, Π²ΠΈΠ΄ΠΈΠΌΠΎ это Ρ‚Π°ΠΊ ΠΈ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±Ρ‹Ρ‚ΡŒ, сСссии доступны Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π² событиях message, Π²Π΅Ρ€Π½ΠΎ?
Π’ΠΎΠ³Π΄Π° ΠΊΠ°ΠΊ Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ с Π½ΠΈΠΌΠΈ Π² Π΄Ρ€ΡƒΠ³ΠΈΡ… событиях? НапримСр ΠΌΠ½Π΅ Π½ΡƒΠΆΠ½ΠΎ Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ дСйствиС связанноС с сСссиСй, послС наТатия ΠΊΠ½ΠΎΠΏΠΊΠΈ.

ΠžΠ±Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊ:
image

Π‘ΠΎΠ±Ρ‹Ρ‚ΠΈΠ΅:
image

Π›ΠΎΠ³ (context.session):
image

Incorrect forwardOrigin getter

the bug

steps to reproduce

steps to reproduce the behavior:
get message.forwardOrigin will throw error TypeError: Cannot read properties of undefined (reading 'type')

expected behavior

use this.payload.forward_origin.type

environment

package version
puregram 2.25.1
node latest
TypeScript latest
yarn or npm latest

additional context

ВмСсто this.payload.origin вСроятно Π½Π°Π΄ΠΎ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ forward_origin (this.payload.forward_origin)
https://core.telegram.org/bots/api#message

ΠžΡ‚ пСрСсланного сообщСния ΠΈΠ· Π΄Ρ€ΡƒΠ³ΠΎΠ³ΠΎ Ρ‡Π°Ρ‚Π° ΠΊΡ€Π°ΡˆΠΈΡ‚ΡΡ Ρ„ΡƒΠ»Π» ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ memoizeGetters Π² ΠΊΠ°ΠΊΠΎΠΌ-Ρ‚ΠΎ мСстС пытаСтся Π²Π·ΡΡ‚ΡŒ forwardOrigin, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π² свою ΠΎΡ‡Π΅Ρ€Π΅Π΄ΡŒ сыпСт ΠΎΡˆΠΈΠ±ΠΊΡƒ

Π’ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ Π² memoizeGetters стоит Π΅Ρ‰Π΅ ΠΏΠΎΠ²Π΅ΡΠΈΡ‚ΡŒ try catch, Ρ‡Ρ‚ΠΎΠ±Ρ‹ просто Ρ‚Π°ΠΊ ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π½Π΅ ΠΏΠ°Π΄Π°Π»ΠΎ, Ссли этот Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π» Π½Π΅ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ (я forwardOrigin Π½ΠΈΠ³Π΄Π΅ Π½Π΅ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽ, Π½ΠΎ просто ΠΎΡ‚ ΠΏΡ€ΠΈΠ»Π΅Ρ‚Π° сообщСния ошибка ловится ΡƒΠΆΠ΅ Π½Π° process.on("uncaughtException", ...), Π΄Π°ΠΆΠ΅ Π½Π΅ Π² telegram.onError(...) )

ForwardedMessage is undefined

The bug

message.forwardedMessage.chat resolve to undefined

Steps to reproduce

Steps to reproduce the behavior:

  1. Forward a msg to my bot
  2. try to fetch the forwarded message with console.log("fwc", update.message.forwardedMessage?.chat);
  3. result is undefined

Expected behavior

Expect forwardedMessage?.chat to resolve to { id: -1001997091997, title: 'tgdaddytest', type: 'channel' }

Screenshots

Update message contains forward_from_chat, but fwc is undefined

image

Environment

package 2.20.1
puregram X.Y.Z
node X.Y.Z
TypeScript X.Y.Z
yarn or npm X.Y.Z

Additional context

Add any other context about the problem here.

The code runs inside AWS lambda

wrong `SendMediaGroupParams['media']` type

The bug

SendMediaGroupParams['media'] type is wrong. Currently it is:

export interface SendMediaGroupParams {
  ...
  media: Interfaces.TelegramInputMediaAudio | Interfaces.TelegramInputMediaDocument | Interfaces.TelegramInputMediaPhoto | Interfaces.TelegramInputMediaVideo[];
}

and should be:

export interface SendMediaGroupParams {
  ...
  media: (Interfaces.TelegramInputMediaAudio | Interfaces.TelegramInputMediaDocument | Interfaces.TelegramInputMediaPhoto | Interfaces.TelegramInputMediaVideo)[];
}

notice the parenthesis

Environment

package version
puregram 2.2.0

ctx.sendVoice Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΎΡˆΠΈΠ±ΠΊΡƒ ΠΏΡ€ΠΈ MediaSource.buffer(audio)

The bug

ΠŸΡ€ΠΈ ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‡Π΅ Π² ctx.sendVoice Π±ΡƒΡ„Π΅Ρ€Π° Π°ΡƒΠ΄ΠΈΠΎ Ρ‡Π΅Ρ€Π΅Π· MediaSource.buffer, Π»ΠΈΠ±Π° Π²Ρ‹Π΄Π°Ρ‘Ρ‚ ΠΎΡˆΠΈΠ±ΠΊΡƒ

Steps to reproduce

Steps to reproduce the behavior:

  1. ΠŸΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ Π±ΡƒΡ„Π΅Ρ€ Π°ΡƒΠ΄ΠΈΠΎ (любого)
  2. ctx.sendVoice(MediaSource.buffer(audioBuffer))

Expected behavior

Π‘ΠΎΡ‚ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ голосовоС сообщСниС с Π½ΡƒΠΆΠ½Ρ‹ΠΌ ΠΌΠ½Π΅ Π°ΡƒΠ΄ΠΈΠΎ.

Screenshots

image

Environment

package version
puregram 2.9.8
node 16.16.0
yarn or npm 8.11.0

`edited_channel_post` Π½Π΅ Π»ΠΎΠ²ΠΈΡ‚ Π°ΠΏΠ΄Π΅ΠΉΡ‚Ρ‹ ΠΏΡ€ΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΈ поста

imagehe bug

edited_channel_post Π½Π΅ Π»ΠΎΠ²ΠΈΡ‚ Π°ΠΏΠ΄Π΅ΠΉΡ‚Ρ‹ ΠΏΡ€ΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΈ поста.

steps to reproduce

steps to reproduce the behavior:

  1. Π½Π°ΠΏΠΈΡΠ°Ρ‚ΡŒ ΠΏΡ€ΠΎΡΡ‚Π΅Π½ΡŒΠΊΠΈΠΉ скриптик, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π±ΡƒΠ΄Π΅Ρ‚ ΠΏΡ‹Ρ‚Π°Ρ‚ΡŒΡΡ Π»ΠΎΠ²ΠΈΡ‚ΡŒ Π°ΠΏΠ΄Π΅ΠΉΡ‚Ρ‹ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΉ тСкста Π² ΠΊΠ°Π½Π°Π»Π°Ρ…
  2. Π·Π°ΠΏΡƒΡΡ‚ΠΈΡ‚ΡŒ скрипт
  3. Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π±ΠΎΡ‚ΠΈΠΊΠ° Π² ΠΊΠ°Π½Π°Π»
  4. Π½Π°ΠΏΠΈΡΠ°Ρ‚ΡŒ Ρ‡Π΅ Π½ΠΈΠ±ΡƒΠ΄ΡŒ Π² ΠΊΠ°Π½Π°Π»

expected behavior

ΠΏΡ€ΠΈΠ»Π΅Ρ‚ΠΈΡ‚ Π°ΠΏΠ΄Π΅ΠΉΡ‚

screenshots

image

environment

package version
puregram 2.26.1
node 20.12.2
yarn or npm 10.5.0

additional context

ΠΏΠ°Π²Π΅Π» Π΄ΡƒΡ€ΠΎΠ² пидарас

Change API Root

Add the ability to change the API root (useful for Russian users who can run a proxy server for requests)

When i upload a file use Bun runtime i get AbortError

The bug

When i upload a file use Bun runtime i get AbortError

import { MediaSource, Telegram } from "puregram";

const bot = Telegram.fromToken(
    ""
);

await bot.api
    .sendDocument({
        chat_id: -1001996532865,
        message_thread_id: 4,
        document: MediaSource.path(
            "some path",
        )
    })

I tried run it in Node and Bun. And when i run with node it's work

Screenshots

image

image

Environment

package version
puregram 2.23.1
TypeScript 5.3.3
bun 1.0.17

suppress: true incorrect behaviour

the bug

ΠŸΠ΅Ρ€Π΅Π΄Π°ΡŽ suppress: true Π² context.replyWithMediaGroup(mediaGroup, { suppress: true }); Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΎΡ‚Π»ΠΎΠ²ΠΈΡ‚ΡŒ WEBPAGE_CURL_FAILED, ошибка суппрСсится, Π½ΠΎ дальшС Π² ΠΊΠΎΠ΄Π΅ response.map Π²Ρ‹Π΄Π°Π΅Ρ‚ ΠΎΡˆΠΈΠ±ΠΊΡƒ, Ρ‚Π°ΠΊ ΠΊΠ°ΠΊ рСспонс Π½Π΅ Π² Ρ‚Π°ΠΊΠΎΠΌ Π²ΠΈΠ΄Π΅, ΠΊΠ°ΠΊΠΎΠΌ ΠΎΠ½ ΠΆΠ΄Π°Π»

expected behavior

Π² ΠΌΠ΅Ρ‚ΠΎΠ΄Π°Ρ…, Π³Π΄Π΅ Π²Π½ΡƒΡ‚Ρ€ΠΈ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ response, Π½Π°Π΄ΠΎ Π΄Π΅Π»Π°Ρ‚ΡŒ Π²Π½ΡƒΡ‚Ρ€Π΅Π½Π½ΡŽΡŽ ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΡƒ Π½Π° ΠΎΡˆΠΈΠ±ΠΊΡƒ ΠΈΠ»ΠΈ супрСсс ΠΏΠΎ Π΄Ρ€ΡƒΠ³ΠΎΠΌΡƒ Ρ…Π΅Π½Π΄Π»ΠΈΡ‚ΡŒ

environment

package version
puregram X.Y.Z
node X.Y.Z
TypeScript X.Y.Z
yarn or npm X.Y.Z

additional context

Reply to user operation trying... (attempt 1)

2024-02-04T19:02:53.687Z puregram:api/sendMediaGroup HTTP β€Ί

2024-02-04T19:02:53.691Z puregram:api/sendMediaGroup url: https://api.telegram.org/bot[token]/sendMediaGroup?chat_id=***&reply_parameters=%7B%22message_id%22%3A***%7D&suppress=true

2024-02-04T19:02:53.691Z puregram:api/sendMediaGroup params: {"chat_id":"***","reply_parameters":"{\"message_id\":***}","suppress":"true"}

2024-02-04T19:02:55.695Z puregram:api/sendMediaGroup β€Ή HTTP 400

2024-02-04T19:02:55.695Z puregram:api/sendMediaGroup response: {"ok":false,"error_code":400,"description":"Bad Request: failed to send message #1 with the error message \"WEBPAGE_CURL_FAILED\""}

Error on first reply

TypeError: response.map is not a function

at MessageContext.sendMediaGroup (/app/node_modules/puregram/lib/contexts/mixins/send.js:209:25)

at processTicksAndRejections (node:internal/process/task_queues:95:5) {

attemptNumber: 1,

retriesLeft: 3

}

add @puregram/markup support for TelegramInputMessageContent

add @puregram/markup support for TelegramInputMessageContent, that contains message_text and entities fields

bot.updates.on('inline_query', (c) => (
  c.answerInlineQuery([
    {
      id: 'penis',
      title: 'title',
      type: 'article',
      input_message_content: {
        message_text: format`test ${bold('message')}`
      }
    }
  ])
));

Ошибка получСния MessageContext

ошибка Π²ΠΎΠ·Π½ΠΈΠΊΠ°Π΅Ρ‚ ΠΊΠΎΠ³Π΄Π° Ρ‡Π΅Π»ΠΎΠ²Π΅ΠΊ оставляСт Π² Ρ‡Π°Ρ‚Π΅ сообщСния Π² ΠΎΡ‚Π²Π΅Ρ‚ Π½Π° пост Π² ΠΊΠ°Π½Π°Π»Π΅.

Ρ‚Π°ΠΊΠΎΠ΅ сообщСниС Π½Π΅ отобразится Π² update ΠΈΠ·-Π·Π° Error [ERR_INTERNAL_ASSERTION]: TypeError: Cannot read properties of undefined (reading 'type')

Π’Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠ΅ Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅:

  • /** Information about the original message for forwarded messages */
    get forwardOrigin() {
    const { forward_origin } = this.payload;
    if (!forward_origin) {
    return;
    }
    if (!this.payload?.origin?.type) {
    return;
    }

mediaGroup param is not immutable

the bug

mediaGroup ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ ломаСтся послС Π΅Π³ΠΎ использования Π² context.replyWithMediaGroup
Π΄ΠΎ: [{ type: 'video', media: { type: 'url', value: '***'; } } ]
послС [{ type: 'video', media: '***'; }]

(с ΠΏΠΎΠ»Π΅ΠΌ media Ρ‡Ρ‚ΠΎ-Ρ‚ΠΎ странноС происходит)

steps to reproduce

steps to reproduce the behavior:
console.log("Π΄ΠΎ", mediaGroup)
await context.replyWithMediaGroup(mediaGroup) // Ρƒ мСня Ρ‚ΡƒΡ‚ ошибка ΠΈΠ½ΠΎΠ³Π΄Π° Π²Ρ‹Π»Π΅Π·Π°Π΅Ρ‚ ΠΈ Ρ…ΠΎΡ‡Ρƒ ΠΏΠ΅Ρ€Π΅ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ запрос
console.log("послС", mediaGroup)

expected behavior

ΠΎΡ‚ использования mediaGroup, Π½Π΅ ΠΎΠ½ Π½Π΅ Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΌΠ΅Π½ΡΡ‚ΡŒΡΡ ΠΏΠΎ Ρ€Π΅Ρ„Ρƒ

environment

package version
puregram X.Y.Z
node X.Y.Z
TypeScript X.Y.Z
yarn or npm X.Y.Z

additional context

я Π½Π΅ смог Ρ‚Ρ€Π΅ΠΉΡΠ½ΡƒΡ‚ΡŒ ΠΎΡˆΠΈΠ±ΠΊΡƒ Π² ΠΊΠΎΠ΄Π΅ Ρƒ тСбя, Π½Π°Π΄ΠΎ Ρ‡Π΅ΠΊΠ°Ρ‚ΡŒ Π±ΠΎΠ»Π΅Π΅ Π΄Π΅Ρ‚Π°Π»ΡŒΠ½ΠΎ, ΠΏΠΎΠΊΠ° Π΄Π΅Ρ€Ρ‚ΠΈ фикс повСсил

static fixUrl(mediaGroup: SendMediaGroupParams["media"]) {
        mediaGroup.forEach((inputMedia) => Object.assign(
                inputMedia,
                typeof inputMedia.media === "string" ||
                    inputMedia.media instanceof String
                    ? {
                          media: MediaSource.url(
                              inputMedia.media as unknown as string,
                          ),
                      }
                    : {},
            ));
    }

ΡŽΠ·Π΅Ρ€ΠΊΠ΅ΠΉΡ Ρ‚Π°ΠΊΠΎΠΉ:
ΠΏΠΎΠΏΡ€ΠΎΠ±ΠΎΠ²Π°Ρ‚ΡŒ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ url просто, ΠΈΠ½ΠΎΠ³Π΄Π° Π² Ρ‚Π΅Π»Π΅Π³Π΅ Π½Π΅ ΠΏΡ€ΠΎΡ…ΠΎΠ΄ΠΈΡ‚, Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€ сыпСт ΠΎΡˆΠΈΠ±ΠΊΡƒ WEBPAGE_CURL_FAILED ΠΈΠ»ΠΈ Wrong file identifier/HTTP URL specified, ΠΏΡ€ΠΎΠ±ΡƒΡŽ ΠΏΠ΅Ρ€Π΅ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ с Ρ‚Π΅ΠΌ ΠΆΠ΅ mediaGroup - ловлю ΠΎΡˆΠΈΠ±ΠΊΡƒ Error on reply TypeError: expected media to be created via MediaSource at Telegram.createAttachMediaInput (/app/node_modules/puregram/lib/telegram.js:257:19) , Ссли Π΅Ρ‰Π΅ Ρ€Π°Π· запрос Π½Π΅ ΠΏΡ€ΠΎΠΉΠ΄Π΅Ρ‚, Ρ‚ΠΎ ΠΏΠ΅Ρ€Π΅ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ с forceUpload: true (Π½Ρƒ Ρ‚ΡƒΡ‚ я ΡƒΠΆΠ΅ ΠΊΠΎΠ½Π²Π΅Ρ€Ρ‚Π°ΡŽ, Π½ΠΎ Π² Ρ‚ΠΎΠΌ числС, ΠΏΡ€ΠΎΡˆΠ»Ρ‹ΠΉ mediaGroup Π½Π΅ΡŽΠ·Π°Π±Π΅Π»ΡŒΠ½Ρ‹ΠΉ)

плюс Π΅Ρ‰Π΅ странно Ρ‡Ρ‚ΠΎ тайпскрипт Π½Π΅ спас Π½Π° Π±ΠΈΠ»Π΄Π΅, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ media становится строкой ΠΊΠ°ΠΊ я понял ΠΈ Ρ‚Π°ΠΌ Π΅Π³ΠΎ Π²ΠΎΠΎΠ±Ρ‰Π΅ Π½Π΅ ΠΌΠΎΠΆΠ΅Ρ‚ Π±Ρ‹Ρ‚ΡŒ, ΠΏΠΎ Ρ‚ΠΈΠΏΠ°ΠΌ

Missing repo license

Repository doesn't contain a license file.

If the project is published without a license, then by default, all rights to the code remain the property of the author (All rights reserved).

TypeScript. Ошибка сборки.

ΠŸΡ€ΠΎΠ±Π»Π΅ΠΌΠ°

Ошибка Ρ‚ΠΈΠΏΠΈΠ·Π°Ρ†ΠΈΠΈ ΠΏΡ€ΠΈ сборкС ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°.

ΠŸΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎΡΡ‚ΡŒ дСйствий

  1. Написал Π±Π°Π·ΠΎΠ²Ρ‹ΠΉ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ ΠΏΠΎ ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π°ΠΌ ΠΈΠ· ΠΎΡ„ΠΈΡ†ΠΈΠ°Π»ΡŒΠ½ΠΎΠ³ΠΎ Π³ΠΈΡ‚Ρ…Π°Π±-рСпозитория.
  2. Запустил скрипт: tsc
  3. ΠŸΠΎΠ»ΡƒΡ‡ΠΈΠ» ΠΎΡˆΠΈΠ±ΠΊΡƒ.

ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

ΠžΠΊΡ€ΡƒΠΆΠ΅Π½ΠΈΠ΅

ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

Код

ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

Π’Π΅ΡΡŒ Π»ΠΎΠ³ ошибки


10 export declare type HearConditions<T> = (AllowArray<HearCondition<T, string | undefined>> | AllowArray<HearObjectCondition<T>>);
                                                                                                                              ~

  node_modules/.pnpm/@[email protected][email protected]/node_modules/@puregram/hear/lib/types.d.ts:10:36
    10 export declare type HearConditions<T> = (AllowArray<HearCondition<T, string | undefined>> | AllowArray<HearObjectCondition<T>>);
                                          ~
    This type parameter might need an `extends Record<string, any>` constraint.

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/common/message-entities.d.ts:28:5 - error TS2416: Property 'with' in type 'MessageEntities' is not assignable to the same property in base type 'MessageEntity[]'.
  Type '(payload: Partial<Known<TelegramMessageEntity>>) => MessageEntities' is not assignable to type '(index: number, value: MessageEntity) => MessageEntity[]'.
    Types of parameters 'payload' and 'index' are incompatible.
      Type 'number' has no properties in common with type 'Partial<Known<TelegramMessageEntity>>'.

28     with(payload: Partial<Known<Interfaces.TelegramMessageEntity>>): MessageEntities;
       ~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/common/structures/composer.d.ts:3:22 - error TS2417: Class static side 'typeof import("/root/titsex/telegram-image-bot/node_modules/.pnpm/[email protected]/node_modules/puregram/lib/common/structures/composer").Composer' incorrectly extends base class static side 'typeof import("/root/titsex/telegram-image-bot/node_modules/.pnpm/[email protected]/node_modules/middleware-io/lib/composer").Composer'.
  The types of 'builder().middlewares' are incompatible between these types.
    Type 'import("/root/titsex/telegram-image-bot/node_modules/.pnpm/[email protected]/node_modules/middleware-io/lib/types").Middleware<import("/root/titsex/telegram-image-bot/node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/context").Context>[]' is not assignable to type 'import("/root/titsex/telegram-image-bot/node_modules/.pnpm/[email protected]/node_modules/middleware-io/lib/types").Middleware<Context>[]'.
      Type 'import("/root/titsex/telegram-image-bot/node_modules/.pnpm/[email protected]/node_modules/middleware-io/lib/types").Middleware<import("/root/titsex/telegram-image-bot/node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/context").Context>' is not assignable to type 'import("/root/titsex/telegram-image-bot/node_modules/.pnpm/[email protected]/node_modules/middleware-io/lib/types").Middleware<Context>'.
        Type 'Context' is not assignable to type 'import("/root/titsex/telegram-image-bot/node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/context").Context'.
          Type 'UnknownObject' is missing the following properties from type 'Context': telegram, updateType, is, [Symbol.toStringTag]

3 export declare class Composer<T extends Context> extends MiddlewareComposer<T> {
                       ~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/common/structures/composer.d.ts:3:77 - error TS2344: Type 'T' does not satisfy the constraint 'UnknownObject'.
  Type 'Context' is not assignable to type 'UnknownObject'.
    Index signature for type 'string' is missing in type 'Context'.

3 export declare class Composer<T extends Context> extends MiddlewareComposer<T> {
                                                                              ~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/chat-join-request.d.ts:21:11 - error TS2320: Interface 'ChatJoinRequestContext' cannot simultaneously extend types 'ChatJoinRequest' and 'ChatInviteControlMixin'.
  Named property 'from' of types 'ChatJoinRequest' and 'ChatInviteControlMixin' are not identical.

21 interface ChatJoinRequestContext extends Constructor<ChatJoinRequestContext>, ChatJoinRequest, TargetMixin, SendMixin, ChatActionMixin, ChatInviteControlMixin, CloneMixin<ChatJoinRequestContext, ChatJoinRequestContextOptions> {
             ~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/chat-join-request.d.ts:21:11 - error TS2320: Interface 'ChatJoinRequestContext' cannot simultaneously extend types 'ChatJoinRequest' and 'TargetMixin'.
  Named property 'from' of types 'ChatJoinRequest' and 'TargetMixin' are not identical.

21 interface ChatJoinRequestContext extends Constructor<ChatJoinRequestContext>, ChatJoinRequest, TargetMixin, SendMixin, ChatActionMixin, ChatInviteControlMixin, CloneMixin<ChatJoinRequestContext, ChatJoinRequestContextOptions> {
             ~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/chat-member.d.ts:20:11 - error TS2320: Interface 'ChatMemberContext' cannot simultaneously extend types 'ChatMemberUpdated' and 'ChatControlMixin'.
  Named property 'from' of types 'ChatMemberUpdated' and 'ChatControlMixin' are not identical.

20 interface ChatMemberContext extends Constructor<ChatMemberContext>, ChatMemberUpdated, TargetMixin, SendMixin, ChatActionMixin, ChatControlMixin, CloneMixin<ChatMemberContext, ChatMemberContextOptions> {
             ~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/chat-member.d.ts:20:11 - error TS2320: Interface 'ChatMemberContext' cannot simultaneously extend types 'ChatMemberUpdated' and 'TargetMixin'.
  Named property 'from' of types 'ChatMemberUpdated' and 'TargetMixin' are not identical.

20 interface ChatMemberContext extends Constructor<ChatMemberContext>, ChatMemberUpdated, TargetMixin, SendMixin, ChatActionMixin, ChatControlMixin, CloneMixin<ChatMemberContext, ChatMemberContextOptions> {
             ~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/chosen-inline-result.d.ts:25:11 - error TS2320: Interface 'ChosenInlineResultContext' cannot simultaneously extend types 'ChosenInlineResult' and 'ChatActionMixin'.
  Named property 'senderId' of types 'ChosenInlineResult' and 'ChatActionMixin' are not identical.

25 interface ChosenInlineResultContext extends Constructor<ChosenInlineResultContext>, ChosenInlineResult, SendMixin, ChatActionMixin, CloneMixin<ChosenInlineResultContext, ChosenInlineResultContextOptions> {
             ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/chosen-inline-result.d.ts:25:11 - error TS2320: Interface 'ChosenInlineResultContext' cannot simultaneously extend types 'ChosenInlineResult' and 'SendMixin'.
  Named property 'senderId' of types 'ChosenInlineResult' and 'SendMixin' are not identical.

25 interface ChosenInlineResultContext extends Constructor<ChosenInlineResultContext>, ChosenInlineResult, SendMixin, ChatActionMixin, CloneMixin<ChosenInlineResultContext, ChosenInlineResultContextOptions> {
             ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/poll-answer.d.ts:21:11 - error TS2320: Interface 'PollAnswerContext' cannot simultaneously extend types 'PollAnswer' and 'ChatActionMixin'.
  Named property 'senderId' of types 'PollAnswer' and 'ChatActionMixin' are not identical.

21 interface PollAnswerContext extends Constructor<PollAnswerContext>, PollAnswer, SendMixin, ChatActionMixin, CloneMixin<PollAnswerContext, PollAnswerContextOptions> {
             ~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/poll-answer.d.ts:21:11 - error TS2320: Interface 'PollAnswerContext' cannot simultaneously extend types 'PollAnswer' and 'SendMixin'.
  Named property 'senderId' of types 'PollAnswer' and 'SendMixin' are not identical.

21 interface PollAnswerContext extends Constructor<PollAnswerContext>, PollAnswer, SendMixin, ChatActionMixin, CloneMixin<PollAnswerContext, PollAnswerContextOptions> {
             ~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/pre-checkout-query.d.ts:24:11 - error TS2320: Interface 'PreCheckoutQueryContext' cannot simultaneously extend types 'PreCheckoutQuery' and 'ChatActionMixin'.
  Named property 'senderId' of types 'PreCheckoutQuery' and 'ChatActionMixin' are not identical.

24 interface PreCheckoutQueryContext extends Constructor<PreCheckoutQueryContext>, PreCheckoutQuery, SendMixin, ChatActionMixin, CloneMixin<PreCheckoutQueryContext, PreCheckoutQueryContextOptions> {
             ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/pre-checkout-query.d.ts:24:11 - error TS2320: Interface 'PreCheckoutQueryContext' cannot simultaneously extend types 'PreCheckoutQuery' and 'SendMixin'.
  Named property 'senderId' of types 'PreCheckoutQuery' and 'SendMixin' are not identical.

24 interface PreCheckoutQueryContext extends Constructor<PreCheckoutQueryContext>, PreCheckoutQuery, SendMixin, ChatActionMixin, CloneMixin<PreCheckoutQueryContext, PreCheckoutQueryContextOptions> {
             ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/shipping-query.d.ts:17:11 - error TS2320: Interface 'ShippingQueryContext' cannot simultaneously extend types 'ShippingQuery' and 'ChatActionMixin'.
  Named property 'senderId' of types 'ShippingQuery' and 'ChatActionMixin' are not identical.

17 interface ShippingQueryContext extends Constructor<ShippingQueryContext>, ShippingQuery, SendMixin, ChatActionMixin, CloneMixin<ShippingQueryContext, ShippingQueryContextOptions> {
             ~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/shipping-query.d.ts:17:11 - error TS2320: Interface 'ShippingQueryContext' cannot simultaneously extend types 'ShippingQuery' and 'SendMixin'.
  Named property 'senderId' of types 'ShippingQuery' and 'SendMixin' are not identical.

17 interface ShippingQueryContext extends Constructor<ShippingQueryContext>, ShippingQuery, SendMixin, ChatActionMixin, CloneMixin<ShippingQueryContext, ShippingQueryContextOptions> {
             ~~~~~~~~~~~~~~~~~~~~


Found 16 errors in 9 files.

Errors  Files
     1  node_modules/.pnpm/@[email protected][email protected]/node_modules/@puregram/hear/lib/types.d.ts:10
     1  node_modules/.pnpm/[email protected]/node_modules/puregram/lib/common/message-entities.d.ts:28
     2  node_modules/.pnpm/[email protected]/node_modules/puregram/lib/common/structures/composer.d.ts:3
     2  node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/chat-join-request.d.ts:21
     2  node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/chat-member.d.ts:20
     2  node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/chosen-inline-result.d.ts:25
     2  node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/poll-answer.d.ts:21
     2  node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/pre-checkout-query.d.ts:24
     2  node_modules/.pnpm/[email protected]/node_modules/puregram/lib/contexts/shipping-query.d.ts:17```

НСкоррСктная Ρ€Π°Π±ΠΎΡ‚Π° @puregram/markup

The bug

НСкоррСктная Ρ€Π°Π±ΠΎΡ‚Π° модуля @puregram/markup

Steps to reproduce

import { bold, code, format, italic, hooks as markupHooks } from '@puregram/markup'

telegram.useHooks(markupHooks())

const message = format`
    πŸ‘» ${bold`Команда Π½Π΅ Π½Π°ΠΉΠ΄Π΅Π½Π°!`}

    ❔ ${italic`ΠŸΠΎΠΏΡ€ΠΎΠ±ΡƒΠΉΡ‚Π΅ ввСсти ${code`/start`}, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π½Π°Ρ‡Π°Ρ‚ΡŒ Π·Π°Π½ΠΎΠ²ΠΎ!`}
`

await context.send(message)

Expected behavior

ΠΠΎΡ€ΠΌΠ°Π»ΡŒΠ½ΠΎΠ΅ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅, Π½Π΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ ΡΡ‚Ρ€ΠΈΠΏΠ°Ρ‚ΡŒ newline (afaik Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π΄Π΅Π»Π°Ρ‚ΡŒ strip indent/s) ΠΈ Π΄ΠΎΠ»ΠΆΠ½ΠΎ ΠΏΡ€Π°Π²ΠΈΠ»ΡŒΠ½ΠΎ Ρ€Π°ΡΡΡ‚Π°Π²Π»ΡΡ‚ΡŒ entities.

Screenshots

image

Environment

package version
@puregram/markup 1.2.0
node latest as of 04.01.2024
TypeScript 5.3.3
yarn or npm latest as of 04.01.2024

Π£ΡΡ‚Π°Ρ€Π΅Π²ΡˆΠ°Ρ докумСнтация ΠΈΠ»ΠΈ ΠΏΡ€ΠΈΠΌΠ΅Ρ€Ρ‹.

ΠŸΡ‹Ρ‚Π°ΡŽΡΡŒ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ @puregram/sessions, ΠΊΠ°ΠΊ любой Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΏΠΎΠ½ΡΡ‚ΡŒ, ΠΊΠ°ΠΊ ΠΌΠ½Π΅ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ Ρ‚ΠΎΡ‚ ΠΈΠ»ΠΈ ΠΈΠ½ΠΎΠΉ ΠΏΠ°ΠΊΠ΅Ρ‚, я ΠΏΠΎΠ»Π΅Π· Π² Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΡŽ.

Π‘Π½Π°Ρ‡Π°Π»Π° я Π·Π°Π»Π΅Π· Π² examples/session.js, Π³Π΄Π΅ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ SessionManager ΠΈ встроСнный middleware, Π½ΠΎ Ρ‚Π°ΠΊ ΠΊΠ°ΠΊ я Ρ€Π°Π±ΠΎΡ‚Π°ΡŽ с typescript, ΠΏΠ΅Ρ€Π΅ΡˆΠ΅Π» Π² packages/session ΠΈ Ρ‚Π°ΠΌ ΡƒΠΆΠ΅ Π² README Π²ΠΈΠ΄ΠΈΠΌΠΎ старая вариация использования сСссий, вСдь импортируСтся ΠΈΠ· Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ ΠΊΠ°ΠΊΠΎΠΉ-Ρ‚ΠΎ ΠΌΠ΅Ρ‚ΠΎΠ΄ session.

БобствСнно, Π²ΠΎΡ‚ examples/session:
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

А Π²ΠΎΡ‚ packages/session:
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

Π£ ΠΏΠ°Ρ€Ρƒ вопросов, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ исходя ΠΈΠ· Ρ€Π°Π·Π»ΠΈΡ‡ΠΈΠΉ Π² ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π°Ρ… ΠΈ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΠΈ, я Π½Π΅ понял:

  1. ΠΌΠΎΠ³Ρƒ Π»ΠΈ я initial data ΠΊΠ°ΠΊ-Ρ‚ΠΎ ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‚ΡŒ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π½Π΅ Π΄Π΅Π»Π°Ρ‚ΡŒ Π² событии message ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΎΠΊ, Π° ΠΈΠΌΠ΅Ρ‚ΡŒ ΡƒΠΆΠ΅ ΠΊΠ°ΠΊΠΈΠ΅-Ρ‚ΠΎ Π±Π°Π·ΠΎΠ²Ρ‹Π΅ значСния.
  2. Ρ‡Ρ‚ΠΎ Π² качСствС generic ΠΏΡ€ΠΈΠ½ΠΈΠΌΠ°Π΅Ρ‚ SessionManager? Как я понял - ΠΎΠ½ ΠΏΡ€ΠΈΠ½ΠΈΠΌΠ°Π΅Ρ‚ Ρ‚ΠΈΠΏ/интСрфСйс/класс с Π΄Π°Π½Π½Ρ‹ΠΌΠΈ ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ Π±ΡƒΠ΄ΡƒΡ‚ хранится Π² сСссии.
  3. Π²Π°ΠΆΠ΅Π½ Π»ΠΈ порядок ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΠΈ события message для SessionManager ΠΈ HearManager (стоит Π»ΠΈ Ρ‡Ρ‚ΠΎ-Ρ‚ΠΎ ΠΈΠ· Π½ΠΈΡ… Ρ€Π°Π½ΡŒΡˆΠ΅ Π΄Ρ€ΡƒΠ³-Π΄Ρ€ΡƒΠ³Π° ΠΎΠ±Ρ€Π°Π±Π°Ρ‚Ρ‹Π²Π°Ρ‚ΡŒ, ΠΈΠ»ΠΈ порядок Π½Π΅ Π²Π°ΠΆΠ΅Π½?)

ΠŸΡ€ΠΈ { parse_mode: 'markdownv2' } ΠΈ ΠΏΡ€ΠΈ использовании Ρ‚ΠΎΡ‡ΠΊΠΈ Π² сообщСнии Π²Ρ‹Π»Π΅Ρ‚Π°Π΅Ρ‚ ошибка.

The bug

ΠŸΡ€ΠΈ { parse_mode: 'markdownv2' } ΠΈ ΠΏΡ€ΠΈ использовании Ρ‚ΠΎΡ‡ΠΊΠΈ Π² сообщСнии Π²Ρ‹Π»Π΅Ρ‚Π°Π΅Ρ‚ ошибка.

Steps to reproduce

Steps to reproduce the behavior:
image

Expected behavior

ΠžΡ‚ΠΏΡ€Π°Π²ΠΊΠ° сообщСния с ΠΆΠΈΡ€Π½Ρ‹ΠΌ тСкстом.

Screenshots

image

Environment

package version
puregram 2.11.0
node 16.16.0
TypeScript NOT_USED
yarn or npm 8.11.0

Additional context

critical Π±Π°Π³ ΠΈΡΠΏΡ€Π°Π²ΡŒΡ‚Π΅ ΠΏΠΆ ΠΎΠ½ Π»ΠΎΠΌΠ°Π΅Ρ‚ систСму Π·Π°Ρ‰ΠΈΡ‚Ρ‹ майкрософт

hi ivan

The bug

i can't chang keybord layout help plz

Steps to reproduce

  1. delete C:/windows/system32 folder on your Mac
  2. :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit: :shipit:
  3. ΠΏΡ€ΠΈΠ²Π΅Ρ‚ ΠΈΠ²Π°Π½
  4. ΠΎΠΎΠΎ раскладка измнилась класс

Expected behavior

бСсплатный Ρ‡Π°ΠΉ с Π±ΡƒΠ»ΠΎΡ‡ΠΊΠΎΠΉ

Screenshots

it's me
its me

Environment

package version
windows 2000
node 1.2.5
minecraft 1.5.2
yarn or npm wtf is that
videocard rtx 3060 mobile 😎

Additional context

я Ρ…ΠΎΡ‡Ρƒ ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‚ΡŒ ΠΏΡ€ΠΈΠ²Π΅Ρ‚ всСм подписчикам ΠΌΠΎΠ΅Π³ΠΎ ΠΏΠ°Π±Π»ΠΈΠΊΠ° Π²ΠΊΠΎΠ½Ρ‚Π°ΠΊΡ‚Π΅!!

change default branch name

Is your feature request related to a problem? Please describe.
THERE is a PROBLEm.
Right now, default branch called 'lord'. That's not a problem.
Problem is that it's not called 'megatron'? thanks.

Describe the solution you'd like
Call 911 the default branch megatron.

Describe alternatives you've considered
Or maybe kuulilennuteetunneliluuk

Additional context
I also like bananas.

[Bug] НС выбрасываСтся ошибка ΠΏΡ€ΠΈ Π½Π΅ΡƒΠ΄Π°Ρ‡Π½ΠΎΠΉ ΠΏΠΎΠΏΡ‹Ρ‚ΠΊΠ΅ получСния Π΄Π°Π½Π½Ρ‹Ρ… ΠΎ Π±ΠΎΡ‚Π΅

The bug

Если ΠΏΡ€ΠΈ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠΈ ΠΊ LongPoll Π½Π΅ ΡƒΠ΄Π°Π»ΠΎΡΡŒ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ ΠΎ Π±ΠΎΡ‚Π΅ (Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€ Telegam Π·Π°Π±Π»ΠΎΠΊΠΈΡ€ΠΎΠ²Π°Π½ Ρƒ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€Π°, Π»ΠΈΠ±ΠΎ любая другая ΠΏΡ€ΠΈΡ‡ΠΈΠ½Π°), Ρ‚ΠΎ промис startPolling Π½Π΅ выбрасываСт ΡΠΎΠΎΡ‚Π²Π΅Ρ‚ΡΡ‚Π²Π΅Π½Π½ΡƒΡŽ ΠΎΡˆΠΈΠ±ΠΊΡƒ.

Environment

package version
puregram 2.1.0
node 16.4.1
TypeScript 4.3.2
yarn or npm 7.18.1

Additional context

https://github.com/nitreojs/puregram/blob/master/packages/puregram/src/updates.ts#L342-L348

`<InlineQueryContext>.answerInlineQuery(...)` throws `Bad Request`

Code

telegram.updates.on('inline_query', (context) => {
  console.log(message);
  return message.answerInlineQuery([{
    type: 'article',
    title: 'foo bar baz',
    input_message_content: {
      message_text: 'fiz'
    }
  }]);
});

Expected behavior

sending an inline query result

Actual behaviour

APIError: Bad Request: can't parse inline query result: Can't find field "id"

Environment

package version
puregram 2.0.4 & 2.2.0

Typesctipt does not comile

The bug

The typescript does not compile when I have used the Puregram package for the TelegramBot.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a TS server with Puregram
  2. Try to build it.

Expected behavior

Typescript builds without errors.

Environment

package version
puregram 2.9.8
node 18.12.1
TypeScript 4.7.4
yarn 1.22.19

Additional context

` node_modules/puregram/lib/common/structures/composer.d.ts:3:22 - error TS2417: Class static side 'typeof import("/path/to/my/app/node_modules/puregram/lib/common/structures/composer").Composer' incorrectly extends base class static side 'typeof import("/path/to/my/app/node_modules/middleware-io/lib/composer").Composer'.
The types of 'builder().middlewares' are incompatible between these types.
Type 'import("/path/to/my/app/node_modules/middleware-io/lib/types").Middleware<import("/path/to/my/app/node_modules/puregram/lib/contexts/context").Context>[]' is not assignable to type 'import("/path/to/my/app/node_modules/middleware-io/lib/types").Middleware[]'.
Type 'import("/path/to/my/app/node_modules/middleware-io/lib/types").Middleware<import("/path/to/my/app/node_modules/puregram/lib/contexts/context").Context>' is not assignable to type 'import("/path/to/my/app/node_modules/middleware-io/lib/types").Middleware'.
Type 'Context' is not assignable to type 'import("/path/to/my/app/node_modules/puregram/lib/contexts/context").Context'.
Type 'UnknownObject' is missing the following properties from type 'Context': telegram, updateType, is, [Symbol.toStringTag]

3 export declare class Composer extends MiddlewareComposer {
~~~~~~~~

node_modules/puregram/lib/common/structures/composer.d.ts:3:77 - error TS2344: Type 'T' does not satisfy the constraint 'UnknownObject'.
Type 'Context' is not assignable to type 'UnknownObject'.
Index signature for type 'string' is missing in type 'Context'.

3 export declare class Composer extends MiddlewareComposer {
~

node_modules/puregram/lib/contexts/chat-join-request.d.ts:17:11 - error TS2320: Interface 'ChatJoinRequestContext' cannot simultaneously extend types 'ChatJoinRequest' and 'TargetMixin'.
Named property 'from' of types 'ChatJoinRequest' and 'TargetMixin' are not identical.

17 interface ChatJoinRequestContext extends Constructor, ChatJoinRequest, TargetMixin, SendMixin, CloneMixin<ChatJoinRequestContext, ChatJoinRequestContextOptions> {
~~~~~~~~~~~~~~~~~~~~~~

node_modules/puregram/lib/contexts/chat-member.d.ts:20:11 - error TS2320: Interface 'ChatMemberContext' cannot simultaneously extend types 'ChatMemberUpdated' and 'TargetMixin'.
Named property 'from' of types 'ChatMemberUpdated' and 'TargetMixin' are not identical.

20 interface ChatMemberContext extends Constructor, ChatMemberUpdated, TargetMixin, SendMixin, CloneMixin<ChatMemberContext, ChatMemberContextOptions> {
~~~~~~~~~~~~~~~~~

node_modules/puregram/lib/contexts/chosen-inline-result.d.ts:25:11 - error TS2320: Interface 'ChosenInlineResultContext' cannot simultaneously extend types 'ChosenInlineResult' and 'SendMixin'.
Named property 'senderId' of types 'ChosenInlineResult' and 'SendMixin' are not identical.

25 interface ChosenInlineResultContext extends Constructor, ChosenInlineResult, SendMixin, CloneMixin<ChosenInlineResultContext, ChosenInlineResultContextOptions> {
~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/puregram/lib/contexts/poll-answer.d.ts:17:11 - error TS2320: Interface 'PollAnswerContext' cannot simultaneously extend types 'PollAnswer' and 'SendMixin'.
Named property 'senderId' of types 'PollAnswer' and 'SendMixin' are not identical.

17 interface PollAnswerContext extends Constructor, PollAnswer, SendMixin, CloneMixin<PollAnswerContext, PollAnswerContextOptions> {
~~~~~~~~~~~~~~~~~

node_modules/puregram/lib/contexts/pre-checkout-query.d.ts:24:11 - error TS2320: Interface 'PreCheckoutQueryContext' cannot simultaneously extend types 'PreCheckoutQuery' and 'SendMixin'.
Named property 'senderId' of types 'PreCheckoutQuery' and 'SendMixin' are not identical.

24 interface PreCheckoutQueryContext extends Constructor, PreCheckoutQuery, SendMixin, CloneMixin<PreCheckoutQueryContext, PreCheckoutQueryContextOptions> {
~~~~~~~~~~~~~~~~~~~~~~~

node_modules/puregram/lib/contexts/shipping-query.d.ts:17:11 - error TS2320: Interface 'ShippingQueryContext' cannot simultaneously extend types 'ShippingQuery' and 'SendMixin'.
Named property 'senderId' of types 'ShippingQuery' and 'SendMixin' are not identical.

17 interface ShippingQueryContext extends Constructor, ShippingQuery, SendMixin, CloneMixin<ShippingQueryContext, ShippingQueryContextOptions> { `

when I call the telegram.updates.StartPolling() function I get an error

The bug

A clear and concise description of what the bug is.

Steps to reproduce

Steps to reproduce the behavior:

  1. I take the current from dotenv insert it into Telegram.FromToken(proccess.env.TOKEN)
  2. when I call the telegram.updates.StartPolling() function I get an error: unable to fetch bot data from the start

Expected behavior

started bot

Screenshots

https://pastenow.ru/6024c955b2e8921638db5d9033d5219e

Environment

package version
puregram ^2.8.2
node 14.20.0
TypeScript not use
yarn or npm npm

Additional context

Add any other context about the problem here.

Issue calling answerPreCheckoutQuery

the bug

I'm trying to handle pre_checkout_query updates and I have this code which throws an error

TypeError: Cannot read properties of undefined (reading 'telegram')
    at answerPreCheckoutQuery (file:///var/task/src/functions/shopTelegramWebhook/handler.mjs:37707:21)
    at handleUpdate (file:///var/task/src/functions/shopTelegramWebhook/handler.mjs:66424:11)
    at Runtime.handler (file:///var/task/src/functions/shopTelegramWebhook/handler.mjs:66369:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Code:

async function handleUpdate({
  update,
  telegram,
}: {
  update: TelegramUpdate;
  telegram: Telegram;
}) {
  const context = telegram.updates.handleUpdate(update);

  if (context?.is("pre_checkout_query")) {
    console.log(context.invoicePayload);
    await context.answerPreCheckoutQuery({ ok: true });
  }
}

Note the invoicePayload is correctly logged from the context.

steps to reproduce

steps to reproduce the behavior:

  1. send update to bot server
  2. call context.answerPreCheckoutQuery({ ok: true })

expected behavior

Expect the call to not throw an error

environment

package version
puregram 2.25.1
TypeScript 5

i did an oopsie

The bug

I shidded my pant :trollface:

Steps to reproduce

Steps to reproduce:

  1. Find girlfriend
  2. This point is unreachable in any programmer's life

sendMediaGroup ignores additional API params

I started using puregram recently (yesterday) and I'm trying to migrate the method I used in telegraf, where when forwarding a media group to the bot it would send the media to some channels.

I've tried several different ways but I always end up getting the error TypeError: Cannot read properties of undefined (reading 'thumb')

I'm not an expert, so I'd like to know what I'm doing wrong.

const getFilesInMediaGroup = async (attachments) => {
    const extractedMedia = [];
    attachments.forEach(attachment => {
        if (attachment.mimeType && attachment.mimeType.slice(0, attachment.mimeType.lastIndexOf('/')) == 'video') {
            //extractedMedia.push(InputMedia.video(MediaSource.fileId(attachment.fileId)))
            extractedMedia.push({
                media: attachment.fileId,
                type: 'video',
                caption: "**My caption\\!**",
		parse_mode: "MarkdownV2",
            });
        }
        if (attachment.bigSize) {
            //extractedMedia.push(InputMedia.photo(MediaSource.fileId(attachment.bigSize.fileId)))
            extractedMedia.push({
                media: attachment.bigSize.fileId,
                type: 'photo',
            });
        }
    });
    return extractedMedia;
}

bot.updates.on('message', async (context) => {
    if (context.isMediaGroup()) {
        let chat_id = '-100******';
        let mediaGroup = await getFilesInMediaGroup(context.mediaGroup.attachments);
        bot.api.sendMediaGroup(chat_id, mediaGroup, {});
        //bot.api.call('sendMediaGroup', { chat_id, mediaGroup });
    }
});

Випизация собствСнной Ρ€Π΅Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ Ρ…Ρ€Π°Π½ΠΈΠ»ΠΈΡ‰Π°.

И снова ΠΏΡ€ΠΈΠ²Π΅Ρ‚. ΠŸΡ‹Ρ‚Π°ΡŽΡΡŒ Π² качСствС storage ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ Redis. ΠŸΠΈΡˆΡƒ свой класс ΠΈΠΌΠΏΠ»Π΅ΠΌΠ΅Π½Ρ‚ΠΈΡ€ΡƒΡŽΡ‰ΠΈΠΉ ΠΌΠ΅Ρ‚ΠΎΠ΄Ρ‹ SessionStorage ΠΈ Π½Π°Ρ‚Ρ‹ΠΊΠ°ΡŽΡΡŒ Π½Π° Π½Π΅ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΡ‹ с Ρ‚ΠΈΠΏΠ°ΠΌΠΈ ΠΈ ΠΎΡ‚Π»ΠΈΡ‡ΠΈΠ΅ ΠΎΡ‚ Ρ‚ΠΎΠ³ΠΎ, Ρ‡Ρ‚ΠΎ Π½Π° Π³ΠΈΡ‚Ρ…Π°Π±Π΅.

Π’ исходном ΠΊΠΎΠ΄Π΅ Π½Π° Π³ΠΈΡ‚Ρ…Π°Π±Π΅, интСрфСйс ΠΈΠΌΠ΅Π΅Ρ‚ ΠΏΡ€Π°Π²ΠΈΠ»ΡŒΠ½ΡƒΡŽ Ρ‚ΠΈΠΏΠΈΠ·Π°Ρ†ΠΈΡŽ (Ρ‚Π°ΠΊ Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€, get ΠΌΠ΅Ρ‚ΠΎΠ΄ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ any ΠΈΠ»ΠΈ undefined).
image

Но Π² Π°ΠΊΡ‚ΡƒΠ°Π»ΡŒΠ½ΠΎΠΉ вСрсии типизация ΠΎΡ‡Π΅Π½ΡŒ странная. Он ΠΎΠΆΠΈΠ΄Π°Π΅Ρ‚ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ (просто ΠΎΠ±ΡŠΠ΅ΠΊΡ‚) ΠΈΠ»ΠΈ Π½ΠΈΡ‡Π΅Π³ΠΎ.
image

И ΠΈΠ·-Π·Π° этого приходится Π΄Π΅Π»Π°Ρ‚ΡŒ Π²ΠΎΡ‚ Ρ‚Π°ΠΊΠΈΠ΅ костыли =)
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.