OS
Size: a a a
OS
DS
DS
DS
DS
W
// start.jsНо если этих composer-ов больше, и их уровень вложенности тоже больше, то и работать это будет медленнее что-ли, потому что вместо одного middleware тут несколько вложенных
import { Composer } from 'telegraf';
const composer = new Composer();
composer.start((ctx) => ctx.reply('Hello, world!'));
composer.command('hello', (ctx) => ctx.reply('Hello!'));
export default composer;
// index.js
import { Telegraf } from 'telegraf';
import start from './start';
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.use(start);
bot.launch();
// start.jsТак же, вариант, который пришел мне в голову, когда я подумал, что не хочу передавать бота, как параметр:
export default function (bot) {
bot.start((ctx) => ctx.reply('Hello, world!'));
bot.command('hello', (ctx) => ctx.reply('Hello!'));
}
// index.js
import { Telegraf } from 'telegraf';
import start from './start';
const bot = new Telegraf(process.env.BOT_TOKEN);
start(bot);
bot.launch();
// bot.jsКакой из этих вариантов лучше? Почему? Есть ли варианты лучше, чем эти?
import { Telegraf } from 'telegraf';
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.launch();
export default bot;
// start.js
import bot from './bot';
bot.start((ctx) => ctx.reply('Hello, world!'));
bot.command('hello', (ctx) => ctx.reply('Hello!'));
// index.js
import './bot';
import './start';
I
// start.jsНо если этих composer-ов больше, и их уровень вложенности тоже больше, то и работать это будет медленнее что-ли, потому что вместо одного middleware тут несколько вложенных
import { Composer } from 'telegraf';
const composer = new Composer();
composer.start((ctx) => ctx.reply('Hello, world!'));
composer.command('hello', (ctx) => ctx.reply('Hello!'));
export default composer;
// index.js
import { Telegraf } from 'telegraf';
import start from './start';
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.use(start);
bot.launch();
// start.jsТак же, вариант, который пришел мне в голову, когда я подумал, что не хочу передавать бота, как параметр:
export default function (bot) {
bot.start((ctx) => ctx.reply('Hello, world!'));
bot.command('hello', (ctx) => ctx.reply('Hello!'));
}
// index.js
import { Telegraf } from 'telegraf';
import start from './start';
const bot = new Telegraf(process.env.BOT_TOKEN);
start(bot);
bot.launch();
// bot.jsКакой из этих вариантов лучше? Почему? Есть ли варианты лучше, чем эти?
import { Telegraf } from 'telegraf';
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.launch();
export default bot;
// start.js
import bot from './bot';
bot.start((ctx) => ctx.reply('Hello, world!'));
bot.command('hello', (ctx) => ctx.reply('Hello!'));
// index.js
import './bot';
import './start';
i
I
W
DS
// start.jsНо если этих composer-ов больше, и их уровень вложенности тоже больше, то и работать это будет медленнее что-ли, потому что вместо одного middleware тут несколько вложенных
import { Composer } from 'telegraf';
const composer = new Composer();
composer.start((ctx) => ctx.reply('Hello, world!'));
composer.command('hello', (ctx) => ctx.reply('Hello!'));
export default composer;
// index.js
import { Telegraf } from 'telegraf';
import start from './start';
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.use(start);
bot.launch();
// start.jsТак же, вариант, который пришел мне в голову, когда я подумал, что не хочу передавать бота, как параметр:
export default function (bot) {
bot.start((ctx) => ctx.reply('Hello, world!'));
bot.command('hello', (ctx) => ctx.reply('Hello!'));
}
// index.js
import { Telegraf } from 'telegraf';
import start from './start';
const bot = new Telegraf(process.env.BOT_TOKEN);
start(bot);
bot.launch();
// bot.jsКакой из этих вариантов лучше? Почему? Есть ли варианты лучше, чем эти?
import { Telegraf } from 'telegraf';
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.launch();
export default bot;
// start.js
import bot from './bot';
bot.start((ctx) => ctx.reply('Hello, world!'));
bot.command('hello', (ctx) => ctx.reply('Hello!'));
// index.js
import './bot';
import './start';
W
I
DS
DS
DS
W
W
JD
// start.jsНо если этих composer-ов больше, и их уровень вложенности тоже больше, то и работать это будет медленнее что-ли, потому что вместо одного middleware тут несколько вложенных
import { Composer } from 'telegraf';
const composer = new Composer();
composer.start((ctx) => ctx.reply('Hello, world!'));
composer.command('hello', (ctx) => ctx.reply('Hello!'));
export default composer;
// index.js
import { Telegraf } from 'telegraf';
import start from './start';
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.use(start);
bot.launch();
// start.jsТак же, вариант, который пришел мне в голову, когда я подумал, что не хочу передавать бота, как параметр:
export default function (bot) {
bot.start((ctx) => ctx.reply('Hello, world!'));
bot.command('hello', (ctx) => ctx.reply('Hello!'));
}
// index.js
import { Telegraf } from 'telegraf';
import start from './start';
const bot = new Telegraf(process.env.BOT_TOKEN);
start(bot);
bot.launch();
// bot.jsКакой из этих вариантов лучше? Почему? Есть ли варианты лучше, чем эти?
import { Telegraf } from 'telegraf';
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.launch();
export default bot;
// start.js
import bot from './bot';
bot.start((ctx) => ctx.reply('Hello, world!'));
bot.command('hello', (ctx) => ctx.reply('Hello!'));
// index.js
import './bot';
import './start';
DS