27 lines
852 B
TypeScript
27 lines
852 B
TypeScript
import { Update, Ctx, Start, Help, On, Message } from 'nestjs-telegraf';
|
|
import { Context } from 'telegraf';
|
|
import { UsersService } from '../users/users.service';
|
|
|
|
@Update()
|
|
export class BotService {
|
|
constructor(private readonly usersService: UsersService) { }
|
|
|
|
@Start()
|
|
async start(@Ctx() ctx: Context) {
|
|
const user = ctx.from;
|
|
if (user) {
|
|
this.usersService.create({
|
|
id: user.id,
|
|
fullName: `${user.first_name} ${user.last_name || ''}`.trim(),
|
|
createdAt: new Date().toISOString(),
|
|
});
|
|
await ctx.reply(`Welcome, ${user.first_name}! You have been registered for motivational quotes.`);
|
|
}
|
|
}
|
|
|
|
@Help()
|
|
async help(@Ctx() ctx: Context) {
|
|
await ctx.reply('I will send you a motivational quote every 3 hours.');
|
|
}
|
|
}
|