Добавил изображение в меню

- Добавлена команда вывода версии `/version`
This commit is contained in:
2026-01-03 03:04:28 +03:00
parent 44329b8a16
commit b8c2979f99
5 changed files with 26 additions and 5 deletions

1
assets/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
images/*

View File

@@ -1,16 +1,27 @@
import { Bot } from 'grammy'; import { Bot, InputFile } from 'grammy';
import { cmdStart, cmdHelp } from './src/commands'; import { cmdStart, cmdHelp } from './src/commands';
import { menu } from './src/menu'; import { menu } from './src/menu';
import { choice } from './src/utils';
import pkg from './package.json';
const bot = new Bot(process.env.TOKEN); const bot = new Bot(process.env.TOKEN);
bot.use(menu); bot.use(menu);
bot.command('start', cmdStart); bot.command('start', cmdStart);
bot.command('help', cmdHelp); bot.command('help', cmdHelp);
bot.command('menu', async (ctx) => { bot.command('menu', async (ctx) => {
await ctx.reply('🛣️ Навигация', { reply_markup: menu }); const photoFile = new InputFile(`./assets/images/road_${choice([1, 2, 3])}.png`);
await ctx.replyWithPhoto(photoFile, {
caption: '🛣️ \*Навигация, меню или что\\-то такое\\.\\.\\.\*',
reply_markup: menu,
parse_mode: 'MarkdownV2',
});
}); });
bot.on('message', (ctx) => ctx.reply('Got another message!')); bot.command('version', (ctx) => ctx.reply(`Версия: ${pkg.version}`));
bot.on('message', (ctx) => ctx.reply('...'));
bot.start(); bot.start();

View File

@@ -1,6 +1,6 @@
{ {
"name": "emilecok_bot", "name": "emilecok_bot",
"version": "1.0.0", "version": "0.1.0",
"module": "index.ts", "module": "index.ts",
"type": "module", "type": "module",
"private": true, "private": true,

View File

@@ -36,6 +36,12 @@ const menuProjects = (ctx) => {
); );
}; };
const menu = new Menu('main').text('💪🏻 Скиллы', menuSkills).row().text('👔 Проекты', menuProjects).row(); const menu = new Menu('main')
.url('🍞 Записки Соры и Широ', 'https://t.me/qp11db')
.row()
.text('💪🏻 Скиллы', menuSkills)
.row()
.text('👔 Проекты', menuProjects)
.row();
export { menu }; export { menu };

3
src/utils.ts Normal file
View File

@@ -0,0 +1,3 @@
const choice = (list) => list[Math.floor(Math.random() * list.length)];
export { choice };