Closed Walkoud closed 1 year ago
try: import { BotNickNameEnum, PoeClient } from "poe-node-api"; const chatBot = new PoeClient({ cookie: yourCookie, debug: true }); await chatBot.init(); await chatBot.sendMessage(xx, xx, xx, xx)
You can check out the example directory. If you build from source, make sure copy the graphql dir to dist.
I got this error :
__dirname: C:\Users\volka\Desktop\POE NODE JS\poe-client\node_modules\poe-node-api\dist
test
fetch: https://poe.com, options: {
method: 'GET',
headers: { cookie: 'p-b=MxxxxxxxxxxxxxxxxxxxxxxxxxxxxD' }
}
fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/Sage.json, options: {
method: 'GET',
headers: { cookie: 'p-b=MxxxxxxxxxxxxxxxxxxxxxxxxD' }
}
fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/GPT-4.json, options: {
method: 'GET',
headers: { cookie: 'p-b=Mxxxxxxxxxxxxxxxxxxxxxxxxxxx%3D' }
}
fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/Claude+.json, options: {
method: 'GET',
headers: { cookie: 'p-b=M98xxxxxxxxxxxxxxxxx3D%3D' }
}
fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/Claude-instant.json, options: {
method: 'GET',
headers: { cookie: 'p-b=Mxxxxxxxxxxxxxxxxxxxxx3D%3D' }
}
fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/ChatGPT.json, options: {
method: 'GET',
headers: { cookie: 'p-b=MxxxxxxxxxxxxxxxxxxxxxxxxxxxD' }
}
fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/NeevaAI.json, options: {
method: 'GET',
headers: { cookie: 'p-b=Mxxxxxxxxxiaxxxxxxxxxx%3D%3D' }
}
fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, options: {
method: 'GET',
headers: { cookie: 'p-b=M9xxxxxxxxxxxxxxxxxxxxxxxxxxxxxD%3D' }
}
retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 1/5...54
fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found
retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 2/5...57
fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found
retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 3/5...59
fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found
retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 4/5...1
fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found
retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 5/5...3
fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found
file:///C:/Users/volka/Desktop/POE%20NODE%20JS/poe-client/node_modules/poe-node-api/dist/PoeClient.js:93
reject(new Error(Failed to fetch ${url} after ${retry} retries
));
^
Error: Failed to fetch https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json after 5 retries at file:///C:/Users/volka/Desktop/POE%20NODE%20JS/poe-client/node_modules/poe-node-api/dist/PoeClient.js:93:24 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v18.14.2
I got this error :
__dirname: C:\Users\volka\Desktop\POE NODE JS\poe-client\node_modules\poe-node-api\dist test fetch: https://poe.com, options: { method: 'GET', headers: { cookie: 'p-b=MxxxxxxxxxxxxxxxxxxxxxxxxxxxxD' } } fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/Sage.json, options: { method: 'GET', headers: { cookie: 'p-b=MxxxxxxxxxxxxxxxxxxxxxxxxD' } } fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/GPT-4.json, options: { method: 'GET', headers: { cookie: 'p-b=Mxxxxxxxxxxxxxxxxxxxxxxxxxxx%3D' } } fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/Claude+.json, options: { method: 'GET', headers: { cookie: 'p-b=M98xxxxxxxxxxxxxxxxx3D%3D' } } fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/Claude-instant.json, options: { method: 'GET', headers: { cookie: 'p-b=Mxxxxxxxxxxxxxxxxxxxxx3D%3D' } } fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/ChatGPT.json, options: { method: 'GET', headers: { cookie: 'p-b=MxxxxxxxxxxxxxxxxxxxxxxxxxxxD' } } fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/NeevaAI.json, options: { method: 'GET', headers: { cookie: 'p-b=Mxxxxxxxxxiaxxxxxxxxxx%3D%3D' } } fetch: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, options: { method: 'GET', headers: { cookie: 'p-b=M9xxxxxxxxxxxxxxxxxxxxxxxxxxxxxD%3D' } } retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 1/5...54 fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 2/5...57 fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 3/5...59 fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 4/5...1 fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found retrying https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 5/5...3 fetch failed: https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json, 404, Not Found file:///C:/Users/volka/Desktop/POE%20NODE%20JS/poe-client/node_modules/poe-node-api/dist/PoeClient.js:93 reject(new Error(
Failed to fetch ${url} after ${retry} retries
)); ^Error: Failed to fetch https://poe.com/_next/data/-rScRmOK6zRMfpJb0lCf3/undefined.json after 5 retries at file:///C:/Users/volka/Desktop/POE%20NODE%20JS/poe-client/node_modules/poe-node-api/dist/PoeClient.js:93:24 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v18.14.2
Seems like DisplayName is undefined, please check your botNickName is using BotNickNameEnum.xxx
(may pass the wrong nickName), and I will add undefined check to botNickName.
i use BotNickNameEnum.capybara
i use BotNickNameEnum.capybara
Can you show me your test code? I don not know why BotNickNameEnum.capybara can not get the displayName, from the code logic, it shoud be ok. And try pass string 'capybara' as botNickName param.
capybara
import { BotNickNameEnum, PoeClient } from "poe-node-api"; const chatBot = new PoeClient({ cookie: "p-b=Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%3D%3D", debug: false });
console.log("test")
async function sendmsg(){
await chatBot.init();
await chatBot.updateAllBotInfo()
await chatBot.sendMessage("Ping", BotNickNameEnum.chinchilla, false, (result) => {
console.log(`${result}`)
})
}
sendmsg();
capybara
import { BotNickNameEnum, PoeClient } from "poe-node-api"; const chatBot = new PoeClient({ cookie: "p-b=Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%3D%3D", debug: false });
console.log("test")
async function sendmsg(){
await chatBot.init(); await chatBot.updateAllBotInfo() await chatBot.sendMessage("Ping", BotNickNameEnum.chinchilla, false, (result) => { console.log(`${result}`) })
}
sendmsg();
ok, I'll try it immediately.
capybara
import { BotNickNameEnum, PoeClient } from "poe-node-api"; const chatBot = new PoeClient({ cookie: "p-b=Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%3D%3D", debug: false });
console.log("test")
async function sendmsg(){
await chatBot.init(); await chatBot.updateAllBotInfo() await chatBot.sendMessage("Ping", BotNickNameEnum.chinchilla, false, (result) => { console.log(`${result}`) })
}
sendmsg();
I just change cookie, and ran your code, it's working fine on my computer.
yarn run build; node .\dist\test.js > sendMsg.json
Try: check .env file is in dir, and open debug mode, check network.
how I can use your module in a .js file ? I am still a beginner, sorry
I compiled, but I still don't know how it works