create-bunspace 0.3.0 → 0.3.1
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/templates/monorepo/apps/example/package.json +1 -1
- package/dist/templates/monorepo/core/packages/utils/rolldown.config.ts +30 -0
- package/dist/templates/monorepo/tsconfig.json +3 -1
- package/dist/templates/telegram-bot/bun.lock +6 -20
- package/dist/templates/telegram-bot/core/package.json +11 -0
- package/dist/templates/telegram-bot/core/rolldown.config.ts +11 -0
- package/dist/templates/telegram-bot/core/src/config/logging.ts +1 -3
- package/dist/templates/telegram-bot/core/src/handlers/config-export.ts +10 -9
- package/dist/templates/telegram-bot/core/src/handlers/control.ts +30 -21
- package/dist/templates/telegram-bot/core/src/handlers/demo-full.ts +58 -0
- package/dist/templates/telegram-bot/core/src/handlers/demo-keyboard.ts +49 -0
- package/dist/templates/telegram-bot/core/src/handlers/demo-media.ts +163 -0
- package/dist/templates/telegram-bot/core/src/handlers/demo-text.ts +27 -0
- package/dist/templates/telegram-bot/core/src/handlers/health.ts +22 -14
- package/dist/templates/telegram-bot/core/src/handlers/info.ts +21 -23
- package/dist/templates/telegram-bot/core/src/handlers/logs.ts +8 -6
- package/dist/templates/telegram-bot/core/src/index.ts +20 -1
- package/dist/templates/telegram-bot/core/src/utils/formatters.ts +5 -60
- package/dist/templates/telegram-bot/core/tsconfig.json +2 -0
- package/dist/templates/telegram-bot/package.json +3 -2
- package/dist/templates/telegram-bot/packages/utils/package.json +12 -1
- package/dist/templates/telegram-bot/packages/utils/rolldown.config.ts +11 -0
- package/dist/templates/telegram-bot/packages/utils/tsconfig.json +10 -0
- package/dist/templates/telegram-bot/tsconfig.json +7 -2
- package/package.json +1 -1
- package/templates/monorepo/apps/example/package.json +1 -1
- package/templates/monorepo/core/packages/utils/rolldown.config.ts +30 -0
- package/templates/monorepo/tsconfig.json +3 -1
- package/templates/telegram-bot/bun.lock +6 -20
- package/templates/telegram-bot/core/package.json +11 -0
- package/templates/telegram-bot/core/rolldown.config.ts +11 -0
- package/templates/telegram-bot/core/src/config/logging.ts +1 -3
- package/templates/telegram-bot/core/src/handlers/config-export.ts +10 -9
- package/templates/telegram-bot/core/src/handlers/control.ts +30 -21
- package/templates/telegram-bot/core/src/handlers/demo-full.ts +58 -0
- package/templates/telegram-bot/core/src/handlers/demo-keyboard.ts +49 -0
- package/templates/telegram-bot/core/src/handlers/demo-media.ts +163 -0
- package/templates/telegram-bot/core/src/handlers/demo-text.ts +27 -0
- package/templates/telegram-bot/core/src/handlers/health.ts +22 -14
- package/templates/telegram-bot/core/src/handlers/info.ts +21 -23
- package/templates/telegram-bot/core/src/handlers/logs.ts +8 -6
- package/templates/telegram-bot/core/src/index.ts +20 -1
- package/templates/telegram-bot/core/src/utils/formatters.ts +5 -60
- package/templates/telegram-bot/core/tsconfig.json +2 -0
- package/templates/telegram-bot/package.json +3 -2
- package/templates/telegram-bot/packages/utils/package.json +12 -1
- package/templates/telegram-bot/packages/utils/rolldown.config.ts +11 -0
- package/templates/telegram-bot/packages/utils/tsconfig.json +10 -0
- package/templates/telegram-bot/tsconfig.json +7 -2
- package/templates/telegram-bot/core/src/utils/message-builder.ts +0 -180
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TelegramMessageBuilder, fmt } from '@mks2508/telegram-message-builder'
|
|
2
|
+
import type { Context } from 'telegraf'
|
|
3
|
+
|
|
4
|
+
export async function handleTextDemo(ctx: Context): Promise<void> {
|
|
5
|
+
const message = TelegramMessageBuilder.text()
|
|
6
|
+
.title('🎨 Text Formatting Demo')
|
|
7
|
+
.newline()
|
|
8
|
+
.section('Inline Formatting')
|
|
9
|
+
.line('Bold', fmt.bold('This is bold text'))
|
|
10
|
+
.line('Italic', fmt.italic('This is italic text'))
|
|
11
|
+
.line('Code', fmt.code('const x = 1'))
|
|
12
|
+
.line('Link', fmt.link('Click here', 'https://example.com'))
|
|
13
|
+
.newline()
|
|
14
|
+
.section('Special Elements')
|
|
15
|
+
.line('Mention', fmt.mention(123456, 'Username'))
|
|
16
|
+
.line('Hashtag', fmt.hashtag('telegram'))
|
|
17
|
+
.newline()
|
|
18
|
+
.codeBlock(`console.log('Hello from telegram-message-builder!')`, 'javascript')
|
|
19
|
+
.newline()
|
|
20
|
+
.separator()
|
|
21
|
+
.listItem('Feature 1: Fluent API')
|
|
22
|
+
.listItem('Feature 2: Type-safe')
|
|
23
|
+
.listItem('Feature 3: Zero dependencies')
|
|
24
|
+
.build()
|
|
25
|
+
|
|
26
|
+
await ctx.reply(message.text || '', { parse_mode: (message.parse_mode || 'HTML') as any })
|
|
27
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context } from 'telegraf'
|
|
2
2
|
import { getConfig } from '../config/index.js'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { formatUptime } from '../utils/formatters.js'
|
|
4
|
+
import { TelegramMessageBuilder } from '@mks2508/telegram-message-builder'
|
|
5
5
|
import { healthLogger, badge, kv, colors, colorText } from '../middleware/logging.js'
|
|
6
6
|
|
|
7
7
|
export async function handleHealth(ctx: Context): Promise<void> {
|
|
@@ -18,15 +18,21 @@ export async function handleHealth(ctx: Context): Promise<void> {
|
|
|
18
18
|
const uptime = Date.now() - (Date.now() - 10000)
|
|
19
19
|
const memoryUsage = process.memoryUsage()
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
status: 'running' as const,
|
|
23
|
-
mode: config.mode,
|
|
24
|
-
startTime: Date.now() - 10000,
|
|
25
|
-
uptime,
|
|
26
|
-
memoryUsage,
|
|
27
|
-
})
|
|
21
|
+
const mb = (bytes: number) => (bytes / 1024 / 1024).toFixed(2)
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
const message = TelegramMessageBuilder.text()
|
|
24
|
+
.title('🏥 Bot Health Status')
|
|
25
|
+
.newline()
|
|
26
|
+
.line('Status', 'RUNNING', { bold: true })
|
|
27
|
+
.line('Mode', config.mode.toUpperCase())
|
|
28
|
+
.line('Uptime', formatUptime(uptime))
|
|
29
|
+
.newline()
|
|
30
|
+
.section('Memory Usage')
|
|
31
|
+
.text(`RSS: ${mb(memoryUsage.rss)}MB`)
|
|
32
|
+
.text(`Heap: ${mb(memoryUsage.heapUsed)}/${mb(memoryUsage.heapTotal)}MB`)
|
|
33
|
+
.build()
|
|
34
|
+
|
|
35
|
+
await ctx.reply(message.text || '', { parse_mode: (message.parse_mode || 'HTML') as any })
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
export async function handleUptime(ctx: Context): Promise<void> {
|
|
@@ -41,11 +47,12 @@ export async function handleUptime(ctx: Context): Promise<void> {
|
|
|
41
47
|
|
|
42
48
|
const uptime = Date.now() - (Date.now() - 10000)
|
|
43
49
|
|
|
44
|
-
const
|
|
50
|
+
const message = TelegramMessageBuilder.text()
|
|
45
51
|
.title('⏱️ Uptime:')
|
|
46
52
|
.text(formatUptime(uptime))
|
|
53
|
+
.build()
|
|
47
54
|
|
|
48
|
-
await ctx.reply(
|
|
55
|
+
await ctx.reply(message.text || '', { parse_mode: (message.parse_mode || 'HTML') as any })
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
export async function handleStats(ctx: Context): Promise<void> {
|
|
@@ -60,7 +67,7 @@ export async function handleStats(ctx: Context): Promise<void> {
|
|
|
60
67
|
|
|
61
68
|
const config = getConfig()
|
|
62
69
|
|
|
63
|
-
const
|
|
70
|
+
const message = TelegramMessageBuilder.text()
|
|
64
71
|
.title('📊 Bot Statistics')
|
|
65
72
|
.newline()
|
|
66
73
|
.section('Performance')
|
|
@@ -73,6 +80,7 @@ export async function handleStats(ctx: Context): Promise<void> {
|
|
|
73
80
|
.line('Log Level', config.logLevel.toUpperCase())
|
|
74
81
|
.line('Logging Enabled', config.logChatId ? '✅' : '❌')
|
|
75
82
|
.line('Control Enabled', config.controlChatId ? '✅' : '❌')
|
|
83
|
+
.build()
|
|
76
84
|
|
|
77
|
-
await ctx.reply(
|
|
85
|
+
await ctx.reply(message.text || '', { parse_mode: (message.parse_mode || 'HTML') as any })
|
|
78
86
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from 'telegraf'
|
|
2
2
|
import { infoLogger, badge, kv, colors, colorText } from '../middleware/logging.js'
|
|
3
|
-
import {
|
|
3
|
+
import { TelegramMessageBuilder } from '@mks2508/telegram-message-builder'
|
|
4
4
|
|
|
5
5
|
export async function handleGetInfo(ctx: Context): Promise<void> {
|
|
6
6
|
const userId = ctx.from?.id ?? 'unknown'
|
|
@@ -17,16 +17,14 @@ export async function handleGetInfo(ctx: Context): Promise<void> {
|
|
|
17
17
|
const from = ctx.from
|
|
18
18
|
const chat = ctx.chat
|
|
19
19
|
|
|
20
|
-
const builder =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
builder.title('📋 Your Information')
|
|
24
|
-
builder.newline()
|
|
20
|
+
const builder = TelegramMessageBuilder.text()
|
|
21
|
+
.title('📋 Your Information')
|
|
22
|
+
.newline()
|
|
25
23
|
|
|
26
24
|
// User info
|
|
27
25
|
if (from) {
|
|
28
26
|
builder.section('👤 User Info:')
|
|
29
|
-
|
|
27
|
+
.line('User ID', String(from.id), { code: true })
|
|
30
28
|
if (from.username) builder.line('Username', `@${from.username}`)
|
|
31
29
|
if (from.first_name) builder.line('First Name', from.first_name)
|
|
32
30
|
if (from.last_name) builder.line('Last Name', from.last_name)
|
|
@@ -38,8 +36,8 @@ export async function handleGetInfo(ctx: Context): Promise<void> {
|
|
|
38
36
|
// Chat info
|
|
39
37
|
if (chat) {
|
|
40
38
|
builder.section('💬 Chat Info:')
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
.line('Chat ID', String(chat.id), { code: true })
|
|
40
|
+
.line('Type', chat.type)
|
|
43
41
|
if ('title' in chat && chat.title) builder.line('Title', chat.title)
|
|
44
42
|
if ('username' in chat && chat.username) builder.line('Username', `@${chat.username}`)
|
|
45
43
|
if (chat.type === 'supergroup' || chat.type === 'group') {
|
|
@@ -53,7 +51,7 @@ export async function handleGetInfo(ctx: Context): Promise<void> {
|
|
|
53
51
|
const botMention = detectBotMention(msg as unknown as MaybeMessage, botUsername)
|
|
54
52
|
if (botMention.isMentioned) {
|
|
55
53
|
builder.section('🤖 Bot Mention:')
|
|
56
|
-
|
|
54
|
+
.line('Bot mentioned', 'Yes')
|
|
57
55
|
if (botMention.type) builder.line('Mention type', botMention.type)
|
|
58
56
|
if (botMention.replyToBot) builder.text('Replying to bot message')
|
|
59
57
|
builder.newline()
|
|
@@ -64,7 +62,7 @@ export async function handleGetInfo(ctx: Context): Promise<void> {
|
|
|
64
62
|
// Message/Topic info
|
|
65
63
|
if (msg) {
|
|
66
64
|
builder.section('📮 Message Info:')
|
|
67
|
-
|
|
65
|
+
.line('Message ID', String(msg.message_id))
|
|
68
66
|
if ('reply_to_message' in msg && msg.reply_to_message) {
|
|
69
67
|
const replyTo = msg.reply_to_message
|
|
70
68
|
builder.line('Reply to message ID', String(replyTo.message_id))
|
|
@@ -75,31 +73,31 @@ export async function handleGetInfo(ctx: Context): Promise<void> {
|
|
|
75
73
|
const threadId = getThreadId(msg as unknown as MaybeMessage)
|
|
76
74
|
if (threadId) {
|
|
77
75
|
builder.newline()
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
.section('🧵 Thread/Topic:')
|
|
77
|
+
.line('Thread ID', String(threadId), { code: true })
|
|
78
|
+
.text('This message is in a topic')
|
|
79
|
+
.newline()
|
|
82
80
|
infoLogger.info(`Message sent in thread ${threadId} by user ${userId}`)
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
// Configuration tips
|
|
86
84
|
builder.newline()
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
.section('🔧 Configuration:')
|
|
86
|
+
.line('TG_CONTROL_CHAT_ID', String(chat?.id ?? 'N/A'), { code: true })
|
|
87
|
+
.line('TG_AUTHORIZED_USER_IDS', String(from?.id ?? 'N/A'))
|
|
90
88
|
if (threadId) {
|
|
91
89
|
builder.line('TG_CONTROL_TOPIC_ID', String(threadId), { code: true })
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
builder.newline()
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
.text('💡 Copy these values to your .env file')
|
|
94
|
+
.newline()
|
|
95
|
+
.newline()
|
|
96
|
+
.text('💡 Tip: In groups, you can also mention the bot with @username to get this info')
|
|
99
97
|
|
|
100
98
|
const message = builder.build()
|
|
101
99
|
infoLogger.info(`Replying to user ${userId} with info`)
|
|
102
|
-
await ctx.reply(message, { parse_mode:
|
|
100
|
+
await ctx.reply(message.text || '', { parse_mode: (message.parse_mode || 'HTML') as any })
|
|
103
101
|
infoLogger.success(`Info sent to user ${userId}`)
|
|
104
102
|
}
|
|
105
103
|
|
|
@@ -2,7 +2,7 @@ import type { Context, Telegraf } from 'telegraf'
|
|
|
2
2
|
import { getConfig, hasLoggingConfigured } from '../config/index.js'
|
|
3
3
|
import { streamLogger, botLogger, badge, kv, colors, colorText } from '../middleware/logging.js'
|
|
4
4
|
import { formatLogEntry } from '../utils/formatters.js'
|
|
5
|
-
import {
|
|
5
|
+
import { TelegramMessageBuilder } from '@mks2508/telegram-message-builder'
|
|
6
6
|
|
|
7
7
|
const LOG_BUFFER_SIZE = 10
|
|
8
8
|
const LOG_BUFFER_TIMEOUT = 5000
|
|
@@ -103,9 +103,10 @@ export async function handleLogsCommand(ctx: Context): Promise<void> {
|
|
|
103
103
|
const config = getConfig()
|
|
104
104
|
|
|
105
105
|
if (!hasLoggingConfigured()) {
|
|
106
|
-
const
|
|
106
|
+
const message = TelegramMessageBuilder.text()
|
|
107
107
|
.text('❌ Logging is not configured. Set TG_LOG_CHAT_ID environment variable.')
|
|
108
|
-
|
|
108
|
+
.build()
|
|
109
|
+
ctx.reply(message.text || '', { parse_mode: (message.parse_mode || 'HTML') as any })
|
|
109
110
|
return
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -120,8 +121,8 @@ export async function handleLogsCommand(ctx: Context): Promise<void> {
|
|
|
120
121
|
})}`
|
|
121
122
|
)
|
|
122
123
|
|
|
123
|
-
const builder =
|
|
124
|
-
.title('📝 Log Streaming Status
|
|
124
|
+
const builder = TelegramMessageBuilder.text()
|
|
125
|
+
.title('📝 Log Streaming Status')
|
|
125
126
|
.newline()
|
|
126
127
|
.line('Status', status, { code: true })
|
|
127
128
|
.line('Chat ID', String(config.logChatId), { code: true })
|
|
@@ -129,5 +130,6 @@ export async function handleLogsCommand(ctx: Context): Promise<void> {
|
|
|
129
130
|
builder.line('Topic ID', String(config.logTopicId), { code: true })
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
|
|
133
|
+
const message = builder.build()
|
|
134
|
+
ctx.reply(message.text || '', { parse_mode: (message.parse_mode || 'HTML') as any })
|
|
133
135
|
}
|
|
@@ -10,6 +10,10 @@ import { handleGetInfo } from './handlers/info.js'
|
|
|
10
10
|
import { handleStop, handleRestart, handleMode, handleWebhook } from './handlers/control.js'
|
|
11
11
|
import { handleLogsCommand, initializeLogStreamer } from './handlers/logs.js'
|
|
12
12
|
import { handleExportConfig } from './handlers/config-export.js'
|
|
13
|
+
import { handleTextDemo } from './handlers/demo-text.js'
|
|
14
|
+
import { handleKeyboardDemo, handleKeyboardCallback } from './handlers/demo-keyboard.js'
|
|
15
|
+
import { handleMediaDemo, handleMediaCallback } from './handlers/demo-media.js'
|
|
16
|
+
import { handleFullDemo, handleFullDemoCallback } from './handlers/demo-full.js'
|
|
13
17
|
import { auth } from './middleware/auth.js'
|
|
14
18
|
import { initializeFileLogging } from './config/logging.js'
|
|
15
19
|
|
|
@@ -75,7 +79,12 @@ async function main(): Promise<void> {
|
|
|
75
79
|
'/stats - Show statistics\n' +
|
|
76
80
|
'/logs - Check log streaming status\n' +
|
|
77
81
|
'/getinfo - Get your user/chat info for configuration\n' +
|
|
78
|
-
'/mode - Check or change bot mode'
|
|
82
|
+
'/mode - Check or change bot mode\n\n' +
|
|
83
|
+
'*🎨 Demo Commands (telegram-message-builder):*\n' +
|
|
84
|
+
'/textdemo - Text formatting showcase\n' +
|
|
85
|
+
'/keybdemo - Keyboard builder showcase\n' +
|
|
86
|
+
'/mediademo - Media types showcase\n' +
|
|
87
|
+
'/fulldemo - Complete feature demo',
|
|
79
88
|
{ parse_mode: 'Markdown' }
|
|
80
89
|
)
|
|
81
90
|
botManager.incrementMessages()
|
|
@@ -137,6 +146,16 @@ async function main(): Promise<void> {
|
|
|
137
146
|
|
|
138
147
|
bot.command('logs', handleLogsCommand)
|
|
139
148
|
|
|
149
|
+
// Demo commands for telegram-message-builder showcase
|
|
150
|
+
bot.command('textdemo', handleTextDemo)
|
|
151
|
+
bot.command('keybdemo', handleKeyboardDemo)
|
|
152
|
+
bot.command('mediademo', handleMediaDemo)
|
|
153
|
+
bot.command('fulldemo', handleFullDemo)
|
|
154
|
+
|
|
155
|
+
// Callback handlers for demo keyboards
|
|
156
|
+
bot.action(/^(demo_yes|demo_no|demo_refresh|demo_search|full_demo_keyboard)$/, handleKeyboardCallback)
|
|
157
|
+
bot.action(/^(media_photo|media_video|media_document|media_audio|media_voice|full_demo_media)$/, handleMediaCallback)
|
|
158
|
+
|
|
140
159
|
process.once('SIGINT', async () => {
|
|
141
160
|
botLogger.info(`${badge('SHUTDOWN', 'pill')} ${colorText('SIGINT received', colors.warning)}`)
|
|
142
161
|
await instanceManager.releaseLock()
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { TimeConstants } from '../types/constants.js'
|
|
2
2
|
import type { BotStatus } from '../types/bot.js'
|
|
3
|
-
import {
|
|
3
|
+
import { TelegramMessageBuilder, fmt } from '@mks2508/telegram-message-builder'
|
|
4
4
|
|
|
5
|
-
// Re-export
|
|
6
|
-
export {
|
|
7
|
-
export type { FormatType }
|
|
8
|
-
|
|
9
|
-
// Default format mode for the bot (HTML is simpler and more reliable than MarkdownV2)
|
|
10
|
-
export const DEFAULT_FORMAT_MODE: FormatType = 'html'
|
|
5
|
+
// Re-export fmt from telegram-message-builder for convenience
|
|
6
|
+
export { fmt }
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
9
|
* Format uptime in human-readable format
|
|
@@ -45,41 +41,7 @@ export function formatMemory(memoryUsage: {
|
|
|
45
41
|
}
|
|
46
42
|
|
|
47
43
|
/**
|
|
48
|
-
* Format
|
|
49
|
-
*/
|
|
50
|
-
export function formatHealthMessage(status: BotStatus): string {
|
|
51
|
-
return MessageBuilder.markdown()
|
|
52
|
-
.title('🏥 Bot Health Status')
|
|
53
|
-
.newline()
|
|
54
|
-
.line('Status', status.status.toUpperCase(), { bold: true })
|
|
55
|
-
.line('Mode', status.mode.toUpperCase())
|
|
56
|
-
.line('Uptime', formatUptime(status.uptime))
|
|
57
|
-
.newline()
|
|
58
|
-
.title('Memory Usage')
|
|
59
|
-
.text(formatMemory(status.memoryUsage))
|
|
60
|
-
.build()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Format bot statistics using MessageBuilder
|
|
65
|
-
*/
|
|
66
|
-
export function formatStats(stats: {
|
|
67
|
-
messagesProcessed: number
|
|
68
|
-
commandsExecuted: number
|
|
69
|
-
errorsEncountered: number
|
|
70
|
-
}): string {
|
|
71
|
-
return MessageBuilder.markdown()
|
|
72
|
-
.title('📊 Bot Statistics')
|
|
73
|
-
.newline()
|
|
74
|
-
.section('Performance')
|
|
75
|
-
.line('Messages Processed', String(stats.messagesProcessed))
|
|
76
|
-
.line('Commands Executed', String(stats.commandsExecuted))
|
|
77
|
-
.line('Errors Encountered', String(stats.errorsEncountered))
|
|
78
|
-
.build()
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Format a log entry message
|
|
44
|
+
* Format a log entry message for Telegram
|
|
83
45
|
*/
|
|
84
46
|
export function formatLogEntry(
|
|
85
47
|
timestamp: string,
|
|
@@ -97,22 +59,5 @@ export function formatLogEntry(
|
|
|
97
59
|
|
|
98
60
|
const emoji = levelEmoji[level as keyof typeof levelEmoji] || 'ℹ️'
|
|
99
61
|
|
|
100
|
-
return
|
|
101
|
-
.text(`${emoji} [${component}] `)
|
|
102
|
-
.text(message)
|
|
103
|
-
.newline()
|
|
104
|
-
.text(fmt.italic(timestamp))
|
|
105
|
-
.build()
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Format error message
|
|
110
|
-
*/
|
|
111
|
-
export function formatError(error: Error | string): string {
|
|
112
|
-
const message = error instanceof Error ? error.message : String(error)
|
|
113
|
-
return MessageBuilder.markdown()
|
|
114
|
-
.text('❌ ')
|
|
115
|
-
.title('Error:')
|
|
116
|
-
.text(message)
|
|
117
|
-
.build()
|
|
62
|
+
return `${emoji} [${component}] ${message}\n${fmt.italic(timestamp)}`
|
|
118
63
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
7
7
|
"core",
|
|
8
|
-
"
|
|
8
|
+
"packages/*"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"dev": "bun run --filter @mks2508/telegram-bot-core dev",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"typescript": "^5"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@
|
|
42
|
+
"@mks2508/telegram-message-builder": "0.3.1",
|
|
43
|
+
"@mks2508/telegram-bot-utils": "workspace:*",
|
|
43
44
|
"@inquirer/prompts": "^8.1.0",
|
|
44
45
|
"chalk": "^5.6.2",
|
|
45
46
|
"commander": "^14.0.2",
|
|
@@ -2,11 +2,22 @@
|
|
|
2
2
|
"name": "@mks2508/telegram-bot-utils",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "rolldown --config rolldown.config.ts && tsgo --emitDeclarationOnly",
|
|
7
|
+
"dev": "bun run --watch src/index.ts",
|
|
8
|
+
"typecheck": "tsgo --noEmit"
|
|
9
|
+
},
|
|
5
10
|
"exports": {
|
|
6
|
-
".":
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
7
15
|
},
|
|
8
16
|
"dependencies": {
|
|
9
17
|
"@mks2508/better-logger": "^4.0.0",
|
|
10
18
|
"@mks2508/no-throw": "^0.1.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"rolldown": "^1.0.0-beta.58"
|
|
11
22
|
}
|
|
12
23
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"moduleResolution": "bundler",
|
|
9
9
|
"allowImportingTsExtensions": true,
|
|
10
10
|
"verbatimModuleSyntax": true,
|
|
11
|
-
"noEmit":
|
|
11
|
+
"noEmit": false,
|
|
12
12
|
"strict": true,
|
|
13
13
|
"skipLibCheck": true,
|
|
14
14
|
"noFallthroughCasesInSwitch": true,
|
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
"noImplicitOverride": true,
|
|
17
17
|
"noUnusedLocals": false,
|
|
18
18
|
"noUnusedParameters": false,
|
|
19
|
-
"noPropertyAccessFromIndexSignature": false
|
|
19
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
20
|
+
"declaration": true,
|
|
21
|
+
"declarationMap": true,
|
|
22
|
+
"sourceMap": true,
|
|
23
|
+
"outDir": "./dist",
|
|
24
|
+
"declarationDir": "./dist"
|
|
20
25
|
},
|
|
21
26
|
"exclude": ["node_modules", "**/node_modules", "**/dist"]
|
|
22
27
|
}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "bun --watch src/index.ts",
|
|
8
|
-
"build": "bun build src/index.ts --outdir ./dist",
|
|
8
|
+
"build": "bun build src/index.ts --outdir ./dist --sourcemap && tsgo --emitDeclarationOnly",
|
|
9
9
|
"typecheck": "tsgo --noEmit",
|
|
10
10
|
"start": "bun run dist/index.js"
|
|
11
11
|
},
|
|
@@ -11,6 +11,16 @@ export default defineConfig([
|
|
|
11
11
|
},
|
|
12
12
|
external: ['@mks2508/better-logger', '@mks2508/no-throw'],
|
|
13
13
|
},
|
|
14
|
+
{
|
|
15
|
+
input: './src/index.ts',
|
|
16
|
+
output: {
|
|
17
|
+
file: './dist/index.cjs',
|
|
18
|
+
format: 'cjs',
|
|
19
|
+
exports: 'named',
|
|
20
|
+
sourcemap: true,
|
|
21
|
+
},
|
|
22
|
+
external: ['@mks2508/better-logger', '@mks2508/no-throw'],
|
|
23
|
+
},
|
|
14
24
|
{
|
|
15
25
|
input: './src/logger.ts',
|
|
16
26
|
output: {
|
|
@@ -21,6 +31,16 @@ export default defineConfig([
|
|
|
21
31
|
},
|
|
22
32
|
external: ['@mks2508/better-logger'],
|
|
23
33
|
},
|
|
34
|
+
{
|
|
35
|
+
input: './src/logger.ts',
|
|
36
|
+
output: {
|
|
37
|
+
file: './dist/logger.cjs',
|
|
38
|
+
format: 'cjs',
|
|
39
|
+
exports: 'named',
|
|
40
|
+
sourcemap: true,
|
|
41
|
+
},
|
|
42
|
+
external: ['@mks2508/better-logger'],
|
|
43
|
+
},
|
|
24
44
|
{
|
|
25
45
|
input: './src/result.ts',
|
|
26
46
|
output: {
|
|
@@ -31,4 +51,14 @@ export default defineConfig([
|
|
|
31
51
|
},
|
|
32
52
|
external: ['@mks2508/no-throw'],
|
|
33
53
|
},
|
|
54
|
+
{
|
|
55
|
+
input: './src/result.ts',
|
|
56
|
+
output: {
|
|
57
|
+
file: './dist/result.cjs',
|
|
58
|
+
format: 'cjs',
|
|
59
|
+
exports: 'named',
|
|
60
|
+
sourcemap: true,
|
|
61
|
+
},
|
|
62
|
+
external: ['@mks2508/no-throw'],
|
|
63
|
+
},
|
|
34
64
|
]);
|
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
"declaration": true,
|
|
30
30
|
"declarationMap": true,
|
|
31
31
|
"sourceMap": true,
|
|
32
|
-
"removeComments": false
|
|
32
|
+
"removeComments": false,
|
|
33
|
+
"outDir": "./dist",
|
|
34
|
+
"declarationDir": "./dist"
|
|
33
35
|
},
|
|
34
36
|
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
|
|
35
37
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"lockfileVersion": 1,
|
|
3
|
+
"configVersion": 0,
|
|
3
4
|
"workspaces": {
|
|
4
5
|
"": {
|
|
5
6
|
"name": "mks-telegram-bot",
|
|
6
7
|
"dependencies": {
|
|
7
|
-
"@flla/telegram-format": "^3.1.2",
|
|
8
8
|
"@inquirer/prompts": "^8.1.0",
|
|
9
|
+
"@mks2508/telegram-bot-utils": "workspace:*",
|
|
10
|
+
"@mks2508/telegram-message-builder": "0.3.1",
|
|
9
11
|
"chalk": "^5.6.2",
|
|
10
12
|
"commander": "^14.0.2",
|
|
11
13
|
"dotenv": "^17.2.3",
|
|
@@ -27,25 +29,11 @@
|
|
|
27
29
|
"version": "0.1.0",
|
|
28
30
|
"dependencies": {
|
|
29
31
|
"@mks2508/telegram-bot-utils": "workspace:*",
|
|
32
|
+
"@mks2508/telegram-message-builder": "0.3.1",
|
|
30
33
|
"telegraf": "^4.16.3",
|
|
31
34
|
"zod": "^3.24.0",
|
|
32
35
|
},
|
|
33
36
|
},
|
|
34
|
-
"packages/bootstrapper": {
|
|
35
|
-
"name": "@mks2508/bootstrapper",
|
|
36
|
-
"version": "0.1.0",
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@inquirer/prompts": "^8.1.0",
|
|
39
|
-
"@mks2508/better-logger": "^4.0.0",
|
|
40
|
-
"big-integer": "^1.6.52",
|
|
41
|
-
"telegraf": "^4.16.3",
|
|
42
|
-
"telegram": "^2.26.22",
|
|
43
|
-
},
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"@types/node": "^20",
|
|
46
|
-
"typescript": "^5",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
37
|
"packages/utils": {
|
|
50
38
|
"name": "@mks2508/telegram-bot-utils",
|
|
51
39
|
"version": "0.1.0",
|
|
@@ -58,8 +46,6 @@
|
|
|
58
46
|
"packages": {
|
|
59
47
|
"@cryptography/aes": ["@cryptography/aes@0.1.1", "", {}, "sha512-PcYz4FDGblO6tM2kSC+VzhhK62vml6k6/YAkiWtyPvrgJVfnDRoHGDtKn5UiaRRUrvUTTocBpvc2rRgTCqxjsg=="],
|
|
60
48
|
|
|
61
|
-
"@flla/telegram-format": ["@flla/telegram-format@3.1.2", "", {}, "sha512-pmBcT0f2ay77WlVq0EX3KseFp07IXU7QYahsY/Halx4/YnsM70qYeLRBoKysukU/l0ZQ2u15xu9rMECm9ov2+A=="],
|
|
62
|
-
|
|
63
49
|
"@inquirer/ansi": ["@inquirer/ansi@2.0.2", "", {}, "sha512-SYLX05PwJVnW+WVegZt1T4Ip1qba1ik+pNJPDiqvk6zS5Y/i8PhRzLpGEtVd7sW0G8cMtkD8t4AZYhQwm8vnww=="],
|
|
64
50
|
|
|
65
51
|
"@inquirer/checkbox": ["@inquirer/checkbox@5.0.3", "", { "dependencies": { "@inquirer/ansi": "^2.0.2", "@inquirer/core": "^11.1.0", "@inquirer/figures": "^2.0.2", "@inquirer/type": "^4.0.2" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-xtQP2eXMFlOcAhZ4ReKP2KZvDIBb1AnCfZ81wWXG3DXLVH0f0g4obE0XDPH+ukAEMRcZT0kdX2AS1jrWGXbpxw=="],
|
|
@@ -98,14 +84,14 @@
|
|
|
98
84
|
|
|
99
85
|
"@mks2508/better-logger": ["@mks2508/better-logger@4.0.0", "", { "dependencies": { "chalk": "^5.6.2" } }, "sha512-39PYkAKg7kC0ncPjcN5zAwTsLIS+iXoL4294gl3Cm4OAI6sAT7YJ+RccD42Ve5ybRC/TGgJnD0AUH5M26w0pWA=="],
|
|
100
86
|
|
|
101
|
-
"@mks2508/bootstrapper": ["@mks2508/bootstrapper@workspace:packages/bootstrapper"],
|
|
102
|
-
|
|
103
87
|
"@mks2508/no-throw": ["@mks2508/no-throw@0.1.0", "", {}, "sha512-/CI8FqiO3oLw66XIQ07mw13b6PDNh1vit0cGzUBLq5MfJUTKDU0yaKFE0l9CqSpe6xv4n4+z4RWEytP5xePKZQ=="],
|
|
104
88
|
|
|
105
89
|
"@mks2508/telegram-bot-core": ["@mks2508/telegram-bot-core@workspace:core"],
|
|
106
90
|
|
|
107
91
|
"@mks2508/telegram-bot-utils": ["@mks2508/telegram-bot-utils@workspace:packages/utils"],
|
|
108
92
|
|
|
93
|
+
"@mks2508/telegram-message-builder": ["@mks2508/telegram-message-builder@0.3.1", "", {}, "sha512-i/BdbxVq13l8XzCUq8jMkFfYjrTXiCdErpzo9tEazLLqqEucAm2aY9HE5i8U+15mEWeSV4D6I9gfU8a5dSn1Cw=="],
|
|
94
|
+
|
|
109
95
|
"@oxlint/darwin-arm64": ["@oxlint/darwin-arm64@1.38.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-9rN3047QTyA4i73FKikDUBdczRcLtOsIwZ5TsEx5Q7jr5nBjolhYQOFQf9QdhBLdInxw1iX4+lgdMCf1g74zjg=="],
|
|
110
96
|
|
|
111
97
|
"@oxlint/darwin-x64": ["@oxlint/darwin-x64@1.38.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-Y1UHW4KOlg5NvyrSn/bVBQP8/LRuid7Pnu+BWGbAVVsFcK0b565YgMSO3Eu9nU3w8ke91dr7NFpUmS+bVkdkbw=="],
|
|
@@ -3,13 +3,24 @@
|
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
+
"build": "rolldown --config rolldown.config.ts && tsgo --emitDeclarationOnly",
|
|
6
7
|
"dev": "bun run --watch src/index.ts",
|
|
7
8
|
"start": "bun run src/index.ts",
|
|
8
9
|
"typecheck": "tsgo --noEmit"
|
|
9
10
|
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
10
17
|
"dependencies": {
|
|
11
18
|
"@mks2508/telegram-bot-utils": "workspace:*",
|
|
19
|
+
"@mks2508/telegram-message-builder": "0.3.1",
|
|
12
20
|
"telegraf": "^4.16.3",
|
|
13
21
|
"zod": "^3.24.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"rolldown": "^1.0.0-beta.58"
|
|
14
25
|
}
|
|
15
26
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineConfig } from 'rolldown';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
input: './src/index.ts',
|
|
5
|
+
output: {
|
|
6
|
+
file: './dist/index.js',
|
|
7
|
+
format: 'esm',
|
|
8
|
+
sourcemap: true,
|
|
9
|
+
},
|
|
10
|
+
external: ['grammy', 'telegraf', '@mks2508/telegram-bot-utils', '@mks2508/telegram-message-builder', 'zod'],
|
|
11
|
+
});
|