-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
31 lines (24 loc) · 816 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Telegraf } from 'telegraf';
const bot = new Telegraf(process.env.TOKEN);
const commands = [
{ command: "start", description: "Inicia el bot" },
{ command: "fox", description: "Envia imagen de un zorro" }
]
bot.start((ctx) => {
ctx.reply("Hola soy Pangolin, pulsa en menú para ver mis comandos!");
});
bot.help((ctx) => {
const text = commands.map(comando => `/${comando.command}: ${comando.description}`).join("\n");
ctx.reply(text);
})
bot.command('hello', (ctx) => {
ctx.reply('Hello!');
});
bot.command('fox', async (ctx) => {
const response = await fetch('https://api.tinyfox.dev/img.json?animal=fox');
const buffer = await (response.json());
ctx.reply("https://api.tinyfox.dev" + buffer.loc);
});
bot.telegram.setMyCommands(commands);
bot.launch();
console.log("Running bot")