agent-messenger 2.3.0 → 2.5.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/.github/workflows/release.yml +0 -12
- package/CONTRIBUTING.md +1 -1
- package/README.md +11 -8
- package/bun.lock +70 -110
- package/bunfig.toml +3 -0
- package/dist/package.json +11 -3
- package/dist/src/platforms/channeltalk/cli.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/cli.js +2 -1
- package/dist/src/platforms/channeltalk/cli.js.map +1 -1
- package/dist/src/platforms/channeltalk/commands/index.d.ts +1 -0
- package/dist/src/platforms/channeltalk/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/commands/index.js +1 -0
- package/dist/src/platforms/channeltalk/commands/index.js.map +1 -1
- package/dist/src/platforms/channeltalk/commands/whoami.d.ts +22 -0
- package/dist/src/platforms/channeltalk/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/channeltalk/commands/whoami.js +40 -0
- package/dist/src/platforms/channeltalk/commands/whoami.js.map +1 -0
- package/dist/src/platforms/channeltalkbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/channeltalkbot/cli.js +2 -1
- package/dist/src/platforms/channeltalkbot/cli.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/index.d.ts +1 -0
- package/dist/src/platforms/channeltalkbot/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/index.js +1 -0
- package/dist/src/platforms/channeltalkbot/commands/index.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/whoami.d.ts +13 -0
- package/dist/src/platforms/channeltalkbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/channeltalkbot/commands/whoami.js +31 -0
- package/dist/src/platforms/channeltalkbot/commands/whoami.js.map +1 -0
- package/dist/src/platforms/discord/cli.d.ts.map +1 -1
- package/dist/src/platforms/discord/cli.js +2 -1
- package/dist/src/platforms/discord/cli.js.map +1 -1
- package/dist/src/platforms/discord/commands/index.d.ts +1 -0
- package/dist/src/platforms/discord/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/index.js +1 -0
- package/dist/src/platforms/discord/commands/index.js.map +1 -1
- package/dist/src/platforms/discord/commands/whoami.d.ts +6 -0
- package/dist/src/platforms/discord/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/whoami.js +33 -0
- package/dist/src/platforms/discord/commands/whoami.js.map +1 -0
- package/dist/src/platforms/discordbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/discordbot/cli.js +2 -1
- package/dist/src/platforms/discordbot/cli.js.map +1 -1
- package/dist/src/platforms/discordbot/client.js +2 -2
- package/dist/src/platforms/discordbot/client.js.map +1 -1
- package/dist/src/platforms/discordbot/commands/index.d.ts +1 -0
- package/dist/src/platforms/discordbot/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/discordbot/commands/index.js +1 -0
- package/dist/src/platforms/discordbot/commands/index.js.map +1 -1
- package/dist/src/platforms/discordbot/commands/whoami.d.ts +14 -0
- package/dist/src/platforms/discordbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/whoami.js +32 -0
- package/dist/src/platforms/discordbot/commands/whoami.js.map +1 -0
- package/dist/src/platforms/instagram/cli.d.ts.map +1 -1
- package/dist/src/platforms/instagram/cli.js +2 -1
- package/dist/src/platforms/instagram/cli.js.map +1 -1
- package/dist/src/platforms/instagram/client.d.ts +6 -0
- package/dist/src/platforms/instagram/client.d.ts.map +1 -1
- package/dist/src/platforms/instagram/client.js +12 -0
- package/dist/src/platforms/instagram/client.js.map +1 -1
- package/dist/src/platforms/instagram/commands/index.d.ts +1 -0
- package/dist/src/platforms/instagram/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/instagram/commands/index.js +1 -0
- package/dist/src/platforms/instagram/commands/index.js.map +1 -1
- package/dist/src/platforms/instagram/commands/whoami.d.ts +7 -0
- package/dist/src/platforms/instagram/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/instagram/commands/whoami.js +19 -0
- package/dist/src/platforms/instagram/commands/whoami.js.map +1 -0
- 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 +225 -23
- 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/whoami.d.ts +3 -0
- package/dist/src/platforms/kakaotalk/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/kakaotalk/commands/whoami.js +19 -0
- package/dist/src/platforms/kakaotalk/commands/whoami.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 +4 -2
- package/dist/src/platforms/kakaotalk/protocol/session.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.js +27 -7
- package/dist/src/platforms/kakaotalk/protocol/session.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/types.d.ts +17 -0
- package/dist/src/platforms/kakaotalk/protocol/types.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/types.js.map +1 -1
- package/dist/src/platforms/kakaotalk/types.d.ts +28 -0
- package/dist/src/platforms/kakaotalk/types.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/types.js +14 -0
- package/dist/src/platforms/kakaotalk/types.js.map +1 -1
- package/dist/src/platforms/line/cli.js +2 -2
- package/dist/src/platforms/line/cli.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 +9 -47
- package/dist/src/platforms/line/commands/auth.js.map +1 -1
- package/dist/src/platforms/line/commands/index.d.ts +1 -1
- package/dist/src/platforms/line/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/line/commands/index.js +1 -1
- package/dist/src/platforms/line/commands/index.js.map +1 -1
- package/dist/src/platforms/line/commands/whoami.d.ts +3 -0
- package/dist/src/platforms/line/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/line/commands/{profile.js → whoami.js} +5 -5
- package/dist/src/platforms/line/commands/whoami.js.map +1 -0
- package/dist/src/platforms/slack/cli.d.ts.map +1 -1
- package/dist/src/platforms/slack/cli.js +2 -1
- package/dist/src/platforms/slack/cli.js.map +1 -1
- package/dist/src/platforms/slack/commands/index.d.ts +1 -0
- package/dist/src/platforms/slack/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/index.js +1 -0
- package/dist/src/platforms/slack/commands/index.js.map +1 -1
- package/dist/src/platforms/slack/commands/whoami.d.ts +6 -0
- package/dist/src/platforms/slack/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/whoami.js +39 -0
- package/dist/src/platforms/slack/commands/whoami.js.map +1 -0
- package/dist/src/platforms/slackbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/slackbot/cli.js +2 -1
- package/dist/src/platforms/slackbot/cli.js.map +1 -1
- package/dist/src/platforms/slackbot/commands/index.d.ts +1 -0
- package/dist/src/platforms/slackbot/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/slackbot/commands/index.js +1 -0
- package/dist/src/platforms/slackbot/commands/index.js.map +1 -1
- package/dist/src/platforms/slackbot/commands/whoami.d.ts +14 -0
- package/dist/src/platforms/slackbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/commands/whoami.js +32 -0
- package/dist/src/platforms/slackbot/commands/whoami.js.map +1 -0
- package/dist/src/platforms/teams/cli.d.ts.map +1 -1
- package/dist/src/platforms/teams/cli.js +2 -1
- package/dist/src/platforms/teams/cli.js.map +1 -1
- package/dist/src/platforms/teams/commands/index.d.ts +1 -0
- package/dist/src/platforms/teams/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/index.js +1 -0
- package/dist/src/platforms/teams/commands/index.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/teams/commands/whoami.d.ts +6 -0
- package/dist/src/platforms/teams/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/whoami.js +30 -0
- package/dist/src/platforms/teams/commands/whoami.js.map +1 -0
- package/dist/src/platforms/telegram/cli.d.ts.map +1 -1
- package/dist/src/platforms/telegram/cli.js +2 -1
- package/dist/src/platforms/telegram/cli.js.map +1 -1
- package/dist/src/platforms/telegram/commands/index.d.ts +1 -0
- package/dist/src/platforms/telegram/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/telegram/commands/index.js +1 -0
- package/dist/src/platforms/telegram/commands/index.js.map +1 -1
- package/dist/src/platforms/telegram/commands/whoami.d.ts +7 -0
- package/dist/src/platforms/telegram/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/telegram/commands/whoami.js +27 -0
- package/dist/src/platforms/telegram/commands/whoami.js.map +1 -0
- package/dist/src/platforms/webex/cli.d.ts.map +1 -1
- package/dist/src/platforms/webex/cli.js +2 -1
- package/dist/src/platforms/webex/cli.js.map +1 -1
- package/dist/src/platforms/webex/commands/index.d.ts +1 -0
- package/dist/src/platforms/webex/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/index.js +1 -0
- package/dist/src/platforms/webex/commands/index.js.map +1 -1
- package/dist/src/platforms/webex/commands/message.js +1 -1
- package/dist/src/platforms/webex/commands/message.js.map +1 -1
- package/dist/src/platforms/webex/commands/whoami.d.ts +6 -0
- package/dist/src/platforms/webex/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/webex/commands/whoami.js +30 -0
- package/dist/src/platforms/webex/commands/whoami.js.map +1 -0
- 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 +19 -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 +6 -0
- package/dist/src/platforms/wechatbot/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/index.js +6 -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/commands/whoami.d.ts +12 -0
- package/dist/src/platforms/wechatbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/whoami.js +33 -0
- package/dist/src/platforms/wechatbot/commands/whoami.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/cli.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/cli.js +2 -1
- package/dist/src/platforms/whatsapp/cli.js.map +1 -1
- package/dist/src/platforms/whatsapp/client.d.ts +9 -0
- package/dist/src/platforms/whatsapp/client.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/client.js +143 -21
- 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 +133 -60
- package/dist/src/platforms/whatsapp/commands/auth.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/index.d.ts +1 -0
- package/dist/src/platforms/whatsapp/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/commands/index.js +1 -0
- package/dist/src/platforms/whatsapp/commands/index.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/shared.js +2 -2
- package/dist/src/platforms/whatsapp/commands/shared.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/whoami.d.ts +7 -0
- package/dist/src/platforms/whatsapp/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/whatsapp/commands/whoami.js +19 -0
- package/dist/src/platforms/whatsapp/commands/whoami.js.map +1 -0
- 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/dist/src/platforms/whatsapp/ensure-auth.js +2 -2
- package/dist/src/platforms/whatsapp/ensure-auth.js.map +1 -1
- package/dist/src/platforms/whatsappbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/whatsappbot/cli.js +2 -1
- package/dist/src/platforms/whatsappbot/cli.js.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/index.d.ts +1 -0
- package/dist/src/platforms/whatsappbot/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/index.js +1 -0
- package/dist/src/platforms/whatsappbot/commands/index.js.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/whoami.d.ts +17 -0
- package/dist/src/platforms/whatsappbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/whatsappbot/commands/whoami.js +39 -0
- package/dist/src/platforms/whatsappbot/commands/whoami.js.map +1 -0
- package/dist/src/shared/utils/qr.d.ts +15 -0
- package/dist/src/shared/utils/qr.d.ts.map +1 -0
- package/dist/src/shared/utils/qr.js +74 -0
- package/dist/src/shared/utils/qr.js.map +1 -0
- package/dist/src/tui/adapters/whatsapp-adapter.d.ts.map +1 -1
- package/dist/src/tui/adapters/whatsapp-adapter.js +20 -15
- package/dist/src/tui/adapters/whatsapp-adapter.js.map +1 -1
- package/docs/content/docs/agent-skills.mdx +4 -4
- package/docs/content/docs/cli/channeltalk.mdx +12 -1
- package/docs/content/docs/cli/channeltalkbot.mdx +10 -1
- package/docs/content/docs/cli/discord.mdx +11 -1
- package/docs/content/docs/cli/discordbot.mdx +10 -1
- package/docs/content/docs/cli/instagram.mdx +12 -1
- package/docs/content/docs/cli/kakaotalk.mdx +25 -1
- package/docs/content/docs/cli/line.mdx +5 -5
- package/docs/content/docs/cli/meta.json +1 -0
- package/docs/content/docs/cli/slack.mdx +11 -1
- package/docs/content/docs/cli/slackbot.mdx +10 -1
- package/docs/content/docs/cli/teams.mdx +11 -1
- package/docs/content/docs/cli/telegram.mdx +11 -0
- package/docs/content/docs/cli/webex.mdx +11 -1
- package/docs/content/docs/cli/wechatbot.mdx +188 -0
- package/docs/content/docs/cli/whatsapp.mdx +37 -8
- package/docs/content/docs/cli/whatsappbot.mdx +10 -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 +12 -1
- package/skills/agent-channeltalkbot/SKILL.md +10 -1
- package/skills/agent-discord/SKILL.md +11 -1
- package/skills/agent-discordbot/SKILL.md +10 -1
- package/skills/agent-instagram/SKILL.md +12 -1
- package/skills/agent-kakaotalk/SKILL.md +30 -1
- package/skills/agent-kakaotalk/references/common-patterns.md +1 -1
- package/skills/agent-line/SKILL.md +11 -15
- package/skills/agent-line/references/authentication.md +13 -4
- package/skills/agent-slack/SKILL.md +11 -1
- package/skills/agent-slackbot/SKILL.md +10 -1
- package/skills/agent-teams/SKILL.md +11 -1
- package/skills/agent-telegram/SKILL.md +6 -1
- package/skills/agent-webex/SKILL.md +11 -1
- package/skills/agent-wechatbot/SKILL.md +394 -0
- package/skills/agent-whatsapp/SKILL.md +63 -15
- package/skills/agent-whatsapp/references/authentication.md +36 -6
- package/skills/agent-whatsappbot/SKILL.md +10 -1
- package/src/platforms/channeltalk/cli.ts +2 -0
- package/src/platforms/channeltalk/commands/index.ts +1 -0
- package/src/platforms/channeltalk/commands/whoami.test.ts +64 -0
- package/src/platforms/channeltalk/commands/whoami.ts +62 -0
- package/src/platforms/channeltalkbot/cli.ts +2 -0
- package/src/platforms/channeltalkbot/commands/index.ts +1 -0
- package/src/platforms/channeltalkbot/commands/whoami.test.ts +104 -0
- package/src/platforms/channeltalkbot/commands/whoami.ts +42 -0
- package/src/platforms/discord/cli.ts +2 -0
- package/src/platforms/discord/commands/index.ts +1 -0
- package/src/platforms/discord/commands/whoami.test.ts +91 -0
- package/src/platforms/discord/commands/whoami.ts +36 -0
- package/src/platforms/discord/credential-manager.test.ts +18 -1
- package/src/platforms/discordbot/cli.ts +2 -0
- package/src/platforms/discordbot/client.ts +2 -2
- package/src/platforms/discordbot/commands/index.ts +1 -0
- package/src/platforms/discordbot/commands/whoami.test.ts +96 -0
- package/src/platforms/discordbot/commands/whoami.ts +44 -0
- package/src/platforms/instagram/cli.ts +2 -1
- package/src/platforms/instagram/client.ts +13 -0
- package/src/platforms/instagram/commands/auth.test.ts +216 -0
- package/src/platforms/instagram/commands/chat.test.ts +123 -0
- package/src/platforms/instagram/commands/index.ts +1 -0
- package/src/platforms/instagram/commands/message.test.ts +174 -0
- package/src/platforms/instagram/commands/whoami.test.ts +60 -0
- package/src/platforms/instagram/commands/whoami.ts +21 -0
- package/src/platforms/kakaotalk/cli.ts +2 -1
- package/src/platforms/kakaotalk/client.test.ts +182 -14
- package/src/platforms/kakaotalk/client.ts +261 -27
- 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/whoami.test.ts +116 -0
- package/src/platforms/kakaotalk/commands/whoami.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 +29 -7
- package/src/platforms/kakaotalk/protocol/types.ts +9 -0
- package/src/platforms/kakaotalk/types.ts +30 -0
- package/src/platforms/line/cli.ts +2 -2
- 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 +37 -61
- 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/index.ts +1 -1
- package/src/platforms/line/commands/message.test.ts +119 -0
- package/src/platforms/line/commands/whoami.test.ts +85 -0
- package/src/platforms/line/commands/{profile.ts → whoami.ts} +4 -4
- package/src/platforms/slack/cli.ts +2 -0
- package/src/platforms/slack/commands/index.ts +1 -0
- package/src/platforms/slack/commands/whoami.test.ts +126 -0
- package/src/platforms/slack/commands/whoami.ts +40 -0
- package/src/platforms/slackbot/cli.ts +2 -1
- package/src/platforms/slackbot/commands/channel.test.ts +139 -0
- package/src/platforms/slackbot/commands/index.ts +1 -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/slackbot/commands/whoami.test.ts +102 -0
- package/src/platforms/slackbot/commands/whoami.ts +44 -0
- package/src/platforms/teams/cli.ts +2 -0
- package/src/platforms/teams/commands/index.ts +1 -0
- package/src/platforms/teams/commands/reaction.test.ts +45 -61
- package/src/platforms/teams/commands/reaction.ts +2 -0
- package/src/platforms/teams/commands/whoami.test.ts +83 -0
- package/src/platforms/teams/commands/whoami.ts +33 -0
- package/src/platforms/telegram/cli.ts +2 -1
- package/src/platforms/telegram/commands/chat.test.ts +125 -0
- package/src/platforms/telegram/commands/index.ts +1 -0
- package/src/platforms/telegram/commands/message.test.ts +92 -0
- package/src/platforms/telegram/commands/whoami.test.ts +75 -0
- package/src/platforms/telegram/commands/whoami.ts +29 -0
- package/src/platforms/webex/cli.ts +2 -1
- package/src/platforms/webex/commands/auth.test.ts +58 -46
- package/src/platforms/webex/commands/index.ts +1 -0
- package/src/platforms/webex/commands/member.test.ts +60 -57
- package/src/platforms/webex/commands/message.test.ts +74 -121
- package/src/platforms/webex/commands/message.ts +1 -1
- package/src/platforms/webex/commands/snapshot.test.ts +54 -45
- package/src/platforms/webex/commands/space.test.ts +46 -49
- package/src/platforms/webex/commands/whoami.test.ts +113 -0
- package/src/platforms/webex/commands/whoami.ts +31 -0
- package/src/platforms/webex/credential-manager.test.ts +0 -1
- package/src/platforms/wechatbot/cli.ts +25 -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 +5 -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/commands/whoami.test.ts +109 -0
- package/src/platforms/wechatbot/commands/whoami.ts +43 -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/cli.ts +2 -1
- package/src/platforms/whatsapp/client.ts +180 -37
- package/src/platforms/whatsapp/commands/auth.test.ts +311 -0
- package/src/platforms/whatsapp/commands/auth.ts +194 -84
- package/src/platforms/whatsapp/commands/chat.test.ts +198 -0
- package/src/platforms/whatsapp/commands/index.ts +1 -0
- package/src/platforms/whatsapp/commands/message.test.ts +231 -0
- package/src/platforms/whatsapp/commands/shared.ts +2 -2
- package/src/platforms/whatsapp/commands/whoami.test.ts +59 -0
- package/src/platforms/whatsapp/commands/whoami.ts +21 -0
- package/src/platforms/whatsapp/credential-manager.test.ts +20 -0
- package/src/platforms/whatsapp/credential-manager.ts +17 -8
- package/src/platforms/whatsapp/ensure-auth.ts +2 -2
- package/src/platforms/whatsappbot/cli.ts +2 -1
- package/src/platforms/whatsappbot/commands/auth.test.ts +217 -0
- package/src/platforms/whatsappbot/commands/index.ts +1 -0
- package/src/platforms/whatsappbot/commands/message.test.ts +198 -0
- package/src/platforms/whatsappbot/commands/template.test.ts +112 -0
- package/src/platforms/whatsappbot/commands/whoami.test.ts +100 -0
- package/src/platforms/whatsappbot/commands/whoami.ts +57 -0
- package/src/shared/utils/qr.ts +92 -0
- package/src/tui/adapters/whatsapp-adapter.ts +19 -16
- package/dist/src/platforms/line/commands/profile.d.ts +0 -3
- package/dist/src/platforms/line/commands/profile.d.ts.map +0 -1
- package/dist/src/platforms/line/commands/profile.js.map +0 -1
|
@@ -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,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AAM,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;AAC1D,CAAC,CAAC,CACL;KACA,UAAU,CACT,IAAI,OAAO,CAAC,QAAQ,CAAC;KAClB,WAAW,CAAC,yBAAyB,CAAC;KACtC,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;KAC/C,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,SAAiB,EAAE,IAA0B,EAAE,EAAE;IAC9D,SAAS,CAAC,MAAM,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;AAC7D,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","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;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,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;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,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":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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/platforms/wechatbot/commands/template.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,OAAwB;IACvD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAA;QAC9C,OAAO,EAAE,SAAS,EAAE,CAAA;IACtB,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,UAAU,CAC9B,MAA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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"],"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;AAgBpC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAoB;IACnD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QAC5D,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CA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AAyB,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,12 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { AccountOption } from './shared.js';
|
|
3
|
+
interface WhoamiResult {
|
|
4
|
+
app_id?: string | null;
|
|
5
|
+
account_name?: string | null;
|
|
6
|
+
verified?: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function whoamiAction(options: AccountOption): Promise<WhoamiResult>;
|
|
10
|
+
export declare const whoamiCommand: Command;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=whoami.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG7C,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAchF;AAOD,eAAO,MAAM,aAAa,SAMtB,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
3
|
+
import { WeChatBotCredentialManager } from '../credential-manager.js';
|
|
4
|
+
import { getClient } from './shared.js';
|
|
5
|
+
export async function whoamiAction(options) {
|
|
6
|
+
try {
|
|
7
|
+
const client = await getClient(options);
|
|
8
|
+
const verified = await client.verifyCredentials();
|
|
9
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
10
|
+
const creds = await credManager.getCredentials(options.account);
|
|
11
|
+
return {
|
|
12
|
+
app_id: creds?.app_id ?? null,
|
|
13
|
+
account_name: creds?.account_name ?? null,
|
|
14
|
+
verified,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return { error: error.message };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function cliOutput(result, pretty) {
|
|
22
|
+
console.log(formatOutput(result, pretty));
|
|
23
|
+
if (result.error)
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
export const whoamiCommand = new Command('whoami')
|
|
27
|
+
.description('Show current authenticated bot')
|
|
28
|
+
.option('--account <id>', 'Account ID to use')
|
|
29
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
30
|
+
.action(async (opts) => {
|
|
31
|
+
cliOutput(await whoamiAction(opts), opts.pretty);
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,u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"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { WeChatBotConfigSchema } from './types.js';
|
|
6
|
+
export class WeChatBotCredentialManager {
|
|
7
|
+
configDir;
|
|
8
|
+
credentialsPath;
|
|
9
|
+
constructor(configDir) {
|
|
10
|
+
this.configDir = configDir ?? join(homedir(), '.config', 'agent-messenger');
|
|
11
|
+
this.credentialsPath = join(this.configDir, 'wechatbot-credentials.json');
|
|
12
|
+
}
|
|
13
|
+
async load() {
|
|
14
|
+
if (!existsSync(this.credentialsPath)) {
|
|
15
|
+
return { current: null, accounts: {} };
|
|
16
|
+
}
|
|
17
|
+
const content = await readFile(this.credentialsPath, 'utf-8');
|
|
18
|
+
let json;
|
|
19
|
+
try {
|
|
20
|
+
json = JSON.parse(content);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return { current: null, accounts: {} };
|
|
24
|
+
}
|
|
25
|
+
const parsed = WeChatBotConfigSchema.safeParse(json);
|
|
26
|
+
if (!parsed.success) {
|
|
27
|
+
return { current: null, accounts: {} };
|
|
28
|
+
}
|
|
29
|
+
return parsed.data;
|
|
30
|
+
}
|
|
31
|
+
async save(config) {
|
|
32
|
+
await mkdir(this.configDir, { recursive: true });
|
|
33
|
+
await writeFile(this.credentialsPath, JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
34
|
+
await chmod(this.credentialsPath, 0o600);
|
|
35
|
+
}
|
|
36
|
+
async getCredentials(accountId) {
|
|
37
|
+
const envAppId = process.env.E2E_WECHATBOT_APP_ID;
|
|
38
|
+
const envAppSecret = process.env.E2E_WECHATBOT_APP_SECRET;
|
|
39
|
+
if (envAppId && envAppSecret && !accountId) {
|
|
40
|
+
return {
|
|
41
|
+
app_id: envAppId,
|
|
42
|
+
app_secret: envAppSecret,
|
|
43
|
+
account_name: 'env',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const config = await this.load();
|
|
47
|
+
if (accountId) {
|
|
48
|
+
const account = config.accounts[accountId];
|
|
49
|
+
if (!account)
|
|
50
|
+
return null;
|
|
51
|
+
return {
|
|
52
|
+
app_id: account.app_id,
|
|
53
|
+
app_secret: account.app_secret,
|
|
54
|
+
account_name: account.account_name,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (!config.current) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const account = config.accounts[config.current.account_id];
|
|
61
|
+
if (!account)
|
|
62
|
+
return null;
|
|
63
|
+
return {
|
|
64
|
+
app_id: account.app_id,
|
|
65
|
+
app_secret: account.app_secret,
|
|
66
|
+
account_name: account.account_name,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async setCredentials(entry) {
|
|
70
|
+
const config = await this.load();
|
|
71
|
+
config.accounts[entry.app_id] = {
|
|
72
|
+
app_id: entry.app_id,
|
|
73
|
+
app_secret: entry.app_secret,
|
|
74
|
+
account_name: entry.account_name,
|
|
75
|
+
};
|
|
76
|
+
config.current = {
|
|
77
|
+
account_id: entry.app_id,
|
|
78
|
+
};
|
|
79
|
+
await this.save(config);
|
|
80
|
+
}
|
|
81
|
+
async removeAccount(accountId) {
|
|
82
|
+
const config = await this.load();
|
|
83
|
+
if (!config.accounts[accountId]) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
delete config.accounts[accountId];
|
|
87
|
+
if (config.current?.account_id === accountId) {
|
|
88
|
+
config.current = null;
|
|
89
|
+
}
|
|
90
|
+
await this.save(config);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
async setCurrent(accountId) {
|
|
94
|
+
const config = await this.load();
|
|
95
|
+
if (!config.accounts[accountId]) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
config.current = {
|
|
99
|
+
account_id: accountId,
|
|
100
|
+
};
|
|
101
|
+
await this.save(config);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
async listAll() {
|
|
105
|
+
const config = await this.load();
|
|
106
|
+
const results = [];
|
|
107
|
+
for (const account of Object.values(config.accounts)) {
|
|
108
|
+
results.push({
|
|
109
|
+
app_id: account.app_id,
|
|
110
|
+
app_secret: account.app_secret,
|
|
111
|
+
account_name: account.account_name,
|
|
112
|
+
is_current: config.current?.account_id === account.app_id,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return results;
|
|
116
|
+
}
|
|
117
|
+
async clearCredentials() {
|
|
118
|
+
await this.save({ current: null, accounts: {} });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=credential-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../../../src/platforms/wechatbot/credential-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE/C,MAAM,OAAO,0BAA0B;IAC7B,SAAS,CAAQ;IACjB,eAAe,CAAQ;IAE/B,YAAY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GAA2D,EAAE,CAAA;QAE1E,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrD,OAAO,CAAC,IAAI,CAAC;gBACX,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,YAAY,EAAE,OAAO,CAAC,YAAY;gBAClC,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,MAAM;aAC1D,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { WeChatBotClient } from './client.js';
|
|
2
|
+
export { WeChatBotCredentialManager } from './credential-manager.js';
|
|
3
|
+
export type { WeChatBotAccountEntry, WeChatBotConfig, WeChatBotCredentials, WeChatBotNewsArticle, WeChatBotTemplate, WeChatBotUserInfo, } from './types.js';
|
|
4
|
+
export { WeChatBotAccountEntrySchema, WeChatBotConfigSchema, WeChatBotCredentialsSchema, WeChatBotError, WeChatBotNewsArticleSchema, WeChatBotTemplateSchema, WeChatBotUserInfoSchema, } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/platforms/wechatbot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AACjE,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,0BAA0B,EAC1B,cAAc,EACd,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { WeChatBotClient } from './client.js';
|
|
2
|
+
export { WeChatBotCredentialManager } from './credential-manager.js';
|
|
3
|
+
export { WeChatBotAccountEntrySchema, WeChatBotConfigSchema, WeChatBotCredentialsSchema, WeChatBotError, WeChatBotNewsArticleSchema, WeChatBotTemplateSchema, WeChatBotUserInfoSchema, } from './types.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platforms/wechatbot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AASjE,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,0BAA0B,EAC1B,cAAc,EACd,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,SAAS,CAAA"}
|