Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: prepare the repo for a stable release #52

Merged
merged 11 commits into from
Nov 13, 2024
1 change: 0 additions & 1 deletion .tool-versions

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) [year] [fullname]
Copyright (c) 2024 Rogerio Munhoz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## grammY Commands Plugin
# grammY commands

This plugin provides a convenient way to define and manage commands for your grammY bot. It simplifies the process of
setting up commands with scopes and localization.
This plugin provides a convenient way to define and manage commands for your grammY bot.
It simplifies the process of setting up commands with scopes and localization.

## Installation

Expand All @@ -14,7 +14,7 @@ npm i @grammyjs/commands
The main functionality of this plugin is to define your commands, localize them, and give them handlers for each
[scope](https://core.telegram.org/bots/api#botcommandscope), like so:

```typescript
```ts
import { Bot } from "grammy";
import { CommandGroup } from "@grammyjs/commands";

Expand Down Expand Up @@ -50,7 +50,7 @@ will not be registered, and your bot will not respond to those commands.
This plugin provides a shortcut for setting the commands for the current chat. To use it, you need to install the
commands flavor and the plugin itself, like so:

```typescript
```ts
import { Bot, Context } from "grammy";
import { CommandGroup, commands, CommandsFlavor } from "@grammyjs/commands";

Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@
],
"author": "Roz <[email protected]>",
"license": "MIT",
"homepage": "https://grammy.dev/plugins/commands.html",
KnorpelSenf marked this conversation as resolved.
Show resolved Hide resolved
"repository": {
"type": "git",
"url": "git+https://github.com/grammyjs/commands.git"
},
"bugs": {
"url": "https://github.com/grammyjs/commands/issues"
},
"dependencies": {
"@grammyjs/types": "^3.8.1",
"grammy": "^1.17.1",
"ts-pattern": "^5.0.1"
},
Expand All @@ -27,4 +34,4 @@
"files": [
"out"
]
}
}
57 changes: 14 additions & 43 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
## grammY Commands Plugin
# grammY commands

This plugin provides a convenient way to define and manage commands for your grammY bot. It simplifies the process of
setting up commands with scopes and localization.
This commands plugin for [grammY](https://grammy.dev) provides a convenient way to define and manage commands for your grammY bot.
It simplifies the process of setting up commands with scopes and localization.
Please confer the [official documentation](https://grammy.dev/plugins/commands) for this plugin to learn more about this plugin.

roziscoding marked this conversation as resolved.
Show resolved Hide resolved
## Installation
Here is a quickstart to get you up and running, though.

```sh
npm i @grammyjs/commands
```
## Quickstart

## Usage
You can define bot commands using the `CommandGroup` class.
Remember to register it on your bot via `bot.use`.

The main functionality of this plugin is to define your commands, localize them, and give them handlers for each
[scope](https://core.telegram.org/bots/api#botcommandscope), like so:
Finally, this plugin can call `setMyCommands` for you with the commands you defined.
That way, your users see the correct command suggestions in chats with your bot.

```typescript
import { Bot } from "grammy";
import { CommandGroup } from "@grammyjs/commands";
```ts
import { Bot } from "https://deno.land/x/grammy/mod.ts";
import { CommandGroup } from "https://deno.land/x/grammy_commands/mod.ts";

const bot = new Bot("<telegram token>");

Expand All @@ -42,33 +42,4 @@ bot.use(myCommands);
bot.start();
```

It is very important that you call `bot.use` with your instance of the `CommandGroup` class. Otherwise, the command handlers
will not be registered, and your bot will not respond to those commands.

### Context shortcuts

This plugin provides a shortcut for setting the commands for the current chat. To use it, you need to install the
commands flavor and the plugin itself, like so:

```typescript
import { Bot, Context } from "grammy";
import { CommandGroup, commands, CommandsFlavor } from "@grammyjs/commands";

type BotContext = CommandsFlavor;

const bot = new Bot<BotContext>("<telegram_token>");
bot.use(commands());

bot.on("message", async (ctx) => {
const cmds = new CommandGroup();

cmds.command("start", "Initializes bot configuration")
.localize("pt", "start", "Inicializa as configurações do bot");

await ctx.setMyCommands(cmds);

return ctx.reply("Commands set!");
});

bot.start();
```
Be sure to check out [the documentation](https://grammy.dev/plugins/commands).
4 changes: 2 additions & 2 deletions src/deps.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type {
Chat,
LanguageCode,
MessageEntity,
} from "https://lib.deno.dev/x/grammy_types@^v3.8.1/mod.ts";
} from "https://lib.deno.dev/x/grammy@1/types.ts";
export {
LanguageCodes,
} from "https://lib.deno.dev/x/grammy_types@^v3.8.1/mod.ts";
} from "https://lib.deno.dev/x/grammy@1/types.ts";
Loading