create-message-kit 1.1.7-beta.1 → 1.1.7-beta.4

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.1.7-beta.1",
3
+ "version": "1.1.7-beta.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -0,0 +1,24 @@
1
+ import { HandlerContext } from "@xmtp/message-kit";
2
+
3
+ export async function handler(context: HandlerContext) {
4
+ const {
5
+ skills,
6
+ group,
7
+ message: {
8
+ content: { command },
9
+ },
10
+ } = context;
11
+
12
+ if (command == "help") {
13
+ const intro =
14
+ "Available experiences:\n" +
15
+ skills
16
+ ?.flatMap((app) => app.skills)
17
+ .map((skill) => `${skill.command} - ${skill.description}`)
18
+ .join("\n") +
19
+ "\nUse these skills to interact with specific apps.";
20
+ context.send(intro);
21
+ } else if (command == "id") {
22
+ context.send(context.group?.id);
23
+ }
24
+ }
@@ -1,26 +1,20 @@
1
1
  import { run, HandlerContext } from "@xmtp/message-kit";
2
- import { handler as splitpayment } from "./handler/splitpayment.js";
3
2
 
4
3
  // Main function to run the app
5
- run(
6
- async (context: HandlerContext) => {
7
- const {
8
- message: { typeId },
9
- } = context;
10
- switch (typeId) {
11
- case "reply":
12
- handleReply(context);
13
- break;
14
- case "remoteStaticAttachment":
15
- handleAttachment(context);
16
- break;
17
- }
18
- if (!context.group) {
19
- context.send("This is a group bot, add this address to a group");
20
- }
21
- },
22
- { attachments: true },
23
- );
4
+ run(async (context: HandlerContext) => {
5
+ const {
6
+ message: { typeId },
7
+ group,
8
+ } = context;
9
+ switch (typeId) {
10
+ case "reply":
11
+ handleReply(context);
12
+ break;
13
+ }
14
+ if (!group) {
15
+ context.send("This is a group bot, add this address to a group");
16
+ }
17
+ });
24
18
  async function handleReply(context: HandlerContext) {
25
19
  const {
26
20
  v2client,
@@ -38,20 +32,3 @@ async function handleReply(context: HandlerContext) {
38
32
  );
39
33
  //await context.skill(chain);
40
34
  }
41
-
42
- // Handle attachment messages
43
- async function handleAttachment(context: HandlerContext) {
44
- await splitpayment(context);
45
- }
46
-
47
- export async function helpHandler(context: HandlerContext) {
48
- const { skills } = context;
49
- const intro =
50
- "Available experiences:\n" +
51
- skills
52
- ?.flatMap((app) => app.skills)
53
- .map((skill) => `${skill.command} - ${skill.description}`)
54
- .join("\n") +
55
- "\nUse these skills to interact with specific apps.";
56
- context.send(intro);
57
- }
@@ -3,7 +3,7 @@ import { handler as agent } from "./handler/agent.js";
3
3
  import { handler as transaction } from "./handler/transaction.js";
4
4
  import { handler as games } from "./handler/game.js";
5
5
  import { handler as loyalty } from "./handler/loyalty.js";
6
- import { helpHandler } from "./index.js";
6
+ import { handler as groupHelp } from "./handler/group.js";
7
7
  import type { SkillGroup } from "@xmtp/message-kit";
8
8
 
9
9
  export const skills: SkillGroup[] = [
@@ -31,6 +31,7 @@ export const skills: SkillGroup[] = [
31
31
  },
32
32
  ],
33
33
  },
34
+
34
35
  {
35
36
  name: "Transactions",
36
37
  description: "Multipurpose transaction frame built onbase.",
@@ -159,10 +160,18 @@ export const skills: SkillGroup[] = [
159
160
  command: "/help",
160
161
  triggers: ["/help"],
161
162
  examples: ["/help"],
162
- handler: helpHandler,
163
+ handler: groupHelp,
163
164
  description: "Get help with the bot.",
164
165
  params: {},
165
166
  },
167
+ {
168
+ command: "/id",
169
+ adminOnly: true,
170
+ handler: groupHelp,
171
+ triggers: ["/id"],
172
+ description: "Get the group ID.",
173
+ params: {},
174
+ },
166
175
  ],
167
176
  },
168
177
  ];