agent-messenger 2.3.0 → 2.4.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.
- package/.claude-plugin/README.md +16 -16
- package/.claude-plugin/marketplace.json +29 -29
- package/.claude-plugin/plugin.json +5 -5
- package/CONTRIBUTING.md +1 -1
- package/README.md +8 -5
- package/bun.lock +70 -110
- package/bunfig.toml +3 -0
- package/dist/package.json +11 -3
- package/dist/src/platforms/discordbot/client.js +2 -2
- package/dist/src/platforms/discordbot/client.js.map +1 -1
- package/dist/src/platforms/kakaotalk/cli.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/cli.js +2 -1
- package/dist/src/platforms/kakaotalk/cli.js.map +1 -1
- package/dist/src/platforms/kakaotalk/client.d.ts +2 -1
- package/dist/src/platforms/kakaotalk/client.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/client.js +52 -2
- package/dist/src/platforms/kakaotalk/client.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.d.ts +1 -0
- package/dist/src/platforms/kakaotalk/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.js +1 -0
- package/dist/src/platforms/kakaotalk/commands/index.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/profile.d.ts +3 -0
- package/dist/src/platforms/kakaotalk/commands/profile.d.ts.map +1 -0
- package/dist/src/platforms/kakaotalk/commands/profile.js +19 -0
- package/dist/src/platforms/kakaotalk/commands/profile.js.map +1 -0
- package/dist/src/platforms/kakaotalk/index.d.ts +2 -2
- package/dist/src/platforms/kakaotalk/index.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/index.js +1 -1
- package/dist/src/platforms/kakaotalk/index.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.js +2 -1
- package/dist/src/platforms/kakaotalk/protocol/session.js.map +1 -1
- package/dist/src/platforms/kakaotalk/types.d.ts +16 -0
- package/dist/src/platforms/kakaotalk/types.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/types.js +8 -0
- package/dist/src/platforms/kakaotalk/types.js.map +1 -1
- package/dist/src/platforms/line/client.d.ts.map +1 -1
- package/dist/src/platforms/line/client.js +9 -36
- package/dist/src/platforms/line/client.js.map +1 -1
- package/dist/src/platforms/line/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/line/commands/auth.js +32 -20
- package/dist/src/platforms/line/commands/auth.js.map +1 -1
- package/dist/src/platforms/teams/commands/reaction.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/reaction.js +2 -0
- package/dist/src/platforms/teams/commands/reaction.js.map +1 -1
- package/dist/src/platforms/wechatbot/cli.d.ts +5 -0
- package/dist/src/platforms/wechatbot/cli.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/cli.js +18 -0
- package/dist/src/platforms/wechatbot/cli.js.map +1 -0
- package/dist/src/platforms/wechatbot/client.d.ts +36 -0
- package/dist/src/platforms/wechatbot/client.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/client.js +208 -0
- package/dist/src/platforms/wechatbot/client.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/auth.d.ts +28 -0
- package/dist/src/platforms/wechatbot/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/auth.js +164 -0
- package/dist/src/platforms/wechatbot/commands/auth.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/index.d.ts +5 -0
- package/dist/src/platforms/wechatbot/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/index.js +5 -0
- package/dist/src/platforms/wechatbot/commands/index.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/message.d.ts +18 -0
- package/dist/src/platforms/wechatbot/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/message.js +80 -0
- package/dist/src/platforms/wechatbot/commands/message.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/shared.d.ts +9 -0
- package/dist/src/platforms/wechatbot/commands/shared.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/shared.js +13 -0
- package/dist/src/platforms/wechatbot/commands/shared.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/template.d.ts +19 -0
- package/dist/src/platforms/wechatbot/commands/template.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/template.js +76 -0
- package/dist/src/platforms/wechatbot/commands/template.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/user.d.ts +20 -0
- package/dist/src/platforms/wechatbot/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/user.js +53 -0
- package/dist/src/platforms/wechatbot/commands/user.js.map +1 -0
- package/dist/src/platforms/wechatbot/credential-manager.d.ts +17 -0
- package/dist/src/platforms/wechatbot/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/credential-manager.js +121 -0
- package/dist/src/platforms/wechatbot/credential-manager.js.map +1 -0
- package/dist/src/platforms/wechatbot/index.d.ts +5 -0
- package/dist/src/platforms/wechatbot/index.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/index.js +4 -0
- package/dist/src/platforms/wechatbot/index.js.map +1 -0
- package/dist/src/platforms/wechatbot/types.d.ts +94 -0
- package/dist/src/platforms/wechatbot/types.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/types.js +54 -0
- package/dist/src/platforms/wechatbot/types.js.map +1 -0
- package/dist/src/platforms/whatsapp/client.d.ts +1 -0
- package/dist/src/platforms/whatsapp/client.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/client.js +27 -13
- package/dist/src/platforms/whatsapp/client.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/commands/auth.js +21 -18
- package/dist/src/platforms/whatsapp/commands/auth.js.map +1 -1
- package/dist/src/platforms/whatsapp/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/credential-manager.js +14 -8
- package/dist/src/platforms/whatsapp/credential-manager.js.map +1 -1
- package/docs/content/docs/agent-skills.mdx +4 -4
- package/docs/content/docs/cli/channeltalk.mdx +1 -1
- package/docs/content/docs/cli/channeltalkbot.mdx +1 -1
- package/docs/content/docs/cli/discord.mdx +1 -1
- package/docs/content/docs/cli/discordbot.mdx +1 -1
- package/docs/content/docs/cli/instagram.mdx +1 -1
- package/docs/content/docs/cli/kakaotalk.mdx +1 -1
- package/docs/content/docs/cli/line.mdx +1 -1
- package/docs/content/docs/cli/meta.json +1 -0
- package/docs/content/docs/cli/slack.mdx +1 -1
- package/docs/content/docs/cli/slackbot.mdx +1 -1
- package/docs/content/docs/cli/teams.mdx +1 -1
- package/docs/content/docs/cli/webex.mdx +1 -1
- package/docs/content/docs/cli/wechatbot.mdx +179 -0
- package/docs/content/docs/cli/whatsapp.mdx +1 -1
- package/docs/content/docs/cli/whatsappbot.mdx +1 -1
- package/docs/content/docs/sdk/meta.json +1 -1
- package/docs/content/docs/sdk/wechatbot.mdx +282 -0
- package/docs/content/docs/tui.mdx +1 -1
- package/docs/src/app/page.tsx +5 -5
- package/package.json +11 -3
- package/skills/agent-channeltalk/SKILL.md +1 -1
- package/skills/agent-channeltalkbot/SKILL.md +1 -1
- package/skills/agent-discord/SKILL.md +1 -1
- package/skills/agent-discordbot/SKILL.md +1 -1
- package/skills/agent-instagram/SKILL.md +1 -1
- package/skills/agent-kakaotalk/SKILL.md +24 -1
- package/skills/agent-line/SKILL.md +7 -11
- package/skills/agent-line/references/authentication.md +13 -4
- package/skills/agent-slack/SKILL.md +1 -1
- package/skills/agent-slackbot/SKILL.md +1 -1
- package/skills/agent-teams/SKILL.md +1 -1
- package/skills/agent-telegram/SKILL.md +1 -1
- package/skills/agent-webex/SKILL.md +1 -1
- package/skills/agent-wechatbot/SKILL.md +385 -0
- package/skills/agent-whatsapp/SKILL.md +12 -1
- package/skills/agent-whatsappbot/SKILL.md +1 -1
- package/src/platforms/discord/credential-manager.test.ts +18 -1
- package/src/platforms/discordbot/client.ts +2 -2
- package/src/platforms/instagram/commands/auth.test.ts +216 -0
- package/src/platforms/instagram/commands/chat.test.ts +127 -0
- package/src/platforms/instagram/commands/message.test.ts +178 -0
- package/src/platforms/kakaotalk/cli.ts +2 -1
- package/src/platforms/kakaotalk/client.test.ts +157 -0
- package/src/platforms/kakaotalk/client.ts +57 -3
- package/src/platforms/kakaotalk/commands/auth.test.ts +299 -0
- package/src/platforms/kakaotalk/commands/chat.test.ts +97 -0
- package/src/platforms/kakaotalk/commands/index.ts +1 -0
- package/src/platforms/kakaotalk/commands/message.test.ts +113 -0
- package/src/platforms/kakaotalk/commands/profile.test.ts +84 -0
- package/src/platforms/kakaotalk/commands/profile.ts +21 -0
- package/src/platforms/kakaotalk/index.test.ts +5 -0
- package/src/platforms/kakaotalk/index.ts +2 -0
- package/src/platforms/kakaotalk/protocol/session.ts +2 -0
- package/src/platforms/kakaotalk/types.ts +18 -0
- package/src/platforms/line/client.ts +14 -39
- package/src/platforms/line/commands/auth.test.ts +141 -0
- package/src/platforms/line/commands/auth.ts +28 -19
- package/src/platforms/line/commands/chat.test.ts +110 -0
- package/src/platforms/line/commands/friend.test.ts +98 -0
- package/src/platforms/line/commands/message.test.ts +119 -0
- package/src/platforms/line/commands/profile.test.ts +85 -0
- package/src/platforms/slackbot/commands/channel.test.ts +139 -0
- package/src/platforms/slackbot/commands/message.test.ts +226 -0
- package/src/platforms/slackbot/commands/reaction.test.ts +90 -0
- package/src/platforms/slackbot/commands/user.test.ts +143 -0
- package/src/platforms/teams/commands/reaction.test.ts +45 -61
- package/src/platforms/teams/commands/reaction.ts +2 -0
- package/src/platforms/telegram/commands/chat.test.ts +125 -0
- package/src/platforms/telegram/commands/message.test.ts +92 -0
- package/src/platforms/webex/commands/member.test.ts +65 -58
- package/src/platforms/webex/commands/message.test.ts +78 -121
- package/src/platforms/webex/commands/snapshot.test.ts +59 -46
- package/src/platforms/webex/commands/space.test.ts +49 -48
- package/src/platforms/wechatbot/cli.ts +24 -0
- package/src/platforms/wechatbot/client.test.ts +497 -0
- package/src/platforms/wechatbot/client.ts +268 -0
- package/src/platforms/wechatbot/commands/auth.test.ts +211 -0
- package/src/platforms/wechatbot/commands/auth.ts +203 -0
- package/src/platforms/wechatbot/commands/index.ts +4 -0
- package/src/platforms/wechatbot/commands/message.test.ts +155 -0
- package/src/platforms/wechatbot/commands/message.ts +104 -0
- package/src/platforms/wechatbot/commands/shared.ts +22 -0
- package/src/platforms/wechatbot/commands/template.test.ts +199 -0
- package/src/platforms/wechatbot/commands/template.ts +102 -0
- package/src/platforms/wechatbot/commands/user.test.ts +165 -0
- package/src/platforms/wechatbot/commands/user.ts +75 -0
- package/src/platforms/wechatbot/credential-manager.test.ts +255 -0
- package/src/platforms/wechatbot/credential-manager.ts +148 -0
- package/src/platforms/wechatbot/index.test.ts +49 -0
- package/src/platforms/wechatbot/index.ts +19 -0
- package/src/platforms/wechatbot/types.test.ts +223 -0
- package/src/platforms/wechatbot/types.ts +107 -0
- package/src/platforms/whatsapp/client.ts +24 -13
- package/src/platforms/whatsapp/commands/auth.test.ts +311 -0
- package/src/platforms/whatsapp/commands/auth.ts +21 -17
- package/src/platforms/whatsapp/commands/chat.test.ts +198 -0
- package/src/platforms/whatsapp/commands/message.test.ts +231 -0
- package/src/platforms/whatsapp/credential-manager.test.ts +20 -0
- package/src/platforms/whatsapp/credential-manager.ts +17 -8
- package/src/platforms/whatsappbot/commands/auth.test.ts +217 -0
- package/src/platforms/whatsappbot/commands/message.test.ts +198 -0
- package/src/platforms/whatsappbot/commands/template.test.ts +112 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
3
|
+
import { WeChatBotClient } from '../client.js';
|
|
4
|
+
import { WeChatBotCredentialManager } from '../credential-manager.js';
|
|
5
|
+
export async function setAction(appId, appSecret, options) {
|
|
6
|
+
try {
|
|
7
|
+
const client = await new WeChatBotClient().login({ appId, appSecret });
|
|
8
|
+
const valid = await client.verifyCredentials();
|
|
9
|
+
if (!valid) {
|
|
10
|
+
return { error: 'Invalid credentials. Could not obtain access token.' };
|
|
11
|
+
}
|
|
12
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
13
|
+
await credManager.setCredentials({
|
|
14
|
+
app_id: appId,
|
|
15
|
+
app_secret: appSecret,
|
|
16
|
+
account_name: appId,
|
|
17
|
+
});
|
|
18
|
+
return { success: true, app_id: appId, account_name: appId };
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return { error: error.message };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export async function statusAction(options) {
|
|
25
|
+
try {
|
|
26
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
27
|
+
const creds = await credManager.getCredentials(options.account);
|
|
28
|
+
if (!creds) {
|
|
29
|
+
return {
|
|
30
|
+
valid: false,
|
|
31
|
+
error: options.account
|
|
32
|
+
? `Account "${options.account}" not found. Run "auth list" to see available accounts.`
|
|
33
|
+
: 'No credentials configured. Run "auth set <app-id> <app-secret>" first.',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
let valid = false;
|
|
37
|
+
let appId;
|
|
38
|
+
let accountName;
|
|
39
|
+
try {
|
|
40
|
+
const client = await new WeChatBotClient().login({ appId: creds.app_id, appSecret: creds.app_secret });
|
|
41
|
+
valid = await client.verifyCredentials();
|
|
42
|
+
appId = creds.app_id;
|
|
43
|
+
accountName = creds.account_name;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
valid = false;
|
|
47
|
+
appId = creds.app_id;
|
|
48
|
+
accountName = creds.account_name;
|
|
49
|
+
}
|
|
50
|
+
return { valid, app_id: appId, account_name: accountName };
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return { error: error.message };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export async function clearAction(options) {
|
|
57
|
+
try {
|
|
58
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
59
|
+
await credManager.clearCredentials();
|
|
60
|
+
return { success: true };
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return { error: error.message };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export async function listAction(options) {
|
|
67
|
+
try {
|
|
68
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
69
|
+
const all = await credManager.listAll();
|
|
70
|
+
return {
|
|
71
|
+
accounts: all.map((a) => ({
|
|
72
|
+
app_id: a.app_id,
|
|
73
|
+
account_name: a.account_name,
|
|
74
|
+
is_current: a.is_current,
|
|
75
|
+
})),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
return { error: error.message };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export async function useAction(accountId, options) {
|
|
83
|
+
try {
|
|
84
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
85
|
+
const found = await credManager.setCurrent(accountId);
|
|
86
|
+
if (!found) {
|
|
87
|
+
return { error: `Account "${accountId}" not found. Run "auth list" to see available accounts.` };
|
|
88
|
+
}
|
|
89
|
+
const creds = await credManager.getCredentials();
|
|
90
|
+
return {
|
|
91
|
+
success: true,
|
|
92
|
+
app_id: creds?.app_id,
|
|
93
|
+
account_name: creds?.account_name,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
return { error: error.message };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export async function removeAction(accountId, options) {
|
|
101
|
+
try {
|
|
102
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
103
|
+
const removed = await credManager.removeAccount(accountId);
|
|
104
|
+
if (!removed) {
|
|
105
|
+
return { error: `Account "${accountId}" not found. Run "auth list" to see available accounts.` };
|
|
106
|
+
}
|
|
107
|
+
return { success: true };
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
return { error: error.message };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function cliOutput(result, pretty, exitOnError = true) {
|
|
114
|
+
console.log(formatOutput(result, pretty));
|
|
115
|
+
if (result.error && exitOnError)
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
export const authCommand = new Command('auth')
|
|
119
|
+
.description('Authentication commands')
|
|
120
|
+
.addCommand(new Command('set')
|
|
121
|
+
.description('Set account credentials')
|
|
122
|
+
.argument('<app-id>', 'WeChat Official Account App ID')
|
|
123
|
+
.argument('<app-secret>', 'WeChat Official Account App Secret')
|
|
124
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
125
|
+
.action(async (appId, appSecret, opts) => {
|
|
126
|
+
cliOutput(await setAction(appId, appSecret, opts), opts.pretty);
|
|
127
|
+
}))
|
|
128
|
+
.addCommand(new Command('status')
|
|
129
|
+
.description('Show authentication status')
|
|
130
|
+
.option('--account <id>', 'Check specific account (default: current)')
|
|
131
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
132
|
+
.action(async (opts) => {
|
|
133
|
+
const result = await statusAction(opts);
|
|
134
|
+
console.log(formatOutput(result, opts.pretty));
|
|
135
|
+
if (!result.valid)
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}))
|
|
138
|
+
.addCommand(new Command('clear')
|
|
139
|
+
.description('Clear all stored credentials')
|
|
140
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
141
|
+
.action(async (opts) => {
|
|
142
|
+
cliOutput(await clearAction(opts), opts.pretty);
|
|
143
|
+
}))
|
|
144
|
+
.addCommand(new Command('list')
|
|
145
|
+
.description('List all stored accounts')
|
|
146
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
147
|
+
.action(async (opts) => {
|
|
148
|
+
cliOutput(await listAction(opts), opts.pretty);
|
|
149
|
+
}))
|
|
150
|
+
.addCommand(new Command('use')
|
|
151
|
+
.description('Switch active account')
|
|
152
|
+
.argument('<account-id>', 'Account ID (App ID)')
|
|
153
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
154
|
+
.action(async (accountId, opts) => {
|
|
155
|
+
cliOutput(await useAction(accountId, opts), opts.pretty);
|
|
156
|
+
}))
|
|
157
|
+
.addCommand(new Command('remove')
|
|
158
|
+
.description('Remove a stored account')
|
|
159
|
+
.argument('<account-id>', 'Account ID (App ID)')
|
|
160
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
161
|
+
.action(async (accountId, opts) => {
|
|
162
|
+
cliOutput(await removeAction(accountId, opts), opts.pretty);
|
|
163
|
+
}));
|
|
164
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAiBlE,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAa,EAAE,SAAiB,EAAE,OAAsB;IACtF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,eAAe,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;QACtE,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,iBAAiB,EAAE,CAAA;QAE9C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,EAAE,KAAK,EAAE,qDAAqD,EAAE,CAAA;QACzE,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,0BAA0B,EAAE,CAAA;QAC5E,MAAM,WAAW,CAAC,cAAc,CAAC;YAC/B,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,SAAS;YACrB,Y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ot/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { AccountOption } from './shared.js';
|
|
3
|
+
interface MessageResult {
|
|
4
|
+
success?: boolean;
|
|
5
|
+
error?: string;
|
|
6
|
+
}
|
|
7
|
+
type MessageOptions = AccountOption & {
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
picurl?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function sendAction(openId: string, text: string, options: MessageOptions): Promise<MessageResult>;
|
|
14
|
+
export declare function sendImageAction(openId: string, mediaId: string, options: MessageOptions): Promise<MessageResult>;
|
|
15
|
+
export declare function sendNewsAction(openId: string, options: MessageOptions): Promise<MessageResult>;
|
|
16
|
+
export declare const messageCommand: Command;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG7C,UAAU,aAAa;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,KAAK,cAAc,GAAG,aAAa,GAAG;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAQ9G;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAQtH;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAmBpG;AAOD,eAAO,MAAM,cAAc,SAqCxB,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
3
|
+
import { getClient } from './shared.js';
|
|
4
|
+
export async function sendAction(openId, text, options) {
|
|
5
|
+
try {
|
|
6
|
+
const client = await getClient(options);
|
|
7
|
+
await client.sendTextMessage(openId, text);
|
|
8
|
+
return { success: true };
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
return { error: error.message };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export async function sendImageAction(openId, mediaId, options) {
|
|
15
|
+
try {
|
|
16
|
+
const client = await getClient(options);
|
|
17
|
+
await client.sendImageMessage(openId, mediaId);
|
|
18
|
+
return { success: true };
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return { error: error.message };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export async function sendNewsAction(openId, options) {
|
|
25
|
+
try {
|
|
26
|
+
if (!options.title || !options.description || !options.url || !options.picurl) {
|
|
27
|
+
return { error: '--title, --description, --url, and --picurl are required' };
|
|
28
|
+
}
|
|
29
|
+
const article = {
|
|
30
|
+
title: options.title,
|
|
31
|
+
description: options.description,
|
|
32
|
+
url: options.url,
|
|
33
|
+
picurl: options.picurl,
|
|
34
|
+
};
|
|
35
|
+
const client = await getClient(options);
|
|
36
|
+
await client.sendNewsMessage(openId, [article]);
|
|
37
|
+
return { success: true };
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return { error: error.message };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function cliOutput(result, pretty) {
|
|
44
|
+
console.log(formatOutput(result, pretty));
|
|
45
|
+
if (result.error)
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
export const messageCommand = new Command('message')
|
|
49
|
+
.description('Message commands')
|
|
50
|
+
.addCommand(new Command('send')
|
|
51
|
+
.description('Send a text message (customer service)')
|
|
52
|
+
.argument('<open-id>', 'Recipient OpenID')
|
|
53
|
+
.argument('<text>', 'Message text')
|
|
54
|
+
.option('--account <id>', 'Account ID')
|
|
55
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
56
|
+
.action(async (openId, text, opts) => {
|
|
57
|
+
cliOutput(await sendAction(openId, text, opts), opts.pretty);
|
|
58
|
+
}))
|
|
59
|
+
.addCommand(new Command('send-image')
|
|
60
|
+
.description('Send an image message (customer service)')
|
|
61
|
+
.argument('<open-id>', 'Recipient OpenID')
|
|
62
|
+
.argument('<media-id>', 'Media ID of the image')
|
|
63
|
+
.option('--account <id>', 'Account ID')
|
|
64
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
65
|
+
.action(async (openId, mediaId, opts) => {
|
|
66
|
+
cliOutput(await sendImageAction(openId, mediaId, opts), opts.pretty);
|
|
67
|
+
}))
|
|
68
|
+
.addCommand(new Command('send-news')
|
|
69
|
+
.description('Send a news/article message (customer service)')
|
|
70
|
+
.argument('<open-id>', 'Recipient OpenID')
|
|
71
|
+
.requiredOption('--title <title>', 'Article title')
|
|
72
|
+
.requiredOption('--description <description>', 'Article description')
|
|
73
|
+
.requiredOption('--url <url>', 'Article URL')
|
|
74
|
+
.requiredOption('--picurl <picurl>', 'Article picture URL')
|
|
75
|
+
.option('--account <id>', 'Account ID')
|
|
76
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
77
|
+
.action(async (openId, opts) => {
|
|
78
|
+
cliOutput(await sendNewsAction(openId, opts), opts.pretty);
|
|
79
|
+
}));
|
|
80
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAIpD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAcpC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc,EAAE,IAAY,EAAE,OAAuB;IACpF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAA;IAC5C,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAc,EAAE,OAAe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kBAAkB,CAAC;KACzC,cAAc,CAAC,iBAAiB,EAAE,eAAe,CAAC;KAClD,cAAc,CAAC,6BAA6B,EAAE,qBAAqB,CAAC;KACpE,cAAc,CAAC,aAAa,EAAE,aAAa,CAAC;KAC5C,cAAc,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;KAC1D,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAAoB,EAAE,EAAE;IACrD,SAAS,CAAC,MAAM,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;AAC5D,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WeChatBotClient } from '../client.js';
|
|
2
|
+
import { WeChatBotCredentialManager } from '../credential-manager.js';
|
|
3
|
+
export interface AccountOption {
|
|
4
|
+
account?: string;
|
|
5
|
+
pretty?: boolean;
|
|
6
|
+
_credManager?: WeChatBotCredentialManager;
|
|
7
|
+
}
|
|
8
|
+
export declare function getClient(options: AccountOption): Promise<WeChatBotClient>;
|
|
9
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAElE,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,YAAY,CAAC,EAAE,0BAA0B,CAAA;CAC1C;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAUhF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
2
|
+
import { WeChatBotClient } from '../client.js';
|
|
3
|
+
import { WeChatBotCredentialManager } from '../credential-manager.js';
|
|
4
|
+
export async function getClient(options) {
|
|
5
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
6
|
+
const creds = await credManager.getCredentials(options.account);
|
|
7
|
+
if (!creds) {
|
|
8
|
+
console.log(formatOutput({ error: 'No credentials. Run "auth set <app-id> <app-secret>" first.' }, options.pretty));
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
return await new WeChatBotClient().login({ appId: creds.app_id, appSecret: creds.app_secret });
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAQlE,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAsB;IACpD,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,0BAA0B,EAAE,CAAA;IAC5E,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAE/D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,6DAA6D,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QACnH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,OAAO,MAAM,IAAI,eAAe,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAA;AAChG,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { WeChatBotTemplate } from '../types.js';
|
|
3
|
+
import type { AccountOption } from './shared.js';
|
|
4
|
+
interface TemplateResult {
|
|
5
|
+
templates?: WeChatBotTemplate[];
|
|
6
|
+
msgid?: number;
|
|
7
|
+
success?: boolean;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
type TemplateOptions = AccountOption & {
|
|
11
|
+
data?: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function listAction(options: TemplateOptions): Promise<TemplateResult>;
|
|
15
|
+
export declare function sendAction(openId: string, templateId: string, options: TemplateOptions): Promise<TemplateResult>;
|
|
16
|
+
export declare function deleteAction(templateId: string, options: TemplateOptions): Promise<TemplateResult>;
|
|
17
|
+
export declare const templateCommand: Command;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG7C,UAAU,cAAc;IACtB,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAA;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,KAAK,eAAe,GAAG,aAAa,GAAG;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAQlF;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CAiBzB;AAED,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAQxG;AAOD,eAAO,MAAM,eAAe,SAiCzB,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
3
|
+
import { getClient } from './shared.js';
|
|
4
|
+
export async function listAction(options) {
|
|
5
|
+
try {
|
|
6
|
+
const client = await getClient(options);
|
|
7
|
+
const templates = await client.listTemplates();
|
|
8
|
+
return { templates };
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
return { error: error.message };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export async function sendAction(openId, templateId, options) {
|
|
15
|
+
try {
|
|
16
|
+
let data = {};
|
|
17
|
+
if (options.data) {
|
|
18
|
+
try {
|
|
19
|
+
data = JSON.parse(options.data);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return { error: 'Invalid --data JSON' };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const client = await getClient(options);
|
|
26
|
+
const result = await client.sendTemplateMessage(openId, templateId, data, options.url);
|
|
27
|
+
return { msgid: result.msgid };
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return { error: error.message };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function deleteAction(templateId, options) {
|
|
34
|
+
try {
|
|
35
|
+
const client = await getClient(options);
|
|
36
|
+
await client.deleteTemplate(templateId);
|
|
37
|
+
return { success: true };
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return { error: error.message };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function cliOutput(result, pretty) {
|
|
44
|
+
console.log(formatOutput(result, pretty));
|
|
45
|
+
if (result.error)
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
export const templateCommand = new Command('template')
|
|
49
|
+
.description('Template message commands')
|
|
50
|
+
.addCommand(new Command('list')
|
|
51
|
+
.description('List all private templates')
|
|
52
|
+
.option('--account <id>', 'Account ID')
|
|
53
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
54
|
+
.action(async (opts) => {
|
|
55
|
+
cliOutput(await listAction(opts), opts.pretty);
|
|
56
|
+
}))
|
|
57
|
+
.addCommand(new Command('send')
|
|
58
|
+
.description('Send a template message')
|
|
59
|
+
.argument('<open-id>', 'Recipient OpenID')
|
|
60
|
+
.argument('<template-id>', 'Template ID')
|
|
61
|
+
.option('--data <json>', 'Template data as JSON object')
|
|
62
|
+
.option('--url <url>', 'URL to redirect when message is clicked')
|
|
63
|
+
.option('--account <id>', 'Account ID')
|
|
64
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
65
|
+
.action(async (openId, templateId, opts) => {
|
|
66
|
+
cliOutput(await sendAction(openId, templateId, opts), opts.pretty);
|
|
67
|
+
}))
|
|
68
|
+
.addCommand(new Command('delete')
|
|
69
|
+
.description('Delete a private template')
|
|
70
|
+
.argument('<template-id>', 'Template ID to delete')
|
|
71
|
+
.option('--account <id>', 'Account ID')
|
|
72
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
73
|
+
.action(async (templateId, opts) => {
|
|
74
|
+
cliOutput(await deleteAction(templateId, opts), opts.pretty);
|
|
75
|
+
}));
|
|
76
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../src/plat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E,8BAA8B,CAAC;KACvD,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;KAChE,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,UAAkB,EAAE,IAAqB,EAAE,EAAE;IAC1E,SAAS,CAAC,MAAM,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;AACpE,CAAC,CAAC,CACL;KACA,UAAU,CACT,IAAI,OAAO,CAAC,QAAQ,CAAC;KAClB,WAAW,CAAC,2BAA2B,CAAC;KACxC,QAAQ,CAAC,eAAe,EAAE,uBAAuB,CAAC;KAClD,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,UAAkB,EAAE,IAAqB,EAAE,EAAE;IAC1D,SAAS,CAAC,MAAM,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;AAC9D,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { WeChatBotUserInfo } from '../types.js';
|
|
3
|
+
import type { AccountOption } from './shared.js';
|
|
4
|
+
interface UserResult {
|
|
5
|
+
total?: number;
|
|
6
|
+
count?: number;
|
|
7
|
+
openids?: string[];
|
|
8
|
+
next_openid?: string;
|
|
9
|
+
user?: WeChatBotUserInfo;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
type UserOptions = AccountOption & {
|
|
13
|
+
nextOpenid?: string;
|
|
14
|
+
lang?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function listAction(options: UserOptions): Promise<UserResult>;
|
|
17
|
+
export declare function getAction(openId: string, options: UserOptions): Promise<UserResult>;
|
|
18
|
+
export declare const userCommand: Command;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG7C,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,iBAAiB,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,KAAK,WAAW,GAAG,aAAa,GAAG;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAa1E;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAQzF;AAOD,eAAO,MAAM,WAAW,SAsBrB,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
3
|
+
import { getClient } from './shared.js';
|
|
4
|
+
export async function listAction(options) {
|
|
5
|
+
try {
|
|
6
|
+
const client = await getClient(options);
|
|
7
|
+
const result = await client.getFollowers(options.nextOpenid);
|
|
8
|
+
return {
|
|
9
|
+
total: result.total,
|
|
10
|
+
count: result.count,
|
|
11
|
+
openids: result.openids,
|
|
12
|
+
next_openid: result.next_openid,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
return { error: error.message };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export async function getAction(openId, options) {
|
|
20
|
+
try {
|
|
21
|
+
const client = await getClient(options);
|
|
22
|
+
const user = await client.getUserInfo(openId, options.lang);
|
|
23
|
+
return { user };
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return { error: error.message };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function cliOutput(result, pretty) {
|
|
30
|
+
console.log(formatOutput(result, pretty));
|
|
31
|
+
if (result.error)
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
export const userCommand = new Command('user')
|
|
35
|
+
.description('User management commands')
|
|
36
|
+
.addCommand(new Command('list')
|
|
37
|
+
.description('List followers')
|
|
38
|
+
.option('--next-openid <cursor>', 'Cursor for pagination')
|
|
39
|
+
.option('--account <id>', 'Account ID')
|
|
40
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
41
|
+
.action(async (opts) => {
|
|
42
|
+
cliOutput(await listAction(opts), opts.pretty);
|
|
43
|
+
}))
|
|
44
|
+
.addCommand(new Command('get')
|
|
45
|
+
.description('Get user info by OpenID')
|
|
46
|
+
.argument('<open-id>', 'User OpenID')
|
|
47
|
+
.option('--lang <lang>', 'Language (zh_CN, zh_TW, en)', 'zh_CN')
|
|
48
|
+
.option('--account <id>', 'Account ID')
|
|
49
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
50
|
+
.action(async (openId, opts) => {
|
|
51
|
+
cliOutput(await getAction(openId, opts), opts.pretty);
|
|
52
|
+
}));
|
|
53
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/user.ts"],"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IAAI,CAAC,CAAC,CAAC,CAAA;AACnC,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,0BAA0B,CAAC;KACvC,UAAU,CACT,IAAI,OAAO,CAAC,MAAM,CAAC;KAChB,WAAW,CAAC,gBAAgB,CAAC;KAC7B,MAAM,CAAC,wBAAwB,EAAE,uBAAuB,CAAC;KACzD,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,IAAiB,EAAE,EAAE;IAClC,SAAS,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;AAChD,CAAC,CAAC,CACL;KACA,UAAU,CACT,IAAI,OAAO,CAAC,KAAK,CAAC;KACf,WAAW,CAAC,yBAAyB,CAAC;KACtC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;KACpC,MAAM,CAAC,eAAe,EAAE,6BAA6B,EAAE,OAAO,CAAC;KAC/D,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAAiB,EAAE,EAAE;IAClD,SAAS,CAAC,MAAM,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;AACvD,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WeChatBotAccountEntry, WeChatBotConfig, WeChatBotCredentials } from './types.js';
|
|
2
|
+
export declare class WeChatBotCredentialManager {
|
|
3
|
+
private configDir;
|
|
4
|
+
private credentialsPath;
|
|
5
|
+
constructor(configDir?: string);
|
|
6
|
+
load(): Promise<WeChatBotConfig>;
|
|
7
|
+
save(config: WeChatBotConfig): Promise<void>;
|
|
8
|
+
getCredentials(accountId?: string): Promise<WeChatBotCredentials | null>;
|
|
9
|
+
setCredentials(entry: WeChatBotAccountEntry): Promise<void>;
|
|
10
|
+
removeAccount(accountId: string): Promise<boolean>;
|
|
11
|
+
setCurrent(accountId: string): Promise<boolean>;
|
|
12
|
+
listAll(): Promise<Array<WeChatBotAccountEntry & {
|
|
13
|
+
is_current: boolean;
|
|
14
|
+
}>>;
|
|
15
|
+
clearCredentials(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=credential-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-manager.d.ts","sourceRoot":"","sources":["../../../../src/platforms/wechatbot/credential-manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAG3F,qBAAa,0BAA0B;IACrC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,eAAe,CAAQ;gBAEnB,SAAS,CAAC,EAAE,MAAM;IAKxB,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IAmBhC,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5C,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAsCxE,cAAc,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB3D,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBlD,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAe/C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,qBAAqB,GAAG;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAgB1E,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}
|