Skip to content

Commit c0fda87

Browse files
committed
init
0 parents  commit c0fda87

7 files changed

+1165
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
mixin.bot

bot.config

Whitespace-only changes.

index.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
const CLIENT_CONFIG = {
2+
client_id: "65334040-1fd0-4142-98ce-4fbd0e81aaab",
3+
client_secret: "d9dc58107xxxxxxxxxxxxxxxxxx",
4+
pin: "415447",
5+
session_id: "8ca9dc89-5d26-4dc4-8a35-5afdd027a4dc",
6+
pin_token: "tDs2MunwyNb8l_i9VDmSKgUIkIr69lIUPDgAgeUQxyA",
7+
private_key:
8+
"1TwZvIRmNGXW2wO92BoZaH5wcKMGzHcRBcOdYljP-6Biqes4_9ipMsN9v_kG2nmh-YGrxl53X2DlzcGA_4NLwQ",
9+
};
10+
11+
const API_KEY = "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";
12+
13+
const request = require("request");
14+
const { MixinSocket } = require("mixin-node-sdk");
15+
16+
const socketClient = new MixinSocket(CLIENT_CONFIG, true, true);
17+
18+
const MODEL = "text-davinci-003";
19+
const API_URL = "https://api.openai.com/v1/completions";
20+
21+
socketClient.get_message_handler = async function (message) {
22+
await this.read_message(message);
23+
24+
if (
25+
!message.action ||
26+
message.action === "ACKNOWLEDGE_MESSAGE_RECEIPT" ||
27+
message.action === "LIST_PENDING_MESSAGES" ||
28+
!message.data ||
29+
!message.data.data
30+
) {
31+
return;
32+
}
33+
34+
if (message.error) return console.log(message.error);
35+
36+
const TEXT = message.data.parseData;
37+
38+
const options = {
39+
method: "POST",
40+
url: API_URL,
41+
headers: {
42+
"Content-Type": "application/json",
43+
Authorization: `Bearer ${API_KEY}`,
44+
},
45+
json: {
46+
prompt: TEXT,
47+
max_tokens: 1024,
48+
temperature: 0.6,
49+
model: MODEL,
50+
},
51+
};
52+
53+
if (message.data.category === "PLAIN_TEXT") {
54+
const self = this;
55+
request(options, function (error, response, body) {
56+
if (!error && response.statusCode == 200) {
57+
const result = body.choices[0].text.replace(/\n[\n]+/g, "");
58+
self.send_text(result, message);
59+
} else {
60+
console.error(error);
61+
}
62+
});
63+
} else {
64+
await this.send_text("Not text", message);
65+
}
66+
};
67+
68+
socketClient.start();

mixin.bot

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"pin": "415447",
3+
"client_id": "65334040-1fd0-4142-98ce-4fbd0e81aaab",
4+
"session_id": "8ca9dc89-5d26-4dc4-8a35-5afdd027a4dc",
5+
"pin_token": "tDs2MunwyNb8l_i9VDmSKgUIkIr69lIUPDgAgeUQxyA",
6+
"private_key": "1TwZvIRmNGXW2wO92BoZaH5wcKMGzHcRBcOdYljP-6Biqes4_9ipMsN9v_kG2nmh-YGrxl53X2DlzcGA_4NLwQ"
7+
}
8+
9+
26fd0be9e5b5def75d2401b2071b06ec8f2c11e64bb2ee05daa16b0c729e9294
10+
11+
https://mixin.one/codes/30ce4c48-d079-42b0-aa85-a6f1d74ac909

0 commit comments

Comments
 (0)