juzibot / wxwork-tester-deprecated

35 stars 6 forks source link

项目无法运行,代码报错如下 #65

Open littlezyx opened 2 years ago

littlezyx commented 2 years ago

代码: import {log, ScanStatus, WechatyBuilder} from "wechaty"; import {PuppetPadlocal} from "wechaty-puppet-padlocal"; import {PuppetService} from "wechaty-puppet-service"; import {dingDongBot, getMessagePayload, LOGPRE} from "./helper";

/****

const puppet = new PuppetService({ token: "puppet_wxwork_6f2c0273cebc444a" })

const bot = WechatyBuilder.build({ name: "PuppetServiceDemo", puppet, }) .on("scan", (qrcode, status) => { if (status === ScanStatus.Waiting && qrcode) { // const qrcodeImageUrl = [ // 'https://wechaty.js.org/qrcode/', // encodeURIComponent(qrcode), // ].join('')

  // log.info(LOGPRE, `onScan: ${ScanStatus[status]}(${status})`);

  // console.log("\n==================================================================");
  // console.log("\n* Two ways to sign on with qr code");
  // console.log("\n1. Scan following QR code:\n");

  require('qrcode-terminal').generate(qrcode, {small: true})  // show qrcode on console

  // console.log(`\n2. Or open the link in your browser: ${qrcodeImageUrl}`);
  console.log("\n==================================================================\n");
} else {
  log.info(LOGPRE, `onScan: ${ScanStatus[status]}(${status})`);
}

})

.on("login", (user) => { log.info(LOGPRE, ${user} login); })

.on("logout", (user, reason) => { log.info(LOGPRE, ${user} logout, reason: ${reason}); })

.on("message", async (message) => { log.info(LOGPRE, on message: ${message.toString()});

await getMessagePayload(message);

await dingDongBot(message);

})

.on("room-invite", async (roomInvitation) => { log.info(LOGPRE, on room-invite: ${roomInvitation}); })

.on("room-join", (room, inviteeList, inviter, date) => { log.info(LOGPRE, on room-join, room:${room}, inviteeList:${inviteeList}, inviter:${inviter}, date:${date}); })

.on("room-leave", (room, leaverList, remover, date) => { log.info(LOGPRE, on room-leave, room:${room}, leaverList:${leaverList}, remover:${remover}, date:${date}); })

.on("room-topic", (room, newTopic, oldTopic, changer, date) => { log.info(LOGPRE, on room-topic, room:${room}, newTopic:${newTopic}, oldTopic:${oldTopic}, changer:${changer}, date:${date}); })

.on("friendship", (friendship) => { log.info(LOGPRE, on friendship: ${friendship}); })

.on("error", (error) => { log.error(LOGPRE, on error: ${error}); })

bot.start().then(() => { log.info(LOGPRE, "started."); }); 报错: Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) { errno: -54, code: 'ECONNRESET', syscall: 'read' } 16:01:03 ERR [PadLocalDemo] on error: Error: 14 UNAVAILABLE: No connection established 16:01:03 WARN ServiceCtl stop() found that is starting... 16:01:03 WARN ServiceCtl stop() found that is starting, waiting stable ... (max 5 seconds) 16:01:08 ERR [PadLocalDemo] on error: DEADLINE_EXCEEDED: Timeout after 5000 ms 16:01:08 WARN ServiceCtl stop() found that is starting, waiting stable ... timeout 16:01:08 ERR [PadLocalDemo] on error: Error: 14 UNAVAILABLE: No connection established 16:01:08 ERR [PadLocalDemo] on error: Error: 14 UNAVAILABLE: No connection established 16:01:08 INFO [PadLocalDemo] started.

hcfw007 commented 2 years ago
const puppet = new PuppetService({
  token: "puppet_wxwork_6f2c0273cebc444a"
})

改为

const puppet = new PuppetService({
  tls: {
    disable: true
  },
  token: "puppet_wxwork_6f2c0273cebc444a"
})