@wasserstoff/mangi-tg-bot
Version:
A powerful Telegram Bot SDK with built-in authentication, session management, and database integration
40 lines • 1.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.welcomeFeature = void 0;
const grammy_1 = require("grammy");
const logger_1 = require("../helper/logger");
const composer = new grammy_1.Composer();
exports.welcomeFeature = composer;
const feature = composer.chatType("private");
feature.command("start", (0, logger_1.logHandle)("command-start"), async (ctx) => {
// Log session data for debugging
if (ctx.config?.isDev) {
ctx.logger.info(`Session data for user ${ctx.from?.id}: ${JSON.stringify(ctx.session)}`);
}
// Show token info in response
let welcomeMessage = "Welcome to the bot!";
if (ctx.session?.jwtToken) {
const tokenPreview = ctx.session.jwtToken.substring(0, 10) + "...";
welcomeMessage += `\n\nYou are authenticated with token: ${tokenPreview}`;
}
else {
welcomeMessage += "\n\nYou are not authenticated yet.";
}
await ctx.reply(welcomeMessage, {
reply_markup: {
inline_keyboard: [[{ text: "Say hi!", callback_data: "say_hi" }]],
},
parse_mode: "HTML",
});
});
// Add a debug command to check session
feature.command("debug", async (ctx) => {
if (ctx.config?.isDev) {
ctx.logger.debug(`Debug command - Session: ${JSON.stringify(ctx.session)}`);
}
const sessionInfo = JSON.stringify(ctx.session, null, 2);
await ctx.reply(`Your session data:\n\n<pre>${sessionInfo}</pre>`, {
parse_mode: "HTML"
});
});
//# sourceMappingURL=welcome.js.map