{"action":"created","issue":{"url":"https://api.github.com/repos/Chatie/wechaty/issues/1573","repository_url":"https://api.github.com/repos/Chatie/wechaty","labels_url":"https://api.github.com/repos/Chatie/wechaty/issues/1573/labels{/name}","comments_url":"https://api.github.com/repos/Chatie/wechaty/issues/1573/comments","events_url":"https://api.github.com/repos/Chatie/wechaty/issues/1573/events","html_url":"https://github.com/Chatie/wechaty/issues/1573","id":355257330,"node_id":"MDU6SXNzdWUzNTUyNTczMzA=","number":1573,"title":"memberAll() not running in docker after v0.21.27","user":{"login":"kis87988","id":25014776,"node_id":"MDQ6VXNlcjI1MDE0Nzc2","avatar_url":"https://avatars2.githubusercontent.com/u/25014776?v=4","gravatar_id":"","url":"https://api.github.com/users/kis87988","html_url":"https://github.com/kis87988","followers_url":"https://api.github.com/users/kis87988/followers","following_url":"https://api.github.com/users/kis87988/following{/other_user}","gists_url":"https://api.github.com/users/kis87988/gists{/gist_id}","starred_url":"https://api.github.com/users/kis87988/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kis87988/subscriptions","organizations_url":"https://api.github.com/users/kis87988/orgs","repos_url":"https://api.github.com/users/kis87988/repos","events_url":"https://api.github.com/users/kis87988/events{/privacy}","received_events_url":"https://api.github.com/users/kis87988/received_events","type":"User","site_admin":false},"labels":[{"id":367767329,"node_id":"MDU6TGFiZWwzNjc3NjczMjk=","url":"https://api.github.com/repos/Chatie/wechaty/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-08-29T17:20:40Z","updated_at":"2018-08-30T16:01:33Z","closed_at":"2018-08-30T16:01:33Z","author_association":"CONTRIBUTOR","body":"### 0. Report Issue Guide\r\n\r\n0. Please search in the issue first, and make sure your problem had not been reported before.\r\n1. If your issue is related to _wechaty-puppet-padchat_, please report the issue at <https://github.com/lijiarui/wechaty-puppet-padchat/issues/new>\r\n2. If your issue is related to _wechaty-puppet-puppeteer_, please report the issue at <https://github.com/Chatie/wechaty-puppet-puppeteer/issues/new>\r\n3. If your issue is DIRECT related to Wechaty, then please follow the below template and make sure you fill it as required in detail.\r\n\r\n### 1. Expected behavior\r\n\r\n**Question: What behavior do you expect?**\r\n\r\nAnswer: run the bot \r\n### 2. Actual behavior\r\n\r\n**Question: What actual behavior did you experience?**\r\n\r\nAnswer: not pass ts-node --type-check\r\n\r\n### 3. Steps to reproduce your problem (and fixes, if any)\r\n\r\nThis part is very important: if you can not provide any reproduce steps, then the problem will be very hard to be recognized.\r\n\r\n**Question: What're the reproducible steps for us to see your problem?**\r\nPlease check code below with replace room id and token id run in the padchat with docker version after v0.21.27\r\n\r\n```ts \r\nimport\r\n{\r\n  Room,\r\n  Contact,\r\n  Wechaty,\r\n  Message,\r\n  Friendship,\r\n  log,\r\n  qrcodeValueToImageUrl,\r\n} from 'wechaty'\r\nimport { PuppetPadchat } from 'wechaty-puppet-padchat';\r\nimport { generate } from 'qrcode-terminal'\r\nimport { finis } from 'finis'\r\n\r\n\r\nexport const PUPPET = new PuppetPadchat({\r\n  endpoint: 'ws://padchat.botorange.com/wx',\r\n  token: '',    \r\n})\r\nconst roomID_NAME = `123@chatroom`\r\n\r\nconst BOT_NAME: string = \"Ponyo_1\"\r\nconst BOT = new Wechaty({\r\n  name: BOT_NAME,\r\n  puppet: PUPPET,\r\n})\r\nconst AVOID_ID_LIST = [\"filehelper\", \"floatbottle\", \"fmessage\",\r\n  \"medianote\", \"weixin\"]\r\n\r\nlet alive_interval_no: NodeJS.Timer\r\nlet manager: Contact | undefined = undefined\r\nlet quiting = false\r\n\r\n\r\n/* stop signal listener */\r\nlet killChrome: NodeJS.SignalsListener\r\nfinis(async (code, signal) =>\r\n{\r\n  log.info('Bot', 'finis(%s, %s)', code, signal)\r\n\r\n  if (!BOT.logonoff())\r\n  {\r\n    log.info('Bot', 'finis() bot had been already stopped')\r\n    await doExit(code)\r\n  }\r\n\r\n  if (quiting)\r\n  {\r\n    log.warn('Bot', 'finis() already quiting... return and wait...')\r\n    return\r\n  }\r\n\r\n  quiting = true\r\n  let done = false\r\n  // let checkNum = 0\r\n\r\n  const exitMsg = `Wechaty will exit ${code} because of ${signal} `\r\n\r\n  log.info('Bot', 'finis() broadcast quiting message for bot')\r\n  await BOT.say(exitMsg)\r\n    // .then(() => bot.stop())\r\n    .catch(e => log.error('Bot', 'finis() catch rejection: %s', e))\r\n    .then(() => done = true)\r\n\r\n  setImmediate(checkForExit)\r\n\r\n  function checkForExit()\r\n  {\r\n    // if (checkNum++ % 100 === 0) {\r\n    log.info('Bot', 'finis() checkForExit() checking done: %s', done)\r\n    // }\r\n    if (done)\r\n    {\r\n      log.info('Bot', 'finis() checkForExit() done!')\r\n      setTimeout(() => doExit(code), 1000)  // delay 1 second\r\n      return\r\n    }\r\n    setTimeout(checkForExit, 100)\r\n  }\r\n})\r\nasync function doExit(code: number): Promise<void>\r\n{\r\n  log.info('Bot', 'doExit(%d)', code)\r\n  if (killChrome)\r\n  {\r\n    killChrome('SIGINT')\r\n  }\r\n  process.exit(code)\r\n}\r\n\r\n/* bot event listener */\r\nBOT\r\n  .on('ready', async () =>\r\n  {\r\n    try\r\n    {\r\n      console.log(`bot1 is ready`)\r\n    }\r\n    catch (e)\r\n    {\r\n      log.error('Bot', 'ready event exception: %s', e.stack)\r\n    }\r\n  })\r\n\r\n  .on('logout', async user =>\r\n  {\r\n    log.info('Bot', `${user.name()} logouted`)\r\n    await sleep(10000)\r\n    BOT.reset()\r\n  })\r\n\r\n  .on('login', async user =>\r\n  {\r\n    try\r\n    {\r\n      manager = BOT.Contact.load(\"a38372624\")\r\n\r\n      log.info('Bot', `${user.name()} login`)\r\n\r\n      if(manager)\r\n        await manager.say(`Bot login ${get_now()}`)\r\n\r\n      if (alive_interval_no)\r\n        clearInterval(alive_interval_no)\r\n\r\n      alive_interval_no = setInterval(async () => \r\n      {\r\n        try \r\n        {\r\n          if (!BOT.logonoff())\r\n            await BOT.reset()\r\n        }\r\n        catch (error) \r\n        {\r\n          log.error(`Bot`, `Bot is dead in the syncing interval`)\r\n          if (!BOT.logonoff())\r\n            await doExit(-2)\r\n        }\r\n      }, 5400000);\r\n    }\r\n    catch (e)\r\n    {\r\n      log.error('Bot', 'login event exception: %s', e.stack)\r\n    }\r\n  })\r\n\r\n  .on('scan', async (qrcode, status, data) =>\r\n  {\r\n    generate(qrcode, { small: true })\r\n    if (data)\r\n    {\r\n      console.log(data)\r\n    }\r\n\r\n    if (!status)\r\n    {\r\n      const url: string = qrcodeValueToImageUrl(qrcode)\r\n      console.log(qrcode)\r\n      console.log(url)\r\n      console.log('^^^ Online QR Code Image URL ^^^ ')\r\n      console.log(`[${status}] ${qrcode} Scan QR Code above url to log in: `)\r\n    }\r\n    else if (status == 201)\r\n    {\r\n      console.log(\"201 scaned, wait for confirm\")\r\n    }\r\n    else if (status == 200)\r\n    {\r\n      console.log(\"200 login confirmed\")\r\n    }\r\n    else if (status == 408)\r\n    {\r\n      console.log(`status: ${status} wait for scan`)\r\n    }\r\n    else\r\n    {\r\n      console.log(`status: ${status}`)\r\n    }\r\n  })\r\n\r\n  /**\r\n * Global Event: room-join\r\n */\r\n  .on('room-join', async function (ROOM, INVITEE_LIST, INVITER)\r\n  {\r\n    try\r\n    {\r\n      const ROOM_TOPIC = await ROOM.topic()\r\n      const INVITEE_NAME_LIST = INVITEE_LIST.map(c => c.name()).join(',')\r\n      const INVITER_NAME = INVITER.name()\r\n\r\n      log.info('Bot', 'EVENT: room-join - Room \"%s\" got new member \"%s\", invited by \"%s\"',\r\n        ROOM_TOPIC,\r\n        INVITEE_NAME_LIST,\r\n        INVITER_NAME,\r\n      )\r\n    }\r\n    catch (e)\r\n    {\r\n      log.error('Bot', 'room-join event exception: %s', e.stack)\r\n    }\r\n  })\r\n\r\n  .on('friendship', async friendship =>\r\n  {\r\n    let logMsg\r\n    try\r\n    {\r\n      switch (friendship.type())\r\n      {\r\n        // 1. New Friend Request\r\n        case Friendship.Type.Receive:\r\n          logMsg = `received \\`friendship\\` event from ${friendship.contact().name()} with ${friendship.hello()}`\r\n          await sleep(getRandomIntInclusive(10000, 30000))\r\n          await friendship.accept()\r\n          break\r\n\r\n        // 2. Friend Ship Confirmed\r\n        case Friendship.Type.Confirm:\r\n          logMsg = 'friend ship confirmed with ' + friendship.contact().name()\r\n          await sleep(getRandomIntInclusive(5000, 15000))\r\n          await friendship.contact().say(`Hi, I'm Ponyo 1`)\r\n          await sleep(10000)\r\n          await friendship.contact().sync()\r\n          break\r\n      }\r\n      log.verbose('Bot', logMsg)\r\n    }\r\n    catch (e)\r\n    {\r\n      log.error('Bot', 'friendship event exception: %s', e.stack)\r\n    }\r\n\r\n  })\r\n\r\n  .on('message', async (msg:Message) =>\r\n  {\r\n    try\r\n    {\r\n      // await BOT.ready()\r\n      const CONTACT: Contact | null = await msg.from()\r\n      const ORIGINAL_CONTENT: string = msg.text()\r\n      const ROOM: Room | null = msg.room()\r\n      if (msg.self() ||\r\n        !CONTACT ||\r\n        AVOID_ID_LIST.indexOf(CONTACT.id) != -1 ||\r\n        CONTACT.type() == BOT.Contact.Type.Official||\r\n        ROOM)\r\n        return\r\n      if (ORIGINAL_CONTENT == 'putInRoom')\r\n        put_in_room(CONTACT,roomID_NAME)\r\n    }\r\n    catch (e)\r\n    {\r\n      log.error('Bot', 'Message event exception: %s', e.stack)\r\n    }\r\n  })\r\n\r\n  .on('error', async e =>\r\n  {\r\n    try\r\n    {\r\n      log.error('Bot', 'error: %s', e)\r\n    }\r\n    catch (e)\r\n    {\r\n      log.error('Bot', 'error event exception: %s', e.stack)\r\n    }\r\n  })\r\n\r\n  .on('room-leave', async (ROOM: Room, LEAVER_LIST: Contact[]) =>\r\n  {\r\n    try\r\n    {\r\n      const LEAVER_NAME_LIST = LEAVER_LIST.map(c => c.name()).join(',')\r\n      console.log(`Room ${ROOM.topic()} lost member ${LEAVER_NAME_LIST}`)\r\n    }\r\n    catch (e)\r\n    {\r\n      log.error('Bot', 'room-leave event exception: %s', e.stack)\r\n    }\r\n  })\r\n\r\nBOT.start()\r\n  .then(async () =>\r\n  {\r\n    const LISTENER_LIST = process.listeners('SIGINT')\r\n    for (const LISTENER of LISTENER_LIST)\r\n    {\r\n      if (LISTENER.name === 'killChrome')\r\n      {\r\n        process.removeListener('SIGINT', LISTENER)\r\n        killChrome = LISTENER\r\n      }\r\n    }\r\n  })\r\n  .catch(async e =>\r\n  {\r\n    log.error('Bot', 'start() fail: %s', e)\r\n    await BOT.stop()\r\n    process.exit(-1)\r\n  })\r\n  \r\n\r\n/* all functions*/\r\nasync function put_in_room(contact: Contact, id_or_name: string)\r\n{\r\n  try\r\n  {\r\n    const CONTACT_ALIAS = await contact.alias()\r\n    const IS_BLOCK_CONTACT = (CONTACT_ALIAS && /^BLK-/i.test(CONTACT_ALIAS)) ?\r\n                             true :\r\n                             false\r\n    if (IS_BLOCK_CONTACT)\r\n      return `Sorry, there is some issue that I can not let you in ${id_or_name}`\r\n\r\n    let keyroom: Room | null\r\n    if (/.*@chatroom/i.test(id_or_name))\r\n      keyroom = BOT.Room.load(id_or_name)\r\n    else\r\n      keyroom = await BOT.Room.find(id_or_name)\r\n    const CONTACT_NAME = contact.name()\r\n    await sleep(getRandomIntInclusive(1000, 10000))\r\n\r\n    if (keyroom)\r\n    {\r\n      await keyroom.ready()\r\n      const ROOM_NAME = await keyroom.topic()\r\n      const ROOM_SIZE = await keyroom.memberAll().then((e: any[]) =>\r\n      {\r\n        return e.length\r\n      }).catch(() =>\r\n      {\r\n        return 0\r\n      })\r\n      log.info('Bot', 'putInRoom(%s, %s)', CONTACT_NAME, ROOM_NAME)\r\n      if (ROOM_SIZE >= 500)\r\n        return `${ROOM_NAME} is super full`\r\n      const HAS = await keyroom.has(contact)\r\n      if (HAS)\r\n        return `You have in the ${ROOM_NAME}, thanks`\r\n\r\n      await keyroom.add(contact)\r\n        .catch(e =>\r\n        {\r\n          log.error('Bot', 'room.add() exception: %s', e.stack)\r\n        })\r\n      const ANNOUNCE = await keyroom.announce().catch(e =>\r\n      {\r\n        log.error('Bot', 'room.announce() exception: %s', e.stack)\r\n        return null\r\n      })\r\n      if (ANNOUNCE)\r\n        return `please Follow ${ROOM_NAME} rules:\\n${ANNOUNCE}`\r\n      return `Please follow ${ROOM_NAME} announce rules`\r\n    }\r\n    else\r\n      await contact.say(`Ponyo error,can not find ${id_or_name} room`)\r\n  }\r\n  catch (e)\r\n  {\r\n    log.error('Bot', 'putInRoom() exception: %s', e.stack)\r\n  }\r\n  return \"\"\r\n}\r\n\r\nfunction sleep(ms: number)\r\n{\r\n  return new Promise<void>(function (resolve)\r\n  {\r\n    setTimeout(resolve, ms);\r\n  });\r\n}\r\n\r\nfunction getRandomIntInclusive(min: number, max: number)\r\n{\r\n  min = Math.ceil(min)\r\n  max = Math.floor(max)\r\n  return Math.floor(Math.random() * (max - min + 1)) + min\r\n  //The maximum is inclusive and the minimum is inclusive \r\n}\r\n\r\nfunction get_now()\r\n{\r\n  let clock: Date = new Date()\r\n  const now: string = clock.toLocaleString('en-US', {\r\n    hour12: false,\r\n    year: \"numeric\", day: \"2-digit\", month: \"2-digit\",\r\n    minute: \"2-digit\", second: \"2-digit\", hour: \"2-digit\"\r\n  })\r\n  return now\r\n}\r\n```\r\n\r\nAnswer:\r\n\r\n### 4. Full Output Logs\r\n\r\n<details>\r\n<summary>\r\nShow Logs\r\n</summary>\r\n\r\n```shell\r\n$ docker create -t -i --name=wechaty_ponyo \\\r\n    --mount type=bind,source=\"$(pwd)\",target=/bot \\\r\n    -e WECHATY_LOG=\"silly\" \\\r\n    -e BROLOG_LEVEL=\"silly\" \\\r\n    -e TZ=\"America/Los_Angeles\" \\\r\n    zixia/wechaty:latest ponyo_1.ts;\r\n    docker start -a wechaty_ponyo\r\n\r\nQuestion: Paste your FULL(DO NOT ONLY PROVIDE FRAGMENTS) log messages\r\nAnswer:\r\nPonyo_1.ts(329,31): error TS2554: Expected 1 arguments, but got 0.\r\n\r\n    at createTSError (/wechaty/node_modules/ts-node/src/index.ts:261:12)\r\n    at getOutput (/wechaty/node_modules/ts-node/src/index.ts:367:40)\r\n    at Object.compile (/wechaty/node_modules/ts-node/src/index.ts:558:11)\r\n    at Module.m._compile (/wechaty/node_modules/ts-node/src/index.ts:439:43)\r\n    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)\r\n    at Object.require.extensions.(anonymous function) [as .ts] (/wechaty/node_modules/ts-node/src/index.ts:442:12)\r\n    at Module.load (internal/modules/cjs/loader.js:599:32)\r\n    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)\r\n    at Function.Module._load (internal/modules/cjs/loader.js:530:3)\r\n    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)\r\nERROR: Bot exited with code 1\r\n  ____  _   _  ____   ____  _____ ____   ___  ____ _____\r\n | __ )| | | |/ ___| |  _ \\| ____|  _ \\ / _ \\|  _ \\_   _|\r\n |  _ \\| | | | |  _  | |_) |  _| | |_) | | | | |_) || |\r\n | |_) | |_| | |_| | |  _ <| |___|  __/| |_| |  _ < | |\r\n |____/ \\___/ \\____| |_| \\_\\_____|_|    \\___/|_| \\_\\|_|\r\n\r\n```\r\n</details>\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Chatie/wechaty/issues/comments/417372814","html_url":"https://github.com/Chatie/wechaty/issues/1573#issuecomment-417372814","issue_url":"https://api.github.com/repos/Chatie/wechaty/issues/1573","id":417372814,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzM3MjgxNA==","user":{"login":"kis87988","id":25014776,"node_id":"MDQ6VXNlcjI1MDE0Nzc2","avatar_url":"https://avatars2.githubusercontent.com/u/25014776?v=4","gravatar_id":"","url":"https://api.github.com/users/kis87988","html_url":"https://github.com/kis87988","followers_url":"https://api.github.com/users/kis87988/followers","following_url":"https://api.github.com/users/kis87988/following{/other_user}","gists_url":"https://api.github.com/users/kis87988/gists{/gist_id}","starred_url":"https://api.github.com/users/kis87988/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kis87988/subscriptions","organizations_url":"https://api.github.com/users/kis87988/orgs","repos_url":"https://api.github.com/users/kis87988/repos","events_url":"https://api.github.com/users/kis87988/events{/privacy}","received_events_url":"https://api.github.com/users/kis87988/received_events","type":"User","site_admin":false},"created_at":"2018-08-30T16:01:33Z","updated_at":"2018-08-30T16:01:33Z","author_association":"CONTRIBUTOR","body":"Sure, I should do that."}}
{"actor":{"display_login":"kis87988"}}