π Open source, privacy-first web analytics β a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
import { Injectable } from '@nestjs/common'
import { Markup } from 'telegraf'
import { UserService } from '../../../user/user.service'
import { Context } from '../interface/context.interface'
import { UNLINK_ACCOUNT_SCENE_ID, START_SCENE_ID } from '../telegram.constants'
@Injectable()
export class SettingsScene {
constructor(private readonly userService: UserService) {}
async onSceneEnter(context: Context) {
const user = await this.userService.getUserByTelegramId(context.from.id)
if (!user) {
await context.scene.enter(START_SCENE_ID)
return
}
await context.reply(
'Settings',
Markup.keyboard(['π Unlink account', 'π Back']).oneTime().resize(),
)
}
async onUnlinkAccount(context: Context) {
const user = await this.userService.getUserByTelegramId(context.from.id)
if (!user) {
await context.scene.enter(START_SCENE_ID)
return
}
await context.scene.enter(UNLINK_ACCOUNT_SCENE_ID)
}
async onBack(context: Context) {
const user = await this.userService.getUserByTelegramId(context.from.id)
if (!user) {
await context.scene.enter(START_SCENE_ID)
return
}
await context.scene.enter(START_SCENE_ID)
}
}