This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
sendMsg.ts
116 lines (99 loc) · 4.37 KB
/
sendMsg.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import {BotNickNameEnum, PoeClient, sleep} from "../src/PoeClient";
// Temporary use:
// Move this file to src/
// Terminal run: cp -r graphql dist/
// Terminal run: yarn run build
// Terminal run: node .\dist\sendMsg.js > sendMsg.log 2>&1
// ========================= use env for one account =========================
const client = new PoeClient({logLevel: 'debug'});
await client.init(true)
await sendMsg()
async function sendMsg() {
console.log(`sleeping...`)
await sleep(2000)
await client.sendMessage("Ping", BotNickNameEnum.capybara, true, (result: string) => {
console.log(`${result}`)
})
console.log(`msg sent!`)
}
// ========================= use envMap for multi-account =========================
// console.log(`\n\n============================== Get configurations first ==============================`)
// let cookies = ['p-b=fTCxxx%3D', 'p-b=ZLuSTxxxxxD'];
// const clientMap = new Map<number, PoeClient>()
// const envMap = new Map<number, ProcessEnv>()
//
// for (let i = 0; i < cookies.length; i++) {
// let cookie = cookies[i];
// // let uuid = randomUUID();
//
// const client = new PoeClient({
// cookie: cookie,
// env: {}, // pass {"poe-formkey": "xxx", "buildId": "xxx" ......} after fetch them first from client1.init()
// logLevel: 'debug'
// });
// const envMap1 = await client.init(false)
// console.log(`envMap1:`, JSON.stringify(envMap1, null, 2))
//
// envMap.set(i, envMap1)
//
// // store envMap1 somewhere, next time pass envMap1 as env to PoeClient constructor, client will read needed info like buildId from env passed in
// clientMap.set(i, client)
// }
// console.log(`\n\n============================== get client and chat ==============================`)
// const client1 = clientMap.get(0)!
// // next time pass envMap1 as env to PoeClient constructor, client will read needed info like buildId from env passed in
// await client1.sendMessage("Give me 2 English words.", BotNickNameEnum.capybara, true, (result: string) => {
// console.log(`${result}`)
// })
// await sleep(2000)
//
// const client2 = clientMap.get(1)!
// await client2.sendMessage("Give me 3 English words.", BotNickNameEnum.capybara, true, (result: string) => {
// console.log(`${result}`)
// })
// await sleep(2000)
// console.log(`\n\n============================== Continue sendMessage ==============================`)
// await client1.sendMessage("What we are talking about?", BotNickNameEnum.capybara, false, (result: string) => {
// console.log(`${result}`)
// })
// await sleep(2000)
// console.log(`\n\n============================== Continue sendMessage by client2 ==============================`)
// await client2.sendMessage("What we are talking about?", BotNickNameEnum.capybara, false, (result: string) => {
// console.log(`${result}`)
// })
// await sleep(2000)
// console.log(`\n\n============================== Next time, Start chat with envMap ==============================`)
// const client3 = new PoeClient({
// cookie: cookies[0],
// env: {
// "poe-formkey": "be6xxxb52a92812",
// "buildId": "rCiSJxxxxbFAj",
// "capybara_-_Sage_chatId": "xxxx",
// "capybara_-_Sage_id": "xxxxx==",
// "beaver_-_GPT-4_chatId": "xxxxx",
// "beaver_-_GPT-4_id": "xxxx==",
// "a2_2_-_Claude_2_chatId": "xxxx",
// "a2_2_-_Claude_2_id": "xxxx==",
// "a2_100k_-_Claude-instant-100k_chatId": "xxxx",
// "a2_100k_-_Claude-instant-100k_id": "xxx==",
// "a2_-_Claude-instant_chatId": "xxxx",
// "a2_-_Claude-instant_id": "xxxx==",
// "chinchilla_-_ChatGPT_chatId": "xxx",
// "chinchilla_-_ChatGPT_id": "xxxx==",
// "nutria_-_Dragonfly_chatId": "xxx",
// "nutria_-_Dragonfly_id": "xxxxxx=="
// }, // pass env stored from last time, {"poe-formkey": "xxx", "buildId": "xxx" ......}
// logLevel: 'debug'
// });
// let env3 = await client3.init(false); // env3 is the same as env passed to PoeClient constructor
// console.log(`env3:`, JSON.stringify(env3, null, 2))
// await sleep(2000)
// await client3.sendMessage("What topic we are talking about?", BotNickNameEnum.capybara, false, (result: string) => {
// console.log(`${result}`)
// })
// await clear()
// async function clear() {
// console.log(`sleeping...`)
// await sleep(2000)
// await client.clearContext(BotNickNameEnum.capybara);
// }