wechaty-fanli

0.1.18 • Public • Published

wechaty-fanli 插件

Powered by Wechaty

基于wechaty实现的返利微信机器人,根据淘口令生成高佣转链接,并创建新的淘口令。 本项目实现功能:

  • 淘宝优惠券查询

参考项目

根据henryfanyiyewechat-fanli-robot 项目改造而成,本项目属于wechaty插件,可以直接配置使用,无需关心源码。只要申请好自己的淘宝联盟账号淘口令 的账号即可,具体步骤可参见wechat-fanli-robot 项目说明

实现微信机器人

机器人是基于 wechaty 来实现,官方文档已经有了非常的详细的教程,所以这里不做赘述。 由于微信 web 协议现在已经废除,所以需要采用iPad协议,wechaty 的 iPad 协议启动是需要 token 的,token 是需要申请的,点击申请 token

使用步骤

安装插件和wechaty

npm install wechaty wechaty-fanli wechaty-puppet-wechat --save

主要代码

index.js

const {Wechaty} = require('wechaty')
//const {PuppetPadlocal} = require('wechaty-puppet-padlocal')
const Qrterminal = require('qrcode-terminal')
const WechatyFanliPlugin = require('wechaty-fanli')
// const token = '申请的ipadlocal token'
const name = 'wechat-fanli'
// const puppet = new PuppetPadlocal({
//    token,
//})
const bot = new Wechaty({
    name, // generate xxxx.memory-card.json and save login data for the next login
    //puppet,
    puppet: 'wechaty-puppet-wechat',
})



async function onLogin(user) {
    console.log(`返利小助手${user}登录了`)
}

async function onLogout(user) {
    console.log(`返利小助手${user}已登出`)
}

/**
 * 扫描登录,显示二维码
 */
async function onScan(qrcode, status) {
    Qrterminal.generate(qrcode)
    console.log('扫描状态', status)
    const qrImgUrl = ['https://api.qrserver.com/v1/create-qr-code/?data=', encodeURIComponent(qrcode)].join('')
    console.log(qrImgUrl)
}


bot.on('scan', onScan);
bot.on('login', onLogin);
bot.on('logout', onLogout);

bot
    .use(WechatyFanliPlugin({
        keyword: '?', // 触发关键词 例: ?淘宝粘贴的链接 不填则对所有对话进行返利转化
        apiKey: '', // 淘口令网的apikey
        siteId: '', // 参见https://www.taokouling.com/html/8.html
        adzoneId: "", // 参见https://www.taokouling.com/html/8.html
        uid: '', // 淘口令网-高佣授权信息-淘宝用户id
        appKey: '', // 淘宝联盟 - 媒体备案管理- 媒体中的appkey
        appSecret: 'appSecret' // 淘宝联盟 - 媒体备案管理- 媒体中的appkey - 查看 - appSecret
    }))
    .start()
    .catch((e) => console.error(e))

运行

node index.js

扫码登录,即可

问题

如有使用问题可以直接加小助手,回复返利,进微信群交流

Package Sidebar

Install

npm i wechaty-fanli

Weekly Downloads

0

Version

0.1.18

License

MIT

Unpacked Size

1.28 MB

Total Files

29

Last publish

Collaborators

  • leo_chen