Skip to content

Commit

Permalink
feat: add support for 7.8 Telegram Bot API
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed Jul 31, 2024
1 parent 2788d51 commit 9aa93ce
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Contexts is a great work of the [puregram](https://github.com/nitreojs/puregram) maintainer! Thank you for many code implementation and ideas. Forked since this [commit](https://github.com/nitreojs/puregram/commit/b431d9303de1696999e7f41f45d7c4d7d264c272). (Jan 28, 2024)

Currently, support [Telegram Bot API 7.7](https://core.telegram.org/bots/api-changelog#july-7-2024).
Currently, support [Telegram Bot API 7.8](https://core.telegram.org/bots/api-changelog#july-31-2024).

This library used under the hood in the GramIO framework (Please see [documentation](https://gramio.dev/)).

Expand Down
Binary file modified bun.lockb
Binary file not shown.
86 changes: 42 additions & 44 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
{
"name": "@gramio/contexts",
"version": "0.0.20",
"main": "dist/index.js",
"keywords": [
"gramio",
"contexts",
"updates",
"events",
"telegram",
"telegram-bot",
"telegram-bot-api",
"bot"
],
"files": [
"dist"
],
"devDependencies": {
"@biomejs/biome": "1.7.3",
"@gramio/types": "^7.7.0",
"@types/bun": "^1.1.6",
"common-tags": "^1.8.2",
"inspectable": "^3.0.2",
"madge": "^7.0.0",
"tsup": "^8.1.0",
"typescript": "^5.5.3"
},
"peerDependencies": {
"inspectable": "^3.0.1"
},
"description": "Contexts for GramIO framework",
"scripts": {
"type": "tsc --noEmit",
"lint": "bunx @biomejs/biome check ./src",
"lint:fix": "bun lint --apply",
"prepublishOnly": "tsc && bunx tsc-alias",
"circular": "bunx madge --circular ./src --extensions=ts",
"generate": "bun scripts/generate.ts",
"jsr": "bun scripts/release-jsr.ts"
},
"type": "commonjs",
"types": "dist/index.d.ts",
"dependencies": {
"tslib": "^2.6.3"
}
"name": "@gramio/contexts",
"version": "0.0.21",
"main": "dist/index.js",
"keywords": [
"gramio",
"contexts",
"updates",
"events",
"telegram",
"telegram-bot",
"telegram-bot-api",
"bot"
],
"files": ["dist"],
"devDependencies": {
"@biomejs/biome": "1.7.3",
"@gramio/types": "^7.8.0",
"@types/bun": "^1.1.6",
"common-tags": "^1.8.2",
"inspectable": "^3.0.2",
"madge": "^7.0.0",
"tsup": "^8.2.3",
"typescript": "^5.5.4"
},
"peerDependencies": {
"inspectable": "^3.0.1"
},
"description": "Contexts for GramIO framework",
"scripts": {
"type": "tsc --noEmit",
"lint": "bunx @biomejs/biome check ./src",
"lint:fix": "bun lint --apply",
"prepublishOnly": "tsc && bunx tsc-alias",
"circular": "bunx madge --circular ./src --extensions=ts",
"generate": "bun scripts/generate.ts",
"jsr": "bun scripts/release-jsr.ts"
},
"type": "commonjs",
"types": "dist/index.d.ts",
"dependencies": {
"tslib": "^2.6.3"
}
}
1 change: 1 addition & 0 deletions src/contexts/mixins/chat-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class ChatActionController<Bot extends BotLike> {
while (!this.abortController.signal.aborted) {
try {
await this.context.sendChatAction(this.action, {
// @ts-expect-error fix later
suppress: true,
});

Expand Down
16 changes: 11 additions & 5 deletions src/contexts/mixins/pins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import type { TargetMixin } from "./target";
class PinsMixin<Bot extends BotLike> {
/** Adds message to the list of pinned messages */
pinChatMessage(
params?: Optional<
params: Optional<
TelegramParams.PinChatMessageParams,
"chat_id" | "message_id"
>,
> = {},
) {
if (this.businessConnectionId && !params.business_connection_id)
params.business_connection_id = this.businessConnectionId;

return this.bot.api.pinChatMessage({
chat_id: this.chatId,
message_id: this.id,
Expand All @@ -25,11 +28,14 @@ class PinsMixin<Bot extends BotLike> {

/** Removes message from the list of pinned messages */
unpinChatMessage(
params?: Optional<
params: Optional<
TelegramParams.UnpinChatMessageParams,
"chat_id" | "message_id"
>,
> = {},
) {
if (this.businessConnectionId && !params.business_connection_id)
params.business_connection_id = this.businessConnectionId;

return this.bot.api.unpinChatMessage({
chat_id: this.chatId,
message_id: this.id,
Expand All @@ -39,7 +45,7 @@ class PinsMixin<Bot extends BotLike> {

/** Clears the list of pinned messages */
unpinAllChatMessages(
params?: Optional<TelegramParams.UnpinAllChatMessagesParams, "chat_id">,
params: Optional<TelegramParams.UnpinAllChatMessagesParams, "chat_id"> = {},
) {
return this.bot.api.unpinAllChatMessages({
chat_id: this.chatId,
Expand Down
1 change: 1 addition & 0 deletions src/contexts/mixins/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ class SendMixin<Bot extends BotLike> {
// INFO: kind of a hack for interoperability between TelegramInputMedia objects and sendMedia

if ("media" in query) {
// @ts-expect-error
query[query.type] = query.media;

//delete
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ Pick<
> /** Then, we take our `K` fields and mark them as optional */ & {
[P in K]?: T[P];
} /** Lastly, we add `[key: string]: any;` */ /** Lastly, we add `[key: string]: any;` */ & {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
[key: string]: any;
// // biome-ignore lint/suspicious/noExplicitAny: <explanation>
// [key: string]: any;
};

/** Type util to make chat_id optional and add type property */
Expand Down

0 comments on commit 9aa93ce

Please sign in to comment.