The original

Make a convertible bond reminder with wechat robot

Technology selection

node wechaty

The target

If there are convertible bonds available for purchase, it will be automatically sent in the group to remind

The implementation process

  1. Climb the collection thought record
  2. useWechat robotTimed message sending

Because its implementation is relatively simple, I will directly post the code

(async() = > {try {
      const url =
        "Http://dcfm.eastmoney.com/em_mutisvcexpandinterface/api/js/get?type=KZZ_LB2.0&token=70f12f2f4f091e459a279469fe49eca5&cm d=&st=STARTDATE&sr=-1&p=1&ps=50&js=var%20xYKcDtXG={pages:(tp),data:(x),font:(font)}&rt=52772118";
      const sres = await superagent.get(url);
      eval(sres.text);
      letStrObj = {debentable today:""
      };
      xYKcDtXG.data.forEach(item= > {
        if (
          moment(item.STARTDATE).format("YYYY-MM-DD") ===
          moment().format("YYYY-MM-DD")
        ) {
          strObj["Debentable today"] + =`,${item.SNAME}`;
        } else if (moment(item.STARTDATE).isAfter(moment())) {
          if(! strObj[moment(item.STARTDATE).format("MM-DD")]) {
            strObj[moment(item.STARTDATE).format("MM-DD")] = "";
          }
          strObj[moment(item.STARTDATE).format("MM-DD"+ =)]`,${item.SNAME}`; }});if(! strObj["Debentable today"]) {
        return;
      }
      let ret = "";
      Object.entries(strObj)
        .sort((a, b) = > moment(a[0]) - moment(b[0]))
        .map(([k, v], i) = > {
          ret +=
            i === 0 ? `${k}\r\n${v.slice(1)}\r\n` : `\r\n${k}\r\n${v.slice(1)}`;
        });
      // Wechaty sends group messages
      const contact = await bot.Room.find({ topic: 'Call for Convertible Bonds' });
      await contact.say(ret)

    } catch (err) {
      console.log("sres", err);
    }
})()
Copy the code

The DEMO presentation

Finally, welcome to join the convertible bond purchase group haha

Post AD 8 for Wechaty

Wechaty is a good way to run your own robot with 6 lines of code

Use up, extremely its square!