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:
|
63
|
+
params: { [key: string]: string | number | string[] | undefined },
|
64
64
|
) {
|
65
65
|
// Filter out undefined parameters
|
66
|
-
let filteredParams: {
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
37
|
-
|
47
|
+
v2client,
|
48
|
+
getReplyChain,
|
49
|
+
version,
|
50
|
+
message: {
|
51
|
+
content: { content: emoji, action, reference },
|
52
|
+
},
|
53
|
+
} = context;
|
38
54
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
55
|
+
const { chain, isSenderInChain } = await getReplyChain(
|
56
|
+
reference,
|
57
|
+
version,
|
58
|
+
v2client.address,
|
59
|
+
);
|
60
|
+
console.log(chain);
|
43
61
|
|
44
|
-
|
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
|
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(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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