create-gramstax 0.8.23 → 0.9.0

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.
@@ -38,7 +38,7 @@
38
38
  "test:all": "bun test test/ e2e/"
39
39
  },
40
40
  "dependencies": {
41
- "gramstax": "^0.8.22",
41
+ "gramstax": "^0.8.24",
42
42
  "dayjs": "^1.11.13"
43
43
  },
44
44
  "peerDependencies": {
@@ -12,8 +12,8 @@ export class BotCore extends Gramstax {
12
12
  return true
13
13
  }
14
14
 
15
- async hookErrorPage(ctx: CtxCore, listenerName: string, error: any, isEdit: boolean) {
16
- await new GeneralStatusPage(ctx).showError(`${listenerName}:hookErrorPage`, error, isEdit)
15
+ async hookErrorPage(ctx: CtxCore, data: NonNullable<Parameters<NonNullable<Gramstax[`hookErrorPage`]>>[1]>) {
16
+ await new GeneralStatusPage(ctx).showError(`${data.listenerName}:hookErrorPage`, data.error, data.isEdit)
17
17
  }
18
18
 
19
19
  async hookErrorInputNotFoundPage(ctx: CtxCore) {
@@ -5,5 +5,5 @@ export class BlankPage extends PageBase {
5
5
  await this.callbackQueryAnswer()
6
6
  }
7
7
 
8
- static template = `<base></base>`
8
+ static template = `<g-base></g-base>`
9
9
  }
@@ -14,7 +14,7 @@ class Helper {
14
14
  }
15
15
  }
16
16
 
17
- class Alert {
17
+ class Main {
18
18
  static async showError(ctx: GeneralStatusPage, funcName: string, error: any, edit = true) {
19
19
  LogHe.errorMake(error, ctx.constructorName, funcName)
20
20
 
@@ -45,27 +45,27 @@ export class GeneralStatusPage extends PageBase {
45
45
  this.constructorName = p?.constructor?.name
46
46
  }
47
47
 
48
- async showError(...args: Parameters<typeof Alert.showError> extends [any, ...infer R] ? R : []) {
49
- await Alert.showError(this, ...args)
48
+ async showError(...args: Parameters<typeof Main.showError> extends [any, ...infer R] ? R : []) {
49
+ await Main.showError(this, ...args)
50
50
  }
51
51
 
52
52
  async showErrorInputNotFound() {
53
- await Alert.showErrorInputNotFound(this)
53
+ await Main.showErrorInputNotFound(this)
54
54
  }
55
55
 
56
56
  static template = `
57
- <base id="${Base.dynamic}">
57
+ <g-base id="${Base.dynamic}">
58
58
  ${this.kbk.home()}
59
- <message>
59
+ <g-message>
60
60
  <b>{~isNotFound ? "🔎 Route Not Found" : "❌ Error Occurred"~}</b>
61
61
 
62
62
  {~isNotFound ? "The requested route does not exist or is unavailable." : "Something went wrong while processing your request. Please try again."~}
63
- </message>
64
- <message lang="id">
63
+ </g-message>
64
+ <g-message lang="id">
65
65
  <b>{~isNotFound ? "🔎 Rute Tidak Ditemukan" : "❌ Terjadi Kesalahan"~}</b>
66
66
 
67
67
  {~isNotFound ? "Rute yang diminta tidak tersedia atau tidak ada." : "Terjadi kesalahan saat memproses permintaan. Silakan coba lagi."~}
68
- </message>
69
- </base>
68
+ </g-message>
69
+ </g-base>
70
70
  `
71
71
  }
@@ -32,24 +32,38 @@ export class HelpPage extends PageBase {
32
32
  }
33
33
 
34
34
  static template = `
35
- <base id="${Base.step1}">
35
+ <g-base id="${Base.step1}">
36
36
  ${this.kbk.back()}
37
- <message>
37
+ <g-message>
38
38
  <b>🆘 Help Message</b>
39
39
 
40
40
  Use this command to get help and instructions.
41
41
 
42
42
  <b>🎰 Random Number</b> - Generate a random number
43
43
  <b>➕ Sum Number</b> - Add two numbers together
44
- </message>
45
- <message lang="id">
44
+
45
+ <details><summary>📋 More commands</summary>
46
+ /start - Show welcome message
47
+ /help - Show this help
48
+ /random - Generate a random number
49
+ /sum - Add two numbers
50
+ </details>
51
+ </g-message>
52
+ <g-message lang="id">
46
53
  <b>🆘 Pesan Bantuan</b>
47
54
 
48
55
  Gunakan perintah ini untuk melihat bantuan dan petunjuk.
49
56
 
50
57
  <b>🎰 Angka Acak</b> - Menghasilkan angka secara acak
51
58
  <b>➕ Jumlah Angka</b> - Menjumlahkan dua angka
52
- </message>
53
- </base>
59
+
60
+ <details><summary>📋 Perintah lainnya</summary>
61
+ /start - Tampilkan pesan selamat datang
62
+ /help - Tampilkan bantuan ini
63
+ /random - Hasilkan angka acak
64
+ /sum - Jumlahkan dua angka
65
+ </details>
66
+ </g-message>
67
+ </g-base>
54
68
  `
55
69
  }
@@ -36,23 +36,23 @@ export class RandomNumberPage extends PageBase {
36
36
  }
37
37
 
38
38
  static template = `
39
- <base id="${Base.step1}">
40
- <keyboard>🎲 Shake, ${this.kbl.back.default}</keyboard>
41
- <keyboard lang="id">🎲 Kocok, ${this.kbl.back.id}</keyboard>
42
- <message>
39
+ <g-base id="${Base.step1}">
40
+ <g-keyboard>🎲 Shake, ${this.kbl.back.default}</g-keyboard>
41
+ <g-keyboard lang="id">🎲 Kocok, ${this.kbl.back.id}</g-keyboard>
42
+ <g-message>
43
43
  <b>🎰 Random Number</b>
44
44
 
45
45
  {{result}}
46
46
 
47
47
  Generated automatically based SCALE 18.
48
- </message>
49
- <message lang="id">
48
+ </g-message>
49
+ <g-message lang="id">
50
50
  <b>🎰 Angka Acak</b>
51
51
 
52
52
  {{result}}
53
53
 
54
54
  Dihasilkan secara otomatis berdasarkan SCALE 18.
55
- </message>
56
- </base>
55
+ </g-message>
56
+ </g-base>
57
57
  `
58
58
  }
@@ -39,10 +39,10 @@ export class StartPage extends PageBase {
39
39
  }
40
40
 
41
41
  static template = `
42
- <base id="${Base.step1}">
43
- <keyboard>🎰 Random Number, ➕ Sum Number, 🆘 Help</keyboard>
44
- <keyboard lang="id">🎰 Angka Acak, ➕ Jumlah Angka, 🆘 Bantuan</keyboard>
45
- <message>
42
+ <g-base id="${Base.step1}">
43
+ <g-keyboard>🎰 Random Number, ➕ Sum Number, 🆘 Help</g-keyboard>
44
+ <g-keyboard lang="id">🎰 Angka Acak, ➕ Jumlah Angka, 🆘 Bantuan</g-keyboard>
45
+ <g-message>
46
46
  <b>👋 Welcome to the bot {{userName}}</b>
47
47
 
48
48
  This bot was initially generated using Gramstax as the base setup and starting structure. It provides a clean foundation that can be extended with custom features, commands, and integrations as needed.
@@ -50,8 +50,12 @@ export class StartPage extends PageBase {
50
50
  <b>🎰 Random Number</b> - Generate a random number
51
51
  <b>➕ Sum Number</b> - Add two numbers together
52
52
  <b>❓ Help</b> - View help and available commands
53
- </message>
54
- <message lang="id">
53
+
54
+ <tg-spoiler>🎁 Hidden tip: try /help for a surprise</tg-spoiler>
55
+
56
+ <a href="https://github.com/gramstax/gramstax">📚 Documentation</a>
57
+ </g-message>
58
+ <g-message lang="id">
55
59
  <b>👋 Selamat datang di bot {{userName}}</b>
56
60
 
57
61
  Bot ini dibuat menggunakan Gramstax sebagai generator awal dan struktur dasar. Dari sini, bot dapat dikembangkan lebih lanjut dengan fitur, perintah, dan integrasi sesuai kebutuhan.
@@ -59,7 +63,11 @@ export class StartPage extends PageBase {
59
63
  <b>🎰 Angka Acak</b> - Menghasilkan angka secara acak
60
64
  <b>➕ Jumlah Angka</b> - Menjumlahkan dua angka
61
65
  <b>❓ Bantuan</b> - Lihat bantuan dan daftar perintah
62
- </message>
63
- </base>
66
+
67
+ <tg-spoiler>🎁 Tips tersembunyi: coba /help untuk kejutan</tg-spoiler>
68
+
69
+ <a href="https://github.com/gramstax/gramstax">📚 Dokumentasi</a>
70
+ </g-message>
71
+ </g-base>
64
72
  `
65
73
  }
@@ -12,18 +12,8 @@ class Helper {
12
12
  return (ctx.temp.session?.params as {step?: (typeof Base)[keyof typeof Base]; left?: number} | undefined) ?? {}
13
13
  }
14
14
 
15
- static kb(ctx: SumNumberPage, baseId: string) {
16
- return ctx.inlineKeyboardT([StartPage], `1`, baseId)
17
- }
18
- }
19
-
20
- class Alert {
21
- static async showSuccess(ctx: SumNumberPage, left: number, right: number) {
22
- await ctx.clearSession()
23
- const bi = Base.success
24
- const kb = Helper.kb(ctx, bi)
25
- const da = {result: left! + right}
26
- await ctx.reply(kb, da, bi)
15
+ static kb(ctx: SumNumberPage, AGBaseId: string) {
16
+ return ctx.inlineKeyboardT([StartPage], `1`, AGBaseId)
27
17
  }
28
18
  }
29
19
 
@@ -62,9 +52,17 @@ class Main {
62
52
  } else if (!Number.isFinite(right ?? NaN)) {
63
53
  await Main.showStep1Form(ctx, false)
64
54
  } else {
65
- await Alert.showSuccess(ctx, left, right)
55
+ await Main.showSuccess(ctx, left, right)
66
56
  }
67
57
  }
58
+
59
+ static async showSuccess(ctx: SumNumberPage, left: number, right: number) {
60
+ await ctx.clearSession()
61
+ const bi = Base.success
62
+ const kb = Helper.kb(ctx, bi)
63
+ const da = {result: left! + right}
64
+ await ctx.reply(kb, da, bi)
65
+ }
68
66
  }
69
67
 
70
68
  export class SumNumberPage extends PageBase {
@@ -88,46 +86,46 @@ export class SumNumberPage extends PageBase {
88
86
  }
89
87
 
90
88
  static template = `
91
- <base id="${Base.step1}">
89
+ <g-base id="${Base.step1}">
92
90
  ${this.kbk.cancel()}
93
- <message>
91
+ <g-message>
94
92
  <b>📚 Input Left Number</b>
95
93
 
96
94
  Example: 23
97
- </message>
98
- <message lang="id">
95
+ </g-message>
96
+ <g-message lang="id">
99
97
  <b>📚 Masukan Angka Kiri</b>
100
98
 
101
99
  Contoh: 23
102
- </message>
103
- </base>
100
+ </g-message>
101
+ </g-base>
104
102
 
105
- <base id="${Base.step2}">
103
+ <g-base id="${Base.step2}">
106
104
  ${this.kbk.cancel()}
107
- <message>
105
+ <g-message>
108
106
  <b>📚 Input Right Number</b>
109
107
 
110
108
  Example: 10
111
- </message>
112
- <message lang="id">
109
+ </g-message>
110
+ <g-message lang="id">
113
111
  <b>📚 Masukan Angka Kanan</b>
114
112
 
115
113
  Contoh: 10
116
- </message>
117
- </base>
114
+ </g-message>
115
+ </g-base>
118
116
 
119
- <base id="${Base.success}">
117
+ <g-base id="${Base.success}">
120
118
  ${this.kbk.home()}
121
- <message>
119
+ <g-message>
122
120
  <b>📚 Result Sum</b>
123
121
 
124
122
  {{result}}
125
- </message>
126
- <message lang="id">
123
+ </g-message>
124
+ <g-message lang="id">
127
125
  <b>📚 Hasil Sum</b>
128
126
 
129
127
  {{result}}
130
- </message>
131
- </base>
128
+ </g-message>
129
+ </g-base>
132
130
  `
133
131
  }
@@ -28,18 +28,18 @@ export class UserNameNotFoundPage extends PageBase {
28
28
  }
29
29
 
30
30
  static template = `
31
- <base id="${Base.step1}">
31
+ <g-base id="${Base.step1}">
32
32
  ${this.kbk.home()}
33
- <message>
33
+ <g-message>
34
34
  <b>⚠️ Username Required</b>
35
35
 
36
36
  Please set the username first before using the bot.
37
- </message>
38
- <message lang="id">
37
+ </g-message>
38
+ <g-message lang="id">
39
39
  <b>⚠️ Username Diperlukan</b>
40
40
 
41
41
  Tolong set username dulu sebelum memakai bot.
42
- </message>
43
- </base>
42
+ </g-message>
43
+ </g-base>
44
44
  `
45
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-gramstax",
3
- "version": "0.8.23",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",