create-message-kit 1.0.7 → 1.0.9

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.
@@ -60,10 +60,12 @@ export async function handler(context: HandlerContext) {
60
60
  function generateFrameURL(
61
61
  baseUrl: string,
62
62
  transaction_type: string,
63
- params: any,
63
+ params: { [key: string]: string | number | string[] | undefined },
64
64
  ) {
65
65
  // Filter out undefined parameters
66
- let filteredParams: { [key: string]: any } = {};
66
+ let filteredParams: {
67
+ [key: string]: string | number | string[] | undefined;
68
+ } = {};
67
69
 
68
70
  for (const key in params) {
69
71
  if (params[key] !== undefined) {
@@ -8,45 +8,58 @@ run(async (context: HandlerContext) => {
8
8
  const {
9
9
  message: { typeId },
10
10
  } = context;
11
- try {
12
- switch (typeId) {
13
- case "reaction":
14
- handleReaction(context);
15
- break;
16
- case "reply":
17
- handleReply(context);
18
- break;
19
- case "remoteStaticAttachment":
20
- handleAttachment(context);
21
- break;
22
- case "text":
23
- handleTextMessage(context);
24
- break;
25
- default:
26
- console.warn(`Unhandled message type: ${typeId}`);
27
- }
28
- } catch (error) {
29
- console.error("Error handling message:", error);
11
+ switch (typeId) {
12
+ case "reaction":
13
+ handleReaction(context);
14
+ break;
15
+ case "reply":
16
+ handleReply(context);
17
+ break;
18
+ case "remoteStaticAttachment":
19
+ handleAttachment(context);
20
+ break;
21
+ case "text":
22
+ handleTextMessage(context);
23
+ break;
30
24
  }
31
25
  });
26
+ async function handleReply(context: HandlerContext) {
27
+ const {
28
+ v2client,
29
+ getReplyChain,
30
+ version,
31
+ message: {
32
+ content: { reference },
33
+ },
34
+ } = context;
32
35
 
36
+ const { chain, isSenderInChain } = await getReplyChain(
37
+ reference,
38
+ version,
39
+ v2client.address,
40
+ );
41
+ console.log(chain);
42
+ handleTextMessage(context);
43
+ }
33
44
  // Handle reaction messages
34
45
  async function handleReaction(context: HandlerContext) {
35
46
  const {
36
- content: { content: emoji, action },
37
- } = context.message;
47
+ v2client,
48
+ getReplyChain,
49
+ version,
50
+ message: {
51
+ content: { content: emoji, action, reference },
52
+ },
53
+ } = context;
38
54
 
39
- if (action === "added" && (emoji === "degen" || emoji === "🎩")) {
40
- await tipping(context);
41
- }
42
- }
55
+ const { chain, isSenderInChain } = await getReplyChain(
56
+ reference,
57
+ version,
58
+ v2client.address,
59
+ );
60
+ console.log(chain);
43
61
 
44
- // Handle reply messages
45
- async function handleReply(context: HandlerContext) {
46
- const {
47
- content: { content: reply },
48
- } = context.message;
49
- if (reply.includes("degen")) {
62
+ if (action === "added" && (emoji === "degen" || emoji === "🎩")) {
50
63
  await tipping(context);
51
64
  }
52
65
  }
@@ -1,15 +1,23 @@
1
- import OpenAI from "openai";
1
+ import dotenv from "dotenv";
2
+ dotenv.config();
2
3
 
4
+ import OpenAI from "openai";
3
5
  const openai = new OpenAI({
4
6
  apiKey: process.env.OPEN_AI_API_KEY,
5
7
  });
6
8
 
7
- export async function textGeneration(userPrompt: string, systemPrompt: string) {
8
- let messages = [];
9
- messages.push({
10
- role: "system",
11
- content: systemPrompt,
12
- });
9
+ export async function textGeneration(
10
+ userPrompt: string,
11
+ systemPrompt: string,
12
+ chatHistory?: any[],
13
+ ) {
14
+ let messages = chatHistory ? [...chatHistory] : []; // Start with existing chat history
15
+ if (messages.length === 0) {
16
+ messages.push({
17
+ role: "system",
18
+ content: systemPrompt,
19
+ });
20
+ }
13
21
  messages.push({
14
22
  role: "user",
15
23
  content: userPrompt,
package/index.js CHANGED
@@ -173,6 +173,7 @@ function createGitignore(destDir) {
173
173
  node_modules/
174
174
  .gitignore
175
175
  .cache/
176
+ .data/
176
177
  dist/
177
178
  .DS_Store
178
179
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",