Skip to content

Instantly share code, notes, and snippets.

@vay3t

vay3t/blog.md Secret

Last active November 19, 2020 02:04
Show Gist options
  • Save vay3t/29f65b41e034c97648b9364dcf1a3b58 to your computer and use it in GitHub Desktop.
Save vay3t/29f65b41e034c97648b9364dcf1a3b58 to your computer and use it in GitHub Desktop.

Creando un bot en Telegram con Bash y Curl

Creando y configurando el bot con BotFather

Antes que nada necesitamos buscar el bot BotFather que nos ayudará a crear y administrar nuestros bots dandonos un token para poder usarlos.

FOTO 1:

7fe7f49ffaf56d4f8886bf696fe0867e.png

En el bot se pueden usar las siguientes opciones:

FOTO 2:

93d2b6a1f3b8e9aa1fcc58383a0acea7.png

Para añadir nuestro bot tenemos que usar el comando /newbot, colocar un titulo al bot y un nombre de usuario para poder identificarlo entre todos los usuarios y bots existentes. Luego de eso nos dará el link del bot y un API token para poder trabajarlo.

FOTO 3:

c3288a0d56a797c04437988e81c0ab2e.png

Programando el bot

Ya creado el bot lo buscamos y damos a /start

FOTO 4:

0ddde4184acf5b9be3d3548cc4fc0499.png

Para poder obtener nuestro id de char necesitamos enviar un mensaje al bot:

FOTO 5:

f30bc154164185dfe93ce5eba51da899.png

Obtener id del chat:

https://gist.github.com/2f11867d65d428b9308338519d124584

Comando:

https://gist.github.com/336ce58ba0b212ee5ddbe26803fb5006

FOTO 6:

3b2d6936bec39d9aea991480a1353300.png

  • En el archivo ~/.bashrc:

https://gist.github.com/cddd1a67c123eaa2c956154268cf4ee6

Luego se ejecuta el comando para que se pueda ejecutar la funcion pusher como si fuera un comando

https://gist.github.com/cbcb303a5e430bfbe44c12b1c8a5a14e

Tenemos tres formas de ejecutar:

  • stdin
  • input por argumentos
  • sin argumentos

FOTO 7:

28dd12fe95f5dd01c21a2c01c6d06ef4.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment