-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2e412e
commit 5696e2f
Showing
29 changed files
with
340 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Command, Ctx, Hears, Help, Start, Update } from 'nestjs-telegraf'; | ||
import { Context } from 'src/core'; | ||
import { Language } from 'src/core/enums/languages.enum'; | ||
import { ReplyUseCases } from 'src/use-cases/reply'; | ||
import { UserUseCases } from 'src/use-cases/user/user.use-case'; | ||
import { Message } from 'telegraf/typings/core/types/typegram'; | ||
|
||
@Update() | ||
export class AppUpdate { | ||
constructor( | ||
private readonly userUseCases: UserUseCases, | ||
private readonly replyUseCases: ReplyUseCases, | ||
) {} | ||
|
||
@Start() | ||
async onStart(@Ctx() ctx: Context) { | ||
// if user does not exist in session, create it | ||
if (!ctx.session.user) { | ||
ctx.session.user = await this.userUseCases.create({ | ||
chatId: ctx.chat.id, | ||
userId: ctx.from.id, | ||
}); | ||
} | ||
|
||
await this.replyUseCases.start(ctx); | ||
} | ||
|
||
@Hears(/🇺🇦|🇬🇧|🇷🇺/) | ||
async onUa(@Ctx() ctx: Context) { | ||
// convert ctx.message to Message.TextMessage so we can access text property | ||
switch ((ctx.message as Message.TextMessage).text) { | ||
case '🇺🇦': | ||
ctx.session.lang = Language.UA; | ||
break; | ||
case '🇬🇧': | ||
ctx.session.lang = Language.EN; | ||
break; | ||
case '🇷🇺': | ||
ctx.session.lang = Language.RU; | ||
break; | ||
} | ||
|
||
await this.replyUseCases.langChanged(ctx); | ||
} | ||
|
||
@Command('language') | ||
async onLanguage(@Ctx() ctx: Context) { | ||
await this.replyUseCases.updateLanguage(ctx); | ||
} | ||
|
||
@Help() | ||
async onHelp(@Ctx() ctx: Context) { | ||
await this.replyUseCases.help(ctx); | ||
} | ||
} |
File renamed without changes.
Empty file.
Oops, something went wrong.