Initial commit
This commit is contained in:
26
src/bot/bot.service.ts
Normal file
26
src/bot/bot.service.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user