绕过登录限制,wechaty免费版web协议实现微信机器人

惊喜!!!放在前面

在我发布文章这一天,下午打开wechaty博客的时候发现

重磅:绕过登录限制,wechaty免费版web协议重新荣光
这篇文章,可以完美实现无需token即可实现微信登录

效果及代码
你的微信会在桌面微信登录,完美绕过不可以web登录微信的痛点,也可以正常使用你的其他功能

const { Wechaty } = require("wechaty");
const Qrterminal = require("qrcode-terminal");

const name = "wechat-puppet-wechat";
let bot = "";
bot = new Wechaty({
  name, // generate xxxx.memory-card.json and save login data for the next login
});

//  二维码生成
function onScan(qrcode, status) {
  Qrterminal.generate(qrcode); // 在console端显示二维码
  const qrcodeImageUrl = [
    "https://wechaty.js.org/qrcode/",
    encodeURIComponent(qrcode),
  ].join("");
  console.log(qrcodeImageUrl);
}

// 登录
async function onLogin(user) {
  console.log(`贴心小助理${user}登录了`);
  if (config.AUTOREPLY) {
    console.log(`已开启机器人自动聊天模式`);
  }
}

//登出
function onLogout(user) {
  console.log(`小助手${user} 已经登出`);
}

bot.on("scan", onScan);
bot.on("login", onLogin);
bot.on("logout", onLogout);
bot.on("message", function(message){
    console.log(message);
}) // 消息监听
bot
  .start()
  .then(() => console.log("开始登陆微信"))
  .catch((e) => console.error(e));

微信图片_20210414142032.png

愿以往所学皆有所获
原文地址:https://www.cnblogs.com/Azune/p/14657767.html