slashvibe-mcp 0.3.21 → 0.3.22
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/LICENSE +21 -0
- package/README.md +280 -47
- package/config.js +36 -31
- package/crypto.js +1 -6
- package/discord.js +19 -19
- package/index.js +217 -207
- package/intelligence/index.js +2 -9
- package/intelligence/infer.js +10 -16
- package/intelligence/patterns.js +23 -18
- package/intelligence/proactive.js +16 -15
- package/intelligence/serendipity.js +57 -20
- package/memory.js +13 -8
- package/notify.js +39 -14
- package/package.json +27 -20
- package/presence.js +2 -2
- package/prompts.js +5 -9
- package/protocol/index.js +123 -87
- package/protocol/telegram-commands.js +36 -37
- package/store/api.js +358 -529
- package/store/local.js +9 -10
- package/store/profiles.js +48 -192
- package/store/reservations.js +2 -9
- package/store/skills.js +69 -71
- package/store/sqlite.js +355 -0
- package/tools/_actions.js +48 -387
- package/tools/_connection-queue.js +45 -56
- package/tools/_discovery-enhanced.js +52 -57
- package/tools/_discovery.js +87 -185
- package/tools/{l2-status.js → _experimental/l2-status.js} +68 -70
- package/tools/{shipback.js → _experimental/shipback.js} +4 -3
- package/tools/_proactive-discovery.js +60 -73
- package/tools/_shared/index.js +41 -64
- package/tools/admin-inbox.js +10 -15
- package/tools/agents.js +1 -1
- package/tools/artifact-create.js +13 -23
- package/tools/artifact-view.js +4 -4
- package/tools/{_deprecated/back.js → back.js} +1 -1
- package/tools/bye.js +3 -5
- package/tools/consent.js +2 -2
- package/tools/context.js +9 -10
- package/tools/crossword.js +3 -2
- package/tools/discover.js +94 -356
- package/tools/dm.js +27 -86
- package/tools/doctor.js +12 -41
- package/tools/drawing.js +34 -20
- package/tools/echo.js +11 -11
- package/tools/feed.js +30 -58
- package/tools/follow.js +64 -187
- package/tools/{_deprecated/forget.js → forget.js} +4 -7
- package/tools/game.js +144 -48
- package/tools/handoff.js +6 -8
- package/tools/help.js +3 -3
- package/tools/idea.js +15 -27
- package/tools/inbox.js +121 -293
- package/tools/init.js +54 -151
- package/tools/invite.js +8 -21
- package/tools/migrate.js +27 -24
- package/tools/multiplayer-game.js +50 -40
- package/tools/{_deprecated/mute.js → mute.js} +4 -3
- package/tools/notifications.js +58 -48
- package/tools/observe.js +12 -15
- package/tools/onboarding.js +8 -11
- package/tools/open.js +13 -144
- package/tools/party-game.js +23 -12
- package/tools/patterns.js +2 -1
- package/tools/ping.js +5 -7
- package/tools/react.js +28 -30
- package/tools/{_deprecated/recall.js → recall.js} +5 -10
- package/tools/release.js +4 -2
- package/tools/{_deprecated/remember.js → remember.js} +4 -6
- package/tools/report.js +2 -2
- package/tools/request.js +6 -26
- package/tools/reserve.js +1 -1
- package/tools/session-fork.js +97 -0
- package/tools/session-save.js +109 -0
- package/tools/settings.js +30 -99
- package/tools/ship.js +74 -56
- package/tools/{_deprecated/skills-exchange.js → skills-exchange.js} +38 -39
- package/tools/social-inbox.js +22 -28
- package/tools/social-post.js +24 -27
- package/tools/solo-game.js +54 -46
- package/tools/start.js +14 -148
- package/tools/status.js +21 -68
- package/tools/submit.js +4 -2
- package/tools/suggest-tags.js +36 -33
- package/tools/summarize.js +19 -16
- package/tools/tag-suggestions.js +72 -73
- package/tools/test.js +1 -1
- package/tools/{_deprecated/tictactoe.js → tictactoe.js} +26 -26
- package/tools/token.js +4 -4
- package/tools/update.js +1 -2
- package/tools/watch.js +132 -112
- package/tools/who.js +20 -40
- package/tools/{_deprecated/wordassociation.js → wordassociation.js} +23 -20
- package/tools/workshop-buddy.js +52 -53
- package/tools/x-mentions.js +0 -1
- package/tools/x-reply.js +0 -1
- package/twitter.js +14 -20
- package/version.json +8 -10
- package/analytics.js +0 -107
- package/auth-store.js +0 -148
- package/auto-update.js +0 -130
- package/bridges/bridge-monitor.js +0 -388
- package/bridges/discord-bot.js +0 -431
- package/bridges/farcaster.js +0 -299
- package/bridges/telegram.js +0 -261
- package/bridges/webhook-health.js +0 -420
- package/bridges/webhook-server.js +0 -437
- package/bridges/whatsapp.js +0 -441
- package/bridges/x-webhook.js +0 -423
- package/games/arcade.js +0 -406
- package/games/chess.js +0 -451
- package/games/colorguess.js +0 -343
- package/games/crossword-words.js +0 -171
- package/games/crossword.js +0 -461
- package/games/drawing.js +0 -347
- package/games/gameroulette.js +0 -300
- package/games/gamerouter.js +0 -336
- package/games/gamestatus.js +0 -337
- package/games/guessnumber.js +0 -209
- package/games/hangman.js +0 -279
- package/games/memory.js +0 -338
- package/games/multiplayer-tictactoe.js +0 -389
- package/games/pixelart.js +0 -399
- package/games/quickduel.js +0 -354
- package/games/riddle.js +0 -371
- package/games/rockpaperscissors.js +0 -291
- package/games/snake.js +0 -406
- package/games/storybuilder.js +0 -343
- package/games/tictactoe.js +0 -345
- package/games/twentyquestions.js +0 -286
- package/games/twotruths.js +0 -207
- package/games/werewolf.js +0 -508
- package/games/wordassociation.js +0 -247
- package/games/wordchain.js +0 -135
- package/intelligence/interests.js +0 -369
- package/notification-emitter.js +0 -77
- package/setup.js +0 -480
- package/smart-inbox.js +0 -276
- package/tools/_deprecated/auto-suggest-connections.js +0 -304
- package/tools/_deprecated/bootstrap-skills.js +0 -231
- package/tools/_deprecated/bridge-dashboard.js +0 -342
- package/tools/_deprecated/bridge-health.js +0 -400
- package/tools/_deprecated/bridge-live.js +0 -384
- package/tools/_deprecated/bridges.js +0 -383
- package/tools/_deprecated/colorguess.js +0 -281
- package/tools/_deprecated/discover-insights.js +0 -379
- package/tools/_deprecated/discover-momentum.js +0 -256
- package/tools/_deprecated/discovery-analytics.js +0 -345
- package/tools/_deprecated/discovery-auto-suggest.js +0 -275
- package/tools/_deprecated/discovery-bootstrap.js +0 -267
- package/tools/_deprecated/discovery-daily.js +0 -375
- package/tools/_deprecated/discovery-dashboard.js +0 -385
- package/tools/_deprecated/discovery-digest.js +0 -314
- package/tools/_deprecated/discovery-hub.js +0 -357
- package/tools/_deprecated/discovery-insights.js +0 -384
- package/tools/_deprecated/discovery-momentum.js +0 -281
- package/tools/_deprecated/discovery-monitor.js +0 -319
- package/tools/_deprecated/discovery-proactive.js +0 -300
- package/tools/_deprecated/draw.js +0 -317
- package/tools/_deprecated/farcaster.js +0 -307
- package/tools/_deprecated/games-catalog.js +0 -376
- package/tools/_deprecated/games.js +0 -313
- package/tools/_deprecated/guessnumber.js +0 -194
- package/tools/_deprecated/hangman.js +0 -129
- package/tools/_deprecated/multiplayer-tictactoe.js +0 -303
- package/tools/_deprecated/riddle.js +0 -240
- package/tools/_deprecated/run-bootstrap.js +0 -69
- package/tools/_deprecated/skills-analytics.js +0 -349
- package/tools/_deprecated/skills-bootstrap.js +0 -301
- package/tools/_deprecated/skills-dashboard.js +0 -268
- package/tools/_deprecated/skills.js +0 -380
- package/tools/_deprecated/smart-intro.js +0 -353
- package/tools/_deprecated/storybuilder.js +0 -331
- package/tools/_deprecated/telegram-bot.js +0 -183
- package/tools/_deprecated/telegram-setup.js +0 -214
- package/tools/_deprecated/twentyquestions.js +0 -143
- package/tools/_shared.js +0 -234
- package/tools/_work-context.js +0 -338
- package/tools/_work-context.manual-test.js +0 -199
- package/tools/_work-context.test.js +0 -260
- package/tools/activity.js +0 -220
- package/tools/agent-treasury.js +0 -288
- package/tools/analytics.js +0 -191
- package/tools/approve.js +0 -197
- package/tools/arcade.js +0 -173
- package/tools/artifacts-price.js +0 -107
- package/tools/ask-expert.js +0 -160
- package/tools/available.js +0 -120
- package/tools/become-expert.js +0 -150
- package/tools/broadcast.js +0 -325
- package/tools/chat.js +0 -202
- package/tools/collaborative-drawing.js +0 -286
- package/tools/connection-status.js +0 -178
- package/tools/earnings.js +0 -126
- package/tools/friends.js +0 -207
- package/tools/genesis.js +0 -233
- package/tools/gig-browse.js +0 -206
- package/tools/gig-complete.js +0 -144
- package/tools/health.js +0 -87
- package/tools/leaderboard.js +0 -117
- package/tools/lib/git-apply.js +0 -206
- package/tools/lib/git-bundle.js +0 -407
- package/tools/mint.js +0 -377
- package/tools/plan.js +0 -225
- package/tools/profile.js +0 -219
- package/tools/proof-of-work.js +0 -144
- package/tools/pulse.js +0 -218
- package/tools/reply.js +0 -166
- package/tools/reputation.js +0 -175
- package/tools/schedule.js +0 -367
- package/tools/search-messages.js +0 -123
- package/tools/session.js +0 -467
- package/tools/session_price.js +0 -128
- package/tools/smart-check.js +0 -201
- package/tools/social-processor.js +0 -445
- package/tools/streak.js +0 -147
- package/tools/stuck.js +0 -297
- package/tools/subscribe.js +0 -148
- package/tools/subscriptions.js +0 -134
- package/tools/tip.js +0 -193
- package/tools/wallet.js +0 -269
- package/tools/webhook-test.js +0 -388
- package/tools/withdraw.js +0 -145
- package/tools/work-summary.js +0 -96
- package/tools/workshop.js +0 -327
- /package/tools/{l2-bridge.js → _experimental/l2-bridge.js} +0 -0
- /package/tools/{l2.js → _experimental/l2.js} +0 -0
- /package/tools/{_deprecated/away.js → away.js} +0 -0
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vibe telegram-bot — Manage Telegram bot connection
|
|
3
|
-
*
|
|
4
|
-
* Set up, test, and manage the /vibe Telegram bot bridge.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const telegram = require('../bridges/telegram');
|
|
8
|
-
const { requireInit, header, divider, success, warning } = require('./_shared');
|
|
9
|
-
|
|
10
|
-
const definition = {
|
|
11
|
-
name: 'vibe_telegram_bot',
|
|
12
|
-
description: 'Manage Telegram bot connection for /vibe bridge',
|
|
13
|
-
inputSchema: {
|
|
14
|
-
type: 'object',
|
|
15
|
-
properties: {
|
|
16
|
-
action: {
|
|
17
|
-
type: 'string',
|
|
18
|
-
enum: ['status', 'test', 'setup', 'webhook'],
|
|
19
|
-
description: 'Action to perform (default: status)'
|
|
20
|
-
},
|
|
21
|
-
chat_id: {
|
|
22
|
-
type: 'string',
|
|
23
|
-
description: 'Chat ID for testing (use with action: test)'
|
|
24
|
-
},
|
|
25
|
-
message: {
|
|
26
|
-
type: 'string',
|
|
27
|
-
description: 'Test message to send (use with action: test)'
|
|
28
|
-
},
|
|
29
|
-
webhook_url: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
description: 'Webhook URL to set (use with action: webhook)'
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
async function handler(args) {
|
|
38
|
-
const initCheck = requireInit();
|
|
39
|
-
if (initCheck) return initCheck;
|
|
40
|
-
|
|
41
|
-
const { action = 'status', chat_id, message, webhook_url } = args;
|
|
42
|
-
|
|
43
|
-
// Check configuration
|
|
44
|
-
const configured = telegram.isConfigured();
|
|
45
|
-
|
|
46
|
-
if (!configured && action !== 'setup') {
|
|
47
|
-
return {
|
|
48
|
-
display: `${header('Telegram Bot')}\n\n${warning('Bot not configured.')}\n\nSet TELEGRAM_BOT_TOKEN in config or run \`vibe telegram-bot --action setup\``
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
switch (action) {
|
|
54
|
-
case 'status':
|
|
55
|
-
return await handleStatus();
|
|
56
|
-
|
|
57
|
-
case 'test':
|
|
58
|
-
return await handleTest(chat_id, message);
|
|
59
|
-
|
|
60
|
-
case 'setup':
|
|
61
|
-
return handleSetup();
|
|
62
|
-
|
|
63
|
-
case 'webhook':
|
|
64
|
-
return await handleWebhook(webhook_url);
|
|
65
|
-
|
|
66
|
-
default:
|
|
67
|
-
return { display: 'Unknown action. Use: status, test, setup, webhook' };
|
|
68
|
-
}
|
|
69
|
-
} catch (e) {
|
|
70
|
-
return {
|
|
71
|
-
display: `${header('Telegram Bot')}\n\n_Error:_ ${e.message}`
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function handleStatus() {
|
|
77
|
-
const botInfo = await telegram.getBotInfo();
|
|
78
|
-
|
|
79
|
-
let display = header('Telegram Bot Status');
|
|
80
|
-
display += '\n\n';
|
|
81
|
-
display += success('✅ Bot configured and connected\n\n');
|
|
82
|
-
display += `**Bot Info:**\n`;
|
|
83
|
-
display += `• Name: ${botInfo.first_name}\n`;
|
|
84
|
-
display += `• Username: @${botInfo.username}\n`;
|
|
85
|
-
display += `• ID: ${botInfo.id}\n`;
|
|
86
|
-
display += `• Can join groups: ${botInfo.can_join_groups ? 'Yes' : 'No'}\n`;
|
|
87
|
-
display += `• Can read all messages: ${botInfo.can_read_all_group_messages ? 'Yes' : 'No'}\n\n`;
|
|
88
|
-
|
|
89
|
-
display += divider();
|
|
90
|
-
display += `**Usage:**\n`;
|
|
91
|
-
display += `• Message @${botInfo.username} on Telegram\n`;
|
|
92
|
-
display += `• Add bot to group chats\n`;
|
|
93
|
-
display += `• Send /vibe commands: /status, /who, /ship\n`;
|
|
94
|
-
display += `• Test with: \`vibe telegram-bot --action test --chat_id YOUR_CHAT_ID --message "hello"\``;
|
|
95
|
-
|
|
96
|
-
return { display };
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function handleTest(chatId, testMessage) {
|
|
100
|
-
if (!chatId) {
|
|
101
|
-
return { display: 'Need --chat_id for testing. Get your chat ID by messaging the bot first.' };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (!testMessage) {
|
|
105
|
-
testMessage = `🧪 Test from /vibe at ${new Date().toLocaleTimeString()}`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const result = await telegram.sendMessage(chatId, testMessage);
|
|
109
|
-
|
|
110
|
-
let display = header('Telegram Test');
|
|
111
|
-
display += '\n\n';
|
|
112
|
-
display += success(`✅ Message sent successfully!\n\n`);
|
|
113
|
-
display += `**Details:**\n`;
|
|
114
|
-
display += `• Chat ID: ${chatId}\n`;
|
|
115
|
-
display += `• Message ID: ${result.message_id}\n`;
|
|
116
|
-
display += `• Content: "${testMessage}"\n`;
|
|
117
|
-
display += `• Sent at: ${new Date(result.date * 1000).toLocaleString()}\n\n`;
|
|
118
|
-
|
|
119
|
-
display += divider();
|
|
120
|
-
display += `Bot is working! You can now:\n`;
|
|
121
|
-
display += `• Set up webhook for real-time updates\n`;
|
|
122
|
-
display += `• Connect bot to /vibe activity notifications`;
|
|
123
|
-
|
|
124
|
-
return { display };
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function handleSetup() {
|
|
128
|
-
let display = header('Telegram Bot Setup');
|
|
129
|
-
display += '\n\n';
|
|
130
|
-
display += `**Step 1: Create bot with @BotFather**\n`;
|
|
131
|
-
display += `1. Open Telegram and search for @BotFather\n`;
|
|
132
|
-
display += `2. Send: /newbot\n`;
|
|
133
|
-
display += `3. Choose a name (e.g., "My Vibe Bot")\n`;
|
|
134
|
-
display += `4. Choose a username (must end in "bot", e.g., "my_vibe_bot")\n`;
|
|
135
|
-
display += `5. Copy the token\n\n`;
|
|
136
|
-
|
|
137
|
-
display += `**Step 2: Configure token**\n`;
|
|
138
|
-
display += `Add to ~/.vibecodings/config.json:\n`;
|
|
139
|
-
display += `\`\`\`json\n`;
|
|
140
|
-
display += `{\n`;
|
|
141
|
-
display += ` "telegram_bot_token": "YOUR_BOT_TOKEN_HERE"\n`;
|
|
142
|
-
display += `}\n`;
|
|
143
|
-
display += `\`\`\`\n\n`;
|
|
144
|
-
|
|
145
|
-
display += `**Step 3: Test connection**\n`;
|
|
146
|
-
display += `Run: \`vibe telegram-bot --action status\`\n\n`;
|
|
147
|
-
|
|
148
|
-
display += `**Step 4: Get your chat ID**\n`;
|
|
149
|
-
display += `1. Message your bot on Telegram\n`;
|
|
150
|
-
display += `2. Run: \`vibe telegram-bot --action test --chat_id YOUR_CHAT_ID\`\n`;
|
|
151
|
-
display += ` (Check Telegram logs for your chat ID)\n\n`;
|
|
152
|
-
|
|
153
|
-
display += divider();
|
|
154
|
-
display += `**Bot Commands (once set up):**\n`;
|
|
155
|
-
display += `• \`/status shipping Building the future\` - Update /vibe status\n`;
|
|
156
|
-
display += `• \`/who\` - See who's online in /vibe\n`;
|
|
157
|
-
display += `• \`/ship\` - Announce completion\n`;
|
|
158
|
-
display += `• \`/dm @handle message\` - Send DM in /vibe`;
|
|
159
|
-
|
|
160
|
-
return { display };
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async function handleWebhook(url) {
|
|
164
|
-
if (!url) {
|
|
165
|
-
return { display: 'Need --webhook_url to set webhook. Example: https://yourapp.vercel.app/api/telegram/webhook' };
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const result = await telegram.setWebhook(url);
|
|
169
|
-
|
|
170
|
-
let display = header('Telegram Webhook');
|
|
171
|
-
display += '\n\n';
|
|
172
|
-
display += success(`✅ Webhook configured!\n\n`);
|
|
173
|
-
display += `**Webhook URL:** ${url}\n`;
|
|
174
|
-
display += `**Status:** Active\n\n`;
|
|
175
|
-
|
|
176
|
-
display += divider();
|
|
177
|
-
display += `The bot will now receive real-time updates.\n`;
|
|
178
|
-
display += `Make sure your webhook endpoint handles POST requests with Telegram update format.`;
|
|
179
|
-
|
|
180
|
-
return { display };
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
module.exports = { definition, handler };
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vibe telegram-setup — Interactive Telegram bot setup
|
|
3
|
-
*
|
|
4
|
-
* One-command setup flow for Telegram bridge with validation.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const telegram = require('../bridges/telegram');
|
|
8
|
-
const config = require('../config');
|
|
9
|
-
const { requireInit, header, divider, success, warning } = require('./_shared');
|
|
10
|
-
|
|
11
|
-
const definition = {
|
|
12
|
-
name: 'vibe_telegram_setup',
|
|
13
|
-
description: 'Interactive setup for Telegram bot bridge with validation',
|
|
14
|
-
inputSchema: {
|
|
15
|
-
type: 'object',
|
|
16
|
-
properties: {
|
|
17
|
-
token: {
|
|
18
|
-
type: 'string',
|
|
19
|
-
description: 'Bot token from @BotFather (optional - will prompt if not provided)'
|
|
20
|
-
},
|
|
21
|
-
webhook_url: {
|
|
22
|
-
type: 'string',
|
|
23
|
-
description: 'Webhook URL for receiving updates (optional)'
|
|
24
|
-
},
|
|
25
|
-
test_chat_id: {
|
|
26
|
-
type: 'string',
|
|
27
|
-
description: 'Your chat ID for testing (optional - get from bot first)'
|
|
28
|
-
},
|
|
29
|
-
skip_test: {
|
|
30
|
-
type: 'boolean',
|
|
31
|
-
description: 'Skip the test message (default: false)'
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
async function handler(args) {
|
|
38
|
-
const initCheck = requireInit();
|
|
39
|
-
if (initCheck) return initCheck;
|
|
40
|
-
|
|
41
|
-
const { token, webhook_url, test_chat_id, skip_test = false } = args;
|
|
42
|
-
|
|
43
|
-
let display = header('Telegram Bot Setup');
|
|
44
|
-
display += '\n\n';
|
|
45
|
-
|
|
46
|
-
// Step 1: Check if already configured
|
|
47
|
-
if (telegram.isConfigured()) {
|
|
48
|
-
display += warning('⚠️ Telegram bot already configured!\n\n');
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
const botInfo = await telegram.getBotInfo();
|
|
52
|
-
display += `Current bot: **@${botInfo.username}** (${botInfo.first_name})\n\n`;
|
|
53
|
-
display += 'To reconfigure, update the token in config.json or provide --token parameter.\n\n';
|
|
54
|
-
|
|
55
|
-
if (!skip_test && test_chat_id) {
|
|
56
|
-
return await testExistingBot(display, test_chat_id);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return { display: display + divider() + 'Bot is ready! Try: `vibe social-inbox --channel telegram`' };
|
|
60
|
-
|
|
61
|
-
} catch (e) {
|
|
62
|
-
display += `❌ Current configuration is invalid: ${e.message}\n\n`;
|
|
63
|
-
display += 'Will proceed with setup...\n\n';
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Step 2: Get/validate token
|
|
68
|
-
let botToken = token;
|
|
69
|
-
|
|
70
|
-
if (!botToken) {
|
|
71
|
-
display += '**Step 1: Create Telegram Bot**\n';
|
|
72
|
-
display += '1. Open Telegram and search for @BotFather\n';
|
|
73
|
-
display += '2. Send: `/newbot`\n';
|
|
74
|
-
display += '3. Follow prompts to choose name and username\n';
|
|
75
|
-
display += '4. Copy the bot token\n\n';
|
|
76
|
-
display += '_Run this command again with: `--token YOUR_BOT_TOKEN`_\n\n';
|
|
77
|
-
display += divider();
|
|
78
|
-
display += '**Example:**\n';
|
|
79
|
-
display += '`vibe telegram-setup --token "123456789:ABCdefGHIjklMNOpqrSTUvwxYZ"`';
|
|
80
|
-
|
|
81
|
-
return { display };
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Step 3: Validate token format
|
|
85
|
-
if (!isValidBotToken(botToken)) {
|
|
86
|
-
display += '❌ Invalid bot token format.\n\n';
|
|
87
|
-
display += 'Token should look like: `123456789:ABCdefGHIjklMNOpqrSTUvwxYZ`\n\n';
|
|
88
|
-
display += 'Get a valid token from @BotFather on Telegram.';
|
|
89
|
-
return { display };
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Step 4: Test the token
|
|
93
|
-
display += '**Testing bot token...**\n';
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
// Temporarily set token for testing
|
|
97
|
-
const tempConfig = { telegram_bot_token: botToken };
|
|
98
|
-
|
|
99
|
-
// Mock the config for this test
|
|
100
|
-
const originalLoad = config.load;
|
|
101
|
-
config.load = () => ({ ...originalLoad(), ...tempConfig });
|
|
102
|
-
|
|
103
|
-
const botInfo = await telegram.getBotInfo();
|
|
104
|
-
|
|
105
|
-
// Restore original config loader
|
|
106
|
-
config.load = originalLoad;
|
|
107
|
-
|
|
108
|
-
display += success(`✅ Token valid! Bot: @${botInfo.username} (${botInfo.first_name})\n\n`);
|
|
109
|
-
|
|
110
|
-
// Step 5: Save to config
|
|
111
|
-
const cfg = config.load();
|
|
112
|
-
cfg.telegram_bot_token = botToken;
|
|
113
|
-
config.save(cfg);
|
|
114
|
-
|
|
115
|
-
display += success('✅ Configuration saved!\n\n');
|
|
116
|
-
|
|
117
|
-
// Step 6: Set webhook if provided
|
|
118
|
-
if (webhook_url) {
|
|
119
|
-
display += '**Setting webhook...**\n';
|
|
120
|
-
try {
|
|
121
|
-
await telegram.setWebhook(webhook_url);
|
|
122
|
-
display += success(`✅ Webhook set: ${webhook_url}\n\n`);
|
|
123
|
-
} catch (e) {
|
|
124
|
-
display += warning(`⚠️ Webhook failed: ${e.message}\n\n`);
|
|
125
|
-
display += 'Bot will work with polling instead.\n\n';
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Step 7: Test message if chat ID provided
|
|
130
|
-
if (!skip_test && test_chat_id) {
|
|
131
|
-
return await testNewBot(display, test_chat_id, botInfo);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Step 8: Instructions for getting chat ID
|
|
135
|
-
display += divider();
|
|
136
|
-
display += '**Next steps:**\n';
|
|
137
|
-
display += `1. Message your bot @${botInfo.username} on Telegram\n`;
|
|
138
|
-
display += '2. Send any message to establish a chat\n';
|
|
139
|
-
display += '3. Test with: `vibe telegram-bot --action test --chat_id YOUR_CHAT_ID`\n\n';
|
|
140
|
-
display += '**Bot commands in Telegram:**\n';
|
|
141
|
-
display += '• `/status mood note` - Update /vibe status\n';
|
|
142
|
-
display += '• `/who` - See who\'s online\n';
|
|
143
|
-
display += '• `/ship message` - Announce completion\n';
|
|
144
|
-
display += '• `/dm @handle message` - Send /vibe DM';
|
|
145
|
-
|
|
146
|
-
return { display };
|
|
147
|
-
|
|
148
|
-
} catch (e) {
|
|
149
|
-
display += `❌ Token test failed: ${e.message}\n\n`;
|
|
150
|
-
display += 'Make sure you copied the complete token from @BotFather.';
|
|
151
|
-
return { display };
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
async function testExistingBot(display, chatId) {
|
|
156
|
-
display += '**Testing existing bot...**\n';
|
|
157
|
-
|
|
158
|
-
try {
|
|
159
|
-
const testMessage = `🧪 /vibe Telegram bridge test at ${new Date().toLocaleTimeString()}`;
|
|
160
|
-
const result = await telegram.sendMessage(chatId, testMessage);
|
|
161
|
-
|
|
162
|
-
display += success(`✅ Test message sent!\n\n`);
|
|
163
|
-
display += `**Message details:**\n`;
|
|
164
|
-
display += `• Chat ID: ${chatId}\n`;
|
|
165
|
-
display += `• Message ID: ${result.message_id}\n`;
|
|
166
|
-
display += `• Timestamp: ${new Date(result.date * 1000).toLocaleString()}\n\n`;
|
|
167
|
-
display += divider();
|
|
168
|
-
display += 'Bridge is working! Check your Telegram for the test message.';
|
|
169
|
-
|
|
170
|
-
} catch (e) {
|
|
171
|
-
display += `❌ Test failed: ${e.message}\n\n`;
|
|
172
|
-
display += 'Check your chat ID or bot permissions.';
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return { display };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
async function testNewBot(display, chatId, botInfo) {
|
|
179
|
-
display += '**Testing new bot...**\n';
|
|
180
|
-
|
|
181
|
-
try {
|
|
182
|
-
const testMessage = `🎉 Welcome to /vibe! Your @${botInfo.username} bridge is now active.\n\nTry these commands:\n• /status shipping "building the future"\n• /who\n• /ship`;
|
|
183
|
-
|
|
184
|
-
const result = await telegram.sendMessage(chatId, testMessage);
|
|
185
|
-
|
|
186
|
-
display += success(`✅ Welcome message sent!\n\n`);
|
|
187
|
-
display += `**Setup complete:**\n`;
|
|
188
|
-
display += `• Bot: @${botInfo.username}\n`;
|
|
189
|
-
display += `• Chat: ${chatId}\n`;
|
|
190
|
-
display += `• Message ID: ${result.message_id}\n\n`;
|
|
191
|
-
display += divider();
|
|
192
|
-
display += success('🚀 Telegram bridge is live!\n\n');
|
|
193
|
-
display += '**What works now:**\n';
|
|
194
|
-
display += '• Receive /vibe notifications in Telegram\n';
|
|
195
|
-
display += '• Control /vibe from Telegram with bot commands\n';
|
|
196
|
-
display += '• Post to multiple channels: `vibe social-post "hello" --channels ["telegram"]`';
|
|
197
|
-
|
|
198
|
-
} catch (e) {
|
|
199
|
-
display += warning(`⚠️ Test message failed: ${e.message}\n\n`);
|
|
200
|
-
display += `Setup is complete, but couldn\'t send test message to chat ${chatId}.\n\n`;
|
|
201
|
-
display += 'Make sure you\'ve messaged the bot first, then try:\n';
|
|
202
|
-
display += '`vibe telegram-bot --action test --chat_id YOUR_CHAT_ID`';
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return { display };
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function isValidBotToken(token) {
|
|
209
|
-
// Telegram bot tokens have format: nnnnnnnnnn:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
210
|
-
// Where n is digits and x is alphanumeric
|
|
211
|
-
return /^\d{8,10}:[a-zA-Z0-9_-]{35}$/.test(token);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
module.exports = { definition, handler };
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vibe twenty-questions — Play 20 questions guessing game
|
|
3
|
-
*
|
|
4
|
-
* I think of something, you ask yes/no questions to guess what it is!
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const config = require('../config');
|
|
8
|
-
const store = require('../store');
|
|
9
|
-
const { createGamePayload } = require('../protocol');
|
|
10
|
-
const { requireInit } = require('./_shared');
|
|
11
|
-
|
|
12
|
-
// 20 Questions game implementation
|
|
13
|
-
const twentyQuestions = require('../games/twentyquestions');
|
|
14
|
-
|
|
15
|
-
const definition = {
|
|
16
|
-
name: 'vibe_twenty_questions',
|
|
17
|
-
description: 'Play 20 questions - I think of something, you guess it with yes/no questions',
|
|
18
|
-
inputSchema: {
|
|
19
|
-
type: 'object',
|
|
20
|
-
properties: {
|
|
21
|
-
question: {
|
|
22
|
-
type: 'string',
|
|
23
|
-
description: 'Yes/no question to ask, or "new" to start a new game'
|
|
24
|
-
},
|
|
25
|
-
category: {
|
|
26
|
-
type: 'string',
|
|
27
|
-
description: 'Category for new games (animals, objects, food, places, activities)',
|
|
28
|
-
enum: ['animals', 'objects', 'food', 'places', 'activities']
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
required: []
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get latest 20 questions game state for user
|
|
37
|
-
*/
|
|
38
|
-
async function getLatestTwentyQuestionsState(handle) {
|
|
39
|
-
// Get user's thread with themselves (for single-player games)
|
|
40
|
-
const thread = await store.getThread(handle, handle);
|
|
41
|
-
|
|
42
|
-
// Find the most recent 20 questions game
|
|
43
|
-
for (let i = thread.length - 1; i >= 0; i--) {
|
|
44
|
-
const msg = thread[i];
|
|
45
|
-
if (msg.payload?.type === 'game' && msg.payload?.game === 'twentyquestions') {
|
|
46
|
-
return msg.payload.state;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function handler(args) {
|
|
53
|
-
const initCheck = requireInit();
|
|
54
|
-
if (initCheck) return initCheck;
|
|
55
|
-
|
|
56
|
-
const { question, category } = args;
|
|
57
|
-
const myHandle = config.getHandle();
|
|
58
|
-
|
|
59
|
-
// Get current game state
|
|
60
|
-
let gameState = await getLatestTwentyQuestionsState(myHandle);
|
|
61
|
-
|
|
62
|
-
// Start new game
|
|
63
|
-
if (!gameState || question === 'new' || (gameState.gameOver && !question)) {
|
|
64
|
-
gameState = twentyQuestions.createInitialTwentyQuestionsState('guess', null, category);
|
|
65
|
-
const payload = createGamePayload('twentyquestions', gameState);
|
|
66
|
-
|
|
67
|
-
const categoryText = category ? ` (${category} category)` : '';
|
|
68
|
-
await store.sendMessage(myHandle, myHandle, `New 20 questions game started${categoryText}! I'm thinking of something...`, 'dm', payload);
|
|
69
|
-
|
|
70
|
-
const display = twentyQuestions.formatTwentyQuestionsDisplay(gameState);
|
|
71
|
-
return {
|
|
72
|
-
display: `## New 20 Questions Game\n\n${display}\n\nAsk yes/no questions: \`vibe twenty-questions --question "Is it alive?"\``
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Show current game if no question
|
|
77
|
-
if (!question) {
|
|
78
|
-
const display = twentyQuestions.formatTwentyQuestionsDisplay(gameState);
|
|
79
|
-
const status = gameState.gameOver ?
|
|
80
|
-
'\nGame over! Use `vibe twenty-questions` to start a new game.' :
|
|
81
|
-
'\nAsk a question: `vibe twenty-questions --question "Is it big?"`';
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
display: `## 20 Questions Game\n\n${display}${status}`
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Process question or guess
|
|
89
|
-
let result;
|
|
90
|
-
|
|
91
|
-
// Check if it's a guess (starts with "is it" or "it is")
|
|
92
|
-
const normalizedQuestion = question.toLowerCase().trim();
|
|
93
|
-
if (normalizedQuestion.startsWith('is it ') || normalizedQuestion.startsWith('it is ')) {
|
|
94
|
-
const guess = normalizedQuestion.startsWith('is it ') ?
|
|
95
|
-
normalizedQuestion.substring(6) : normalizedQuestion.substring(6);
|
|
96
|
-
result = twentyQuestions.processGuess(gameState, guess);
|
|
97
|
-
} else {
|
|
98
|
-
result = twentyQuestions.askQuestion(gameState, question);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (result.error) {
|
|
102
|
-
const display = twentyQuestions.formatTwentyQuestionsDisplay(gameState);
|
|
103
|
-
return {
|
|
104
|
-
display: `## 20 Questions Game\n\n${display}\n\n❌ **${result.error}**\n\nTry again: \`vibe twenty-questions --question "Is it alive?"\``
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Update game state
|
|
109
|
-
const newGameState = result.gameState;
|
|
110
|
-
const payload = createGamePayload('twentyquestions', newGameState);
|
|
111
|
-
|
|
112
|
-
// Send message with updated state
|
|
113
|
-
let message;
|
|
114
|
-
if (newGameState.gameOver) {
|
|
115
|
-
if (newGameState.won) {
|
|
116
|
-
message = `🎉 Correct! It was "${newGameState.item}"! You guessed it in ${newGameState.moves} questions!`;
|
|
117
|
-
} else {
|
|
118
|
-
message = `💀 Sorry! It was "${newGameState.item}". Better luck next time!`;
|
|
119
|
-
}
|
|
120
|
-
} else if (newGameState.currentQuestion) {
|
|
121
|
-
const { answer } = newGameState.currentQuestion;
|
|
122
|
-
message = `Question ${newGameState.moves}: "${question}" → **${answer.toUpperCase()}**`;
|
|
123
|
-
} else if (newGameState.message) {
|
|
124
|
-
message = newGameState.message;
|
|
125
|
-
} else {
|
|
126
|
-
message = 'Question processed!';
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
await store.sendMessage(myHandle, myHandle, message, 'dm', payload);
|
|
130
|
-
|
|
131
|
-
const display = twentyQuestions.formatTwentyQuestionsDisplay(newGameState);
|
|
132
|
-
const status = newGameState.gameOver ?
|
|
133
|
-
'\n\n🎮 Use `vibe twenty-questions` to start a new game!' :
|
|
134
|
-
newGameState.questionsLeft === 0 ?
|
|
135
|
-
'\n\nNo questions left! Make your final guess: `vibe twenty-questions --question "Is it a cat?"`' :
|
|
136
|
-
'\n\nNext question: `vibe twenty-questions --question "Does it fly?"`';
|
|
137
|
-
|
|
138
|
-
return {
|
|
139
|
-
display: `## 20 Questions Game\n\n${display}${status}`
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
module.exports = { definition, handler };
|