Skip to content

Commit

Permalink
Merge branch 'main' into new-comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
DzikrL authored Jun 17, 2024
2 parents e2ce323 + eda46d6 commit e6f0b35
Show file tree
Hide file tree
Showing 20 changed files with 1,198 additions and 0 deletions.
8 changes: 8 additions & 0 deletions site/docs/.vitepress/configs/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,14 @@ const hostingTutorials = {
text: "Cyclic",
link: "/hosting/cyclic",
},
{
text: "Zeabur (Deno)",
link: "/hosting/zeabur-deno",
},
{
text: "Zeabur (Node.js)",
link: "/hosting/zeabur-nodejs",
},
{
text: "Heroku",
link: "/hosting/heroku",
Expand Down
8 changes: 8 additions & 0 deletions site/docs/.vitepress/configs/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ const hostingTutorials = {
text: "Cyclic",
link: "/es/hosting/cyclic",
},
{
text: "Zeabur (Deno)",
link: "/es/hosting/zeabur-deno",
},
{
text: "Zeabur (Node.js)",
link: "/es/hosting/zeabur-nodejs",
},
{
text: "Heroku",
link: "/es/hosting/heroku",
Expand Down
8 changes: 8 additions & 0 deletions site/docs/.vitepress/configs/locales/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ const hostingTutorials = {
text: "Cyclic",
link: "/id/hosting/cyclic",
},
{
text: "Zeabur (Deno)",
link: "/id/hosting/zeabur-deno",
},
{
text: "Zeabur (Node.js)",
link: "/id/hosting/zeabur-nodejs",
},
{
text: "Heroku",
link: "/id/hosting/heroku",
Expand Down
8 changes: 8 additions & 0 deletions site/docs/.vitepress/configs/locales/uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ const hostingTutorials = {
text: "Cyclic",
link: "/uk/hosting/cyclic",
},
{
text: "Zeabur (Deno)",
link: "/uk/hosting/zeabur-deno",
},
{
text: "Zeabur (Node.js)",
link: "/uk/hosting/zeabur-nodejs",
},
{
text: "Heroku",
link: "/uk/hosting/heroku",
Expand Down
8 changes: 8 additions & 0 deletions site/docs/.vitepress/configs/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ const hostingTutorials = {
text: "Cyclic",
link: "/zh/hosting/cyclic",
},
{
text: "Zeabur (Deno)",
link: "/zh/hosting/zeabur-deno",
},
{
text: "Zeabur (Node.js)",
link: "/zh/hosting/zeabur-nodejs",
},
{
text: "Heroku",
link: "/zh/hosting/heroku",
Expand Down
1 change: 1 addition & 0 deletions site/docs/es/hosting/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ En su lugar, a menudo tendrás que tener una base de datos por separado y conect
| Heroku | $5 | $5 por 1,000 [horas de dyno](https://devcenter.heroku.com/articles/usage-and-billing#dyno-usage-and-costs)/mo | [512MB RAM, se duerme tras 30 minutos de inactividad](https://www.heroku.com/pricing) |||| Deno es compatible con un [paquete de terceros](https://github.com/chibat/heroku-buildpack-deno). |
| DigitalOcean Apps | $5 | | |||| No se ha probado |
| Fastly Compute@Edge | | | |||| |
| Zeabur | $5 | $5/mes suscripción | 2GB RAM, Invocaciones ilimitadas |||| |

### VPS

Expand Down
94 changes: 94 additions & 0 deletions site/docs/es/hosting/zeabur-deno.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
prev: false
next: false
---

# Alojamiento: Zeabur (Deno)

[Zeabur](https://zeabur.com) es una plataforma que te permite desplegar tus aplicaciones full-stack con facilidad.
Soporta varios lenguajes de programación y frameworks, incluyendo Deno y grammY.

Este tutorial te guiará en el despliegue de tus bots grammY con Deno en [Zeabur](https://zeabur.com).

::: tip ¿Buscas la versión para Node.js?
Este tutorial explica cómo desplegar un bot de Telegram en Zeabur usando Deno.
Si estás buscando la versión Node.js, por favor revisa [este tutorial](./zeabur-nodejs) en su lugar.
:::

## Requisitos previos

Para seguir el curso, necesitas tener cuentas [Github](https://github.com) y [Zeabur](https://zeabur.com).

### Método 1: Crear un nuevo proyecto desde cero

> Asegúrese de tener Deno instalado en su máquina local.
Inicialice su proyecto e instale algunas dependencias necesarias:

```sh
# Inicializar el proyecto.
mkdir grammy-bot
cd grammy-bot

# Crear archivo main.ts
touch main.ts

# Crear archivo deno.json para generar archivo de bloqueo
touch deno.json
```

Luego modifica el archivo `main.ts` con el siguiente código:

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

const token = Deno.env.get("TELEGRAM_BOT_TOKEN");
if (!token) throw new Error("TELEGRAM_BOT_TOKEN no está configurado");

const bot = new Bot(token);

bot.command("start", (ctx) => ctx.reply("¡Hola de Deno & grammY!"));

bot.on("message:text", (ctx) => ctx.reply("¿En qué puedo ayudarle?"));

bot.start();
```

> Nota: Obtén tu bot token con [@BotFather](https://t.me/BotFather) en Telegram, y establécelo como variable de entorno `TELEGRAM_BOT_TOKEN` en Zeabur.
>
> Puedes consultar [este tutorial](https://zeabur.com/docs/deploy/variables) para establecer variables de entorno en Zeabur.
Luego ejecuta el siguiente comando para iniciar tu bot:

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

Deno descargará automáticamente las dependencias, generará el archivo de bloqueo e iniciará tu bot.

### Método 2: Utilizar la plantilla de Zeabur

Zeabur ya ha proporcionado una plantilla para su uso.
Puedes encontrarla [aquí](https://github.com/zeabur/deno-telegram-bot-starter).

Puedes usar la plantilla y empezar a escribir el código de tu bot.

## Despliegue

### Método 1: Despliegue desde GitHub en el Dashboard de Zeabur

1. Crea un repositorio en GitHub, puede ser público o privado y empuja tu código a él.
2. Ve a [Zeabur dashboard](https://dash.zeabur.com).
3. Haz click en el botón `New Project`, y haz click en el botón `Deploy New Service`, elige `GitHub` como fuente y selecciona tu repositorio.
4. Ve a la pestaña `Variables` para añadir tus variables de entorno como `TELEGRAM_BOT_TOKEN`.
5. Tu servicio se desplegará automáticamente.

### Método 2: Despliegue con Zeabur CLI

`cd` en el directorio de tu proyecto y ejecuta el siguiente comando:

```sh
npx @zeabur/cli deploy
```

Siga las instrucciones para seleccionar una región para desplegar, y su bot se desplegará automáticamente.
133 changes: 133 additions & 0 deletions site/docs/es/hosting/zeabur-nodejs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
prev: false
next: false
---

# Alojamiento: Zeabur (Node.js)

[Zeabur](https://zeabur.com) es una plataforma que te permite desplegar tus aplicaciones full-stack con facilidad.
Soporta varios lenguajes de programación y frameworks, incluyendo Node.js y grammY.

Este tutorial te guiará sobre cómo desplegar tus bots grammY con Node.js en [Zeabur](https://zeabur.com).

::: tip ¿Buscas la versión de Deno?
Este tutorial explica cómo desplegar un bot de Telegram en Zeabur usando Node.js.
Si estás buscando la versión Deno, por favor revisa [este tutorial](./zeabur-deno) en su lugar.
:::

## Requisitos previos

Para seguir el curso, necesitas tener cuentas [Github](https://github.com) y [Zeabur](https://zeabur.com).

### Método 1: Crear un nuevo proyecto desde cero

Inicialice su proyecto e instale algunas dependencias necesarias:

```sh
# Inicializar el proyecto.
mkdir grammy-bot
cd grammy-bot
pnpm init -y

# Instale las dependencias principales.
pnpm install grammy

# Instale las dependencias de desarrollo.
pnpm install -D typescript

# Inicializar TypeScript.
npx tsc --init
```

Luego, `cd` en `src/`, y crea un archivo llamado `bot.ts`.
Es donde escribirás el código de tu bot.

Ahora, puedes empezar a escribir el código de tu bot en `src/bot.ts`.

```ts
import { Bot } from "grammy";

const bot = new Bot(
process.env.TELEGRAM_BOT_TOKEN || "TELEGRAM_BOT_TOKEN",
);

bot.command("start", (ctx) => ctx.reply("¡Hola de Deno & grammY!"));

bot.on("message:text", (ctx) => ctx.reply("¿En qué puedo ayudarle?"));

bot.start();
```

> Nota: Obtén tu bot token con [@BotFather](https://t.me/BotFather) en Telegram, y establécelo como variable de entorno `TELEGRAM_BOT_TOKEN` en Zeabur.
>
> Puedes consultar [este tutorial](https://zeabur.com/docs/deploy/variables) para establecer variables de entorno en Zeabur.
Ahora el directorio raíz de tu proyecto debería verse así:

```asciiart:no-line-numbers
.
├── node_modules/
├── src/
│ └── bot.ts
├── package.json
├── pnpm-lock.yaml
```

Y luego tenemos que añadir scripts `start` a nuestro `package.json`.
Nuestro `package.json` ahora debe ser similar a esto:

```json
{
"name": "telegram-bot-starter",
"version": "1.0.0",
"description": "Telegram Bot Starter con TypeScript y grammY",
"scripts": {
"start": "ts-node src/bot.ts"
},
"author": "MichaelYuhe",
"license": "MIT",
"dependencies": {
"grammy": "^1.21.1"
},
"devDependencies": {
"typescript": "^5.4.5"
}
}
```

Ahora, puedes ejecutar tu bot localmente ejecutando:

```sh
pnpm start
```

> Nota: Necesitas instalar `ts-node` globalmente para ejecutar el bot localmente.
>
> Puedes instalarlo ejecutando `pnpm install -g ts-node`.
### Método 2: Utilizar la plantilla de Zeabur

Zeabur ya ha proporcionado una plantilla para su uso.
Puedes encontrarla [aquí](https://github.com/zeabur/telegram-bot-starter).

Puedes usar la plantilla y empezar a escribir el código de tu bot.

## Despliegue

### Método 1: Despliegue desde GitHub en el Dashboard de Zeabur

1. Crea un repositorio en GitHub, puede ser público o privado y empuja tu código a él.
2. Ve a [Zeabur dashboard](https://dash.zeabur.com).
3. Haz click en el botón `New Project`, y haz click en el botón `Deploy New Service`, elige `GitHub` como fuente y selecciona tu repositorio.
4. Ve a la pestaña `Variables` para añadir tus variables de entorno como `TELEGRAM_BOT_TOKEN`.
5. Tu servicio se desplegará automáticamente.

### Método 2: Despliegue con Zeabur CLI

`cd` en el directorio de tu proyecto y ejecuta el siguiente comando:

```sh
npx @zeabur/cli deploy
```

Siga las instrucciones para seleccionar una región para desplegar, y su bot se desplegará automáticamente.
1 change: 1 addition & 0 deletions site/docs/hosting/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Instead, you will often have to have a database separately and connect to it if
| Heroku | $5 | $5 for 1,000 [dyno hours](https://devcenter.heroku.com/articles/usage-and-billing#dyno-usage-and-costs)/mo | [512MB RAM, sleeps after 30 mins of inactivity](https://www.heroku.com/pricing) |||| Deno is supported by a [third-party buildpack](https://github.com/chibat/heroku-buildpack-deno). |
| DigitalOcean Apps | $5 | | |||| Not tested |
| Fastly Compute@Edge | | | |||| |
| Zeabur | $5 | $5/mo subscription | 2GB RAM, Unlimited invocations |||| |

### VPS

Expand Down
Loading

0 comments on commit e6f0b35

Please sign in to comment.