// index.ts
main.pipe(
Logger.withMinimumLogLevel(LogLevel.Info),
Effect.provideServiceEffect(Bot.Bot, Bot.makeBot),
Effect.runPromise
);
// Main.ts
export const main = Effect.all([
Bot.command("start")(Bot.reply("Welcome! Up and running.")),
Bot.on("message")(Bot.reply("Got another message!")),
Bot.startPolling,
]);
// Bot.ts
export const makeBot = Effect.gen(function* (_) {
Effect.logInfo("Creating bot");
const token = yield* _(Config.string("BOT_TOKEN"));
const bot = yield* _(Effect.try(() => new Grammy.Bot(token)));
return bot;
});
export const startPolling = Effect.gen(function* (_) {
Effect.logInfo("Starting polling");
const bot = yield* _(Bot);
yield* _(Effect.tryPromise(() => bot.start()));
});
// ... more operations
// index.ts
main.pipe(
Logger.withMinimumLogLevel(LogLevel.Info),
Effect.provideServiceEffect(Bot.Bot, Bot.makeBot),
Effect.runPromise
);
// Main.ts
export const main = Effect.all([
Bot.command("start")(Bot.reply("Welcome! Up and running.")),
Bot.on("message")(Bot.reply("Got another message!")),
Bot.startPolling,
]);
// Bot.ts
export const makeBot = Effect.gen(function* (_) {
Effect.logInfo("Creating bot");
const token = yield* _(Config.string("BOT_TOKEN"));
const bot = yield* _(Effect.try(() => new Grammy.Bot(token)));
return bot;
});
export const startPolling = Effect.gen(function* (_) {
Effect.logInfo("Starting polling");
const bot = yield* _(Bot);
yield* _(Effect.tryPromise(() => bot.start()));
});
// ... more operations