create-gramstax 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/templates/package.json +1 -1
- package/dist/src/templates/src/guards/user.ts +1 -1
- package/dist/src/templates/src/pages/general-status.ts +2 -2
- package/dist/src/templates/src/pages/help.ts +4 -4
- package/dist/src/templates/src/pages/random-number.ts +5 -5
- package/dist/src/templates/src/pages/start.ts +5 -5
- package/dist/src/templates/src/pages/sum-number.ts +16 -16
- package/dist/src/templates/src/pages/username-notfound.ts +4 -4
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ export class UserGuard extends GuardBase {
|
|
|
11
11
|
async ensureUsername(edit: boolean) {
|
|
12
12
|
try {
|
|
13
13
|
if (!this.userName || this.userName.length == 0) {
|
|
14
|
-
await new UserNameNotFoundPage(this).
|
|
14
|
+
await new UserNameNotFoundPage(this).showEntryPoint(edit)
|
|
15
15
|
return null
|
|
16
16
|
}
|
|
17
17
|
return {status: true}
|
|
@@ -37,8 +37,8 @@ export class GeneralStatusPage extends PageBase {
|
|
|
37
37
|
this.constructorName = p?.constructor?.name
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async error(
|
|
41
|
-
await Alert.error(this,
|
|
40
|
+
async error(...args: Parameters<typeof Alert.error> extends [any, ...infer R] ? R : []) {
|
|
41
|
+
await Alert.error(this, ...args)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async errorInputNotFound() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {PageBase} from "~/base/page"
|
|
2
2
|
import {StartPage} from "./start"
|
|
3
3
|
|
|
4
|
-
class
|
|
5
|
-
static async
|
|
4
|
+
class Main {
|
|
5
|
+
static async showEntryPoint(ctx: HelpPage, edit = true) {
|
|
6
6
|
const kb = ctx.inlineKeyboardT([StartPage])
|
|
7
7
|
if (edit) {
|
|
8
8
|
await ctx.edit(kb)
|
|
@@ -14,11 +14,11 @@ class Perform {
|
|
|
14
14
|
|
|
15
15
|
export class HelpPage extends PageBase {
|
|
16
16
|
async handleCallbackData() {
|
|
17
|
-
await
|
|
17
|
+
await Main.showEntryPoint(this, true)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async handleCommandText() {
|
|
21
|
-
await
|
|
21
|
+
await Main.showEntryPoint(this, false)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
static template = `
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {PageBase} from "~/base/page"
|
|
2
2
|
import {StartPage} from "./start"
|
|
3
3
|
|
|
4
|
-
class
|
|
5
|
-
static async
|
|
4
|
+
class Main {
|
|
5
|
+
static async showEntryPoint(ctx: RandomNumberPage, edit = true) {
|
|
6
6
|
const kb = ctx.inlineKeyboardT([this, StartPage])
|
|
7
7
|
const da = {result: Math.random() * 10 ** 18}
|
|
8
8
|
if (edit) {
|
|
@@ -15,15 +15,15 @@ class Perform {
|
|
|
15
15
|
|
|
16
16
|
export class RandomNumberPage extends PageBase {
|
|
17
17
|
async handleCallbackData() {
|
|
18
|
-
await
|
|
18
|
+
await Main.showEntryPoint(this, true)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
async handleCommandText() {
|
|
22
|
-
await
|
|
22
|
+
await Main.showEntryPoint(this, false)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async entryPoint(edit = true) {
|
|
26
|
-
await
|
|
26
|
+
await Main.showEntryPoint(this, edit)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
static template = `
|
|
@@ -3,8 +3,8 @@ import {PageBase} from "~/base/page"
|
|
|
3
3
|
import {RandomNumberPage} from "./random-number"
|
|
4
4
|
import {SumNumberPage} from "./sum-number"
|
|
5
5
|
|
|
6
|
-
class
|
|
7
|
-
static async
|
|
6
|
+
class Main {
|
|
7
|
+
static async showEntryPoint(ctx: StartPage, edit = true) {
|
|
8
8
|
await ctx.clearSession()
|
|
9
9
|
const kb = ctx.inlineKeyboardT([RandomNumberPage, SumNumberPage, HelpPage], `2`)
|
|
10
10
|
const da = {userName: ctx.userName}
|
|
@@ -18,15 +18,15 @@ class Perform {
|
|
|
18
18
|
|
|
19
19
|
export class StartPage extends PageBase {
|
|
20
20
|
async handleCallbackData() {
|
|
21
|
-
await
|
|
21
|
+
await Main.showEntryPoint(this, true)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async handleCommandText() {
|
|
25
|
-
await
|
|
25
|
+
await Main.showEntryPoint(this, false)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
async entryPoint(edit = true) {
|
|
29
|
-
await
|
|
29
|
+
await Main.showEntryPoint(this, edit)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
static template = `
|
|
@@ -4,7 +4,7 @@ import {StartPage} from "./start"
|
|
|
4
4
|
class Base {
|
|
5
5
|
static pleft: `pleft`
|
|
6
6
|
static pright: `pright`
|
|
7
|
-
static
|
|
7
|
+
static success: `success`
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
class Helper {
|
|
@@ -17,8 +17,8 @@ class Helper {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
class
|
|
21
|
-
static async
|
|
20
|
+
class Main {
|
|
21
|
+
static async showStep1Form(ctx: SumNumberPage, edit: boolean) {
|
|
22
22
|
await ctx.sessionFreeText({step: `left`})
|
|
23
23
|
const bi = Base.pleft
|
|
24
24
|
const kb = Helper.kb(ctx, bi)
|
|
@@ -30,15 +30,15 @@ class Flow {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
static async
|
|
33
|
+
static async processStep1Answer(ctx: SumNumberPage, left: number) {
|
|
34
34
|
if (!Number.isFinite(left)) {
|
|
35
|
-
await
|
|
35
|
+
await Main.showStep1Form(ctx, false)
|
|
36
36
|
} else {
|
|
37
|
-
await this.
|
|
37
|
+
await this.showStep2Form(ctx, left)
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
static async
|
|
41
|
+
static async showStep2Form(ctx: SumNumberPage, left: number) {
|
|
42
42
|
await ctx.sessionFreeText({step: `right`, left})
|
|
43
43
|
const bi = Base.pright
|
|
44
44
|
const kb = Helper.kb(ctx, bi)
|
|
@@ -46,12 +46,12 @@ class Flow {
|
|
|
46
46
|
await ctx.reply(kb, da, bi)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
static async
|
|
49
|
+
static async processStep2Answer(ctx: SumNumberPage, left: number, right: number) {
|
|
50
50
|
if (!Number.isFinite(right)) {
|
|
51
|
-
await
|
|
51
|
+
await Main.showStep2Form(ctx, right)
|
|
52
52
|
} else if (!Number.isFinite(right ?? NaN)) {
|
|
53
53
|
await ctx.clearSession()
|
|
54
|
-
await
|
|
54
|
+
await Main.showStep1Form(ctx, false)
|
|
55
55
|
} else {
|
|
56
56
|
await Alert.success(ctx, left, right)
|
|
57
57
|
}
|
|
@@ -61,7 +61,7 @@ class Flow {
|
|
|
61
61
|
class Alert {
|
|
62
62
|
static async success(ctx: SumNumberPage, left: number, right: number) {
|
|
63
63
|
await ctx.clearSession()
|
|
64
|
-
const bi = Base.
|
|
64
|
+
const bi = Base.success
|
|
65
65
|
const kb = Helper.kb(ctx, bi)
|
|
66
66
|
const da = {result: left! + right}
|
|
67
67
|
await ctx.reply(kb, da, bi)
|
|
@@ -70,11 +70,11 @@ class Alert {
|
|
|
70
70
|
|
|
71
71
|
export class SumNumberPage extends PageBase {
|
|
72
72
|
async handleCallbackData() {
|
|
73
|
-
await
|
|
73
|
+
await Main.showStep1Form(this, true)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
async handleCommandText() {
|
|
77
|
-
await
|
|
77
|
+
await Main.showStep1Form(this, false)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
async handleFreeText() {
|
|
@@ -85,9 +85,9 @@ export class SumNumberPage extends PageBase {
|
|
|
85
85
|
const input = this.msgText?.trim()
|
|
86
86
|
const value = input ? Number(input) : NaN
|
|
87
87
|
if (step === `left`) {
|
|
88
|
-
await
|
|
88
|
+
await Main.processStep1Answer(this, value)
|
|
89
89
|
} else if (step === `right`) {
|
|
90
|
-
await
|
|
90
|
+
await Main.processStep2Answer(this, left!, value)
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -120,7 +120,7 @@ export class SumNumberPage extends PageBase {
|
|
|
120
120
|
</message>
|
|
121
121
|
</base>
|
|
122
122
|
|
|
123
|
-
<base id="${Base.
|
|
123
|
+
<base id="${Base.success}">
|
|
124
124
|
${this.kbk.home()}
|
|
125
125
|
<message>
|
|
126
126
|
<b>📚 Result Sum</b>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {HelpPage} from "./help"
|
|
2
2
|
import {PageBase} from "~/base/page"
|
|
3
3
|
|
|
4
|
-
class
|
|
5
|
-
static async
|
|
4
|
+
class Main {
|
|
5
|
+
static async showEntryPoint(ctx: UserNameNotFoundPage, edit = true) {
|
|
6
6
|
const kb = ctx.inlineKeyboardT([HelpPage])
|
|
7
7
|
if (edit) {
|
|
8
8
|
await ctx.edit(kb)
|
|
@@ -13,8 +13,8 @@ class Perform {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export class UserNameNotFoundPage extends PageBase {
|
|
16
|
-
async
|
|
17
|
-
await
|
|
16
|
+
async showEntryPoint(edit = true) {
|
|
17
|
+
await Main.showEntryPoint(this, edit)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
static template = `
|