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

[Portuguese] Translate guide/getting-started.md #895

Closed
wants to merge 12 commits into from
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea/
.DS_Store
.DS_Store
deno.lock
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tasks": {
"check-links": "deno run --allow-read --allow-net https://raw.githubusercontent.com/grammyjs/link-checker/main/main.ts site/docs"
"check-links": "deno run -r --allow-read --allow-net https://raw.githubusercontent.com/grammyjs/link-checker/main/main.ts --clean-url --dir=site/docs"
},
"fmt": {
"proseWrap": "preserve",
Expand Down
2 changes: 0 additions & 2 deletions site/docs/.vitepress/theme/style/_vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
* -------------------------------------------------------------------------- */

:root {
--vp-c-bg: #eeeeee;

--vp-c-brand: #009dca;
--vp-c-brand-dark: #0094bd; // Main button when hovered
--vp-c-brand-darker: #0089af; // Main button when pressed
Expand Down
2 changes: 1 addition & 1 deletion site/docs/advanced/flood.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ From the [Bot FAQ](https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-h
**This only applies to bulk notifications,** i.e. if you proactively message many users.
If you are just responding to messages from users, then it is no problem to send 1,000 or more messages per second.

When the Bot FAQ says that you should _"consider spreading out notifications over large intervals"_, it this does not mean that you should add any artificial delays.
When the Bot FAQ says that you should _"consider spreading out notifications over large intervals"_, this does not mean that you should add any artificial delays.
Instead, the main takeaway here is that sending bulk notifications is a process that will take many hours.
You cannot expect to message all users instantly at the same time.

Expand Down
2 changes: 1 addition & 1 deletion site/docs/es/guide/deployment-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ______________ _____________
```

> Tenga en cuenta que, en realidad, ninguna conexión se mantendría abierta durante horas.
> Las solicitudes de long polling ienen un tiempo de espera por defecto de 30 segundos (para evitar una serie de [problemas técnicos](https://datatracker.ietf.org/doc/html/draft-loreto-http-bidirectional-07#section-5.5)).
> Las solicitudes de long polling ienen un tiempo de espera por defecto de 30 segundos (para evitar una serie de [problemas técnicos](https://datatracker.ietf.org/doc/html/rfc6202#section-5.5)).
> Si no se devuelven nuevos mensajes después de este período de tiempo, la solicitud se cancelará y se volverá a enviar---pero el concepto general sigue siendo el mismo.
Usando un long polling, no necesitas enviar spam a los servidores de Telegram, ¡y aún así recibes nuevos mensajes inmediatamente!
Expand Down
2 changes: 1 addition & 1 deletion site/docs/guide/deployment-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ______________ _____________
```

> Note that in reality, no connection would be kept open for hours.
> Long polling requests have a default timeout of 30 seconds (in order to avoid a number of [technical problems](https://datatracker.ietf.org/doc/html/draft-loreto-http-bidirectional-07#section-5.5)).
> Long polling requests have a default timeout of 30 seconds (in order to avoid a number of [technical problems](https://datatracker.ietf.org/doc/html/rfc6202#section-5.5)).
> If no new messages are returned after this period of time, then the request will be cancelled and resent---but the general concept stays the same.
Using long polling, you don't need to spam Telegram's servers, and still you get new messages immediately!
Expand Down
2 changes: 1 addition & 1 deletion site/docs/id/guide/deployment-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ______________ _____________
```

> Perlu dicatat bahwa pada kenyataannya, tidak ada koneksi yang akan tetap terbuka selama berjam-jam.
> Request long polling mempunyai waktu timeout bawaan selama 30 detik untuk menghindari terjadinya berbagai [masalah teknis](https://datatracker.ietf.org/doc/html/draft-loreto-http-bidirectional-07#section-5.5).
> Request long polling mempunyai waktu timeout bawaan selama 30 detik untuk menghindari terjadinya berbagai [masalah teknis](https://datatracker.ietf.org/doc/html/rfc6202#section-5.5).
> Kalau tidak ada pesan baru yang dikembalikan selama periode waktu tersebut, maka request akan dibatalkan dan dikirimkan kembali---tetapi konsep dasarnya masih tetap sama.
Dengan menggunakan long polling, kamu akan menerima pesan baru yang sama cepatnya, sehingga tidak perlu lagi mengirim spam ke server Telegram.
Expand Down
2 changes: 1 addition & 1 deletion site/docs/id/hosting/cloudflare-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Panduan ini akan menuntun kamu melakukan hosting bot Telegram di Cloudflare Work

::: tip Mencari Versi yang Node.js?
Tutorial ini berisi langkah-langkah untuk men-deploy bot Telegram ke Cloudflare Workers menggunakan Deno.
Jika kamu sedang mencari versi yang Node.js, silahkan beralih ke [tutorial berikut](./cloudflare-workers-nodejs.md).
Jika kamu sedang mencari versi yang Node.js, silahkan beralih ke [tutorial berikut](./cloudflare-workers-nodejs).
:::

## Persiapan
Expand Down
222 changes: 222 additions & 0 deletions site/docs/pt/guide/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
# Primeiros Passos

Crie seu primeiro Bot em minutos. ([Desça um pouco](#getting-started-on-deno) para um guia para um projeto Deno.)

## Primeiros passos no Node.js

> Esse guia assume que você tem o [Node.js](https://nodejs.org) instalado, e o `npm` deve vir com ele.
> Se você não sabe o que são essas coisas, dê uma olhada na nossa [Introdução](./introduction)!

Crie um novo projeto TypeScript e instale o pacote `grammy`.
Para fazer isso, abra um terminal e digite:

::: code-group

```sh [npm]
# Crie um novo diretório e entre nele.
mkdir meu-bot
cd meu-bot

# Configure o TypeScript (ignore esse passo se você usa JavaScript).
npm install -D typescript
npx tsc --init

# Instale o grammY.
npm install grammy
```

```sh [Yarn]
# Crie um novo diretório e entre nele.
mkdir meu-bot
cd meu-bot

# Configure o TypeScript (ignore esse passo se você usa JavaScript).
yarn add typescript -D
npx tsc --init

# Instale o grammY.
yarn add grammy
```

```sh [pnpm]
# Crie um novo diretório e entre nele.
mkdir meu-bot
cd meu-bot

# Configure o TypeScript (ignore esse passo se você usa JavaScript).
pnpm add -D typescript
npx tsc --init

# Instale o grammY.
pnpm add grammy
```

:::

Crie um novo arquivo de texto vazio chamado `bot.ts`, por exemplo.
Sua estrutura de diretórios deve ficar mais ou menos assim:

```asciiart:no-line-numbers
.
├── bot.ts
├── node_modules/
├── package.json
├── package-lock.json
└── tsconfig.json
```

Agora, é hora de abrir o Telegram para criar uma conta de bot e obter um token de bot para ele.
Fale com o [@BotFather](https://t.me/BotFather) para fazer isso.
O token do bot é algo como `123456:aBcDeF_gHiJkLmNoP-q`.
Ele é usado para autenticar seu bot.

Pegou o token? Agora você pode escrever o código do seu bot no arquivo `bot.ts`.
Você pode copiar o seguinte bot de exemplo para esse arquivo, e passar seu token para o construtor `Bot`:

::: code-group

```ts [TypeScript]
import { Bot } from "grammy";

// Crie uma instância da classe `Bot` e passe seu token de bot para ela.
const bot = new Bot(""); // <-- coloque o token do seu bot entre ""

// Agora você pode registrar listeners no objeto `bot`.
// O grammY irá chamar os listeners quando usuários enviarem mensagens para seu bot.

// Trata o comando /start.
bot.command("start", (ctx) => ctx.reply("Boas vindas! Online e roteando 😎"));
// Trata outras mensagens.
bot.on("message", (ctx) => ctx.reply("Chegou outra mensagem!"));

// Agora que você especificou como tratar mensagens, você pode iniciar seu bot.
// Isso irá conectar aos servidores do Telegram e esperar por mensagens.

// Inicia o bot.
bot.start();
```

```js [JavaScript]
const { Bot } = require("grammy");

// Crie uma instância da classe `Bot` e passe seu token de bot para ela.
const bot = new Bot(""); // <-- coloque o token do seu bot entre ""

// Agora você pode registrar listeners no objeto `bot`.
// O grammY irá chamar os listeners quando usuários enviarem mensagens para seu bot.

// Trata o comando /start.
bot.command("start", (ctx) => ctx.reply("Boas vindas! Online e roteando :sunglasses:"));
// Trata outras mensagens.
bot.on("message", (ctx) => ctx.reply("Chegou outra mensagem!"));

// Agora que você especificou como tratar mensagens, você pode iniciar seu bot.
// Isso irá conectar aos servidores do Telegram e esperar por mensagens.

// Inicia o bot.
bot.start();
```

:::

Para compilar o código, execute

```sh
npx tsc
```

no seu terminal.
Isso gera o arquivo JavaScript `bot.js`.

Agora é só executar o bot rodando o comando

```sh
node bot.js
```

no terminal.
E pronto! :tada:

Vá para o Telegram para ver seu bot responder às mensagens!

::: tip Habilitando Logs
Para habilitar alguns logs básicos, execute

```sh
export DEBUG="grammy*"
```

no seu terminal antes de executar `node bot.js`.
Vai ser mais fácil debugar o seu bot assim.
:::

## Primeiros passos no Deno

> Esse guia assume que você tem o [Deno](https://deno.land) instalado.

Crie um novo diretório em algum lugar, e crie um novo arquivo de texto vazio nele, chamado `bot.ts` por exemplo.

```sh
mkdir ./meu-bot
cd ./meu-bot
touch bot.ts
```

Agora, é hora de abrir o Telegram para criar uma conta de bot e obter um token de bot para ele.
Fale com o [@BotFather](https://t.me/BotFather) para fazer isso.
O token do bot é algo como `123456:aBcDeF_gHiJkLmNoP-q`.
Ele é usado para autenticar seu bot.

Pegou o token? Agora você pode escrever o código do seu bot no arquivo `bot.ts`.
Você pode copiar o seguinte bot de exemplo para esse arquivo, e passar seu token para o construtor `Bot`:

```ts
import { Bot } from "https://deno.land/x/grammy/mod.ts";

// Crie uma instância da classe `Bot` e passe seu token de bot para ela.
const bot = new Bot(""); // <-- coloque o token do seu bot entre ""

// Agora você pode registrar listeners no objeto `bot`.
// O grammY irá chamar os listeners quando usuários enviarem mensagens para seu bot.

// Trata o comando /start.
bot.command("start", (ctx) => ctx.reply("Boas vindas! Online e roteando 😎"));
// Trata outras mensagens.
bot.on("message", (ctx) => ctx.reply("Chegou outra mensagem!"));

// Agora que você especificou como tratar mensagens, você pode iniciar seu bot.
// Isso irá conectar aos servidores do Telegram e esperar por mensagens.

// Inicia o bot.
bot.start();
```

Agora é só executar o bot rodando o comando

```sh
deno run --allow-net bot.ts
```

no terminal.
E pronto! :tada:

Vá para o Telegram para ver seu bot responder às mensagens!

::: tip Habilitando Logs
Para habilitar alguns logs básicos, execute

```sh
export DEBUG="grammy*"
```

no seu terminal antes de executar seu bot.
Vai ser mais fácil debugar o seu bot assim.

Além disso, você precisa executar o bot usando

```sh
deno run --allow-net --allow-env bot.ts
```

para que o grammY consiga ler a variável de ambiente `DEBUG`.
:::
2 changes: 1 addition & 1 deletion site/docs/uk/guide/deployment-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ______________ _____________
```

> Зауважте, що насправді жодне зʼєднання не буде відкритим годинами.
> Запити на тривале опитування мають типовий 30-ти секундний тайм-аут, щоб уникнути ряду [технічних проблем](https://datatracker.ietf.org/doc/html/draft-loreto-http-bidirectional-07#section-5.5).
> Запити на тривале опитування мають типовий 30-ти секундний тайм-аут, щоб уникнути ряду [технічних проблем](https://datatracker.ietf.org/doc/html/rfc6202#section-5.5).
> Якщо після цього періоду часу не буде отримано жодного нового повідомлення, запит буде скасовано та надіслано повторно, але загальна концепція залишається незмінною.
Використовуючи тривале опитування, вам не потрібно спамити сервери Telegram, і ви все одно отримуєте нові повідомлення відразу!
Expand Down
2 changes: 1 addition & 1 deletion site/docs/zh/guide/deployment-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ ______________ _____________
```

> 请注意,在现实中,没有连接将保持数小时。
> 长轮询请求的默认超时时间为 30 秒(为了避免一些 [技术问题](https://datatracker.ietf.org/doc/html/draft-loreto-http-bidirectional-07#section-5.5)
> 长轮询请求的默认超时时间为 30 秒(为了避免一些 [技术问题](https://datatracker.ietf.org/doc/html/rfc6202#section-5.5)
> 如果在这段时间之后没有返回任何新消息,那么请求将被取消并重新执行,但总体信息保持不变。
使用长轮询,你不需要污染 Telegram 的服务器,你仍然可以立即得到新的信息!
Expand Down
Loading