Code Monkey home page Code Monkey logo

wechaty-fanli's Introduction

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

扫码登录,即可

问题

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

wechaty-fanli's People

Contributors

leochen-g avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.