How to use the wechaty.Wechaty function in wechaty

To help you get started, we’ve selected a few wechaty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wechaty / wechaty / tests / fixtures / smoke-testing.ts View on Github external
function getBotList (): Wechaty[] {
  const botList = [
    new Wechaty({ puppet: 'wechaty-puppet-mock' }),
    new Wechaty({ puppet: 'wechaty-puppet-wechat4u' }),
    // new Wechaty({ puppet: 'wechaty-puppet-puppeteer' }),
  ]

  if (!isPR) {
    botList.push(
      new Wechaty({
        puppet: 'wechaty-puppet-padplus',
        // we use WECHATY_PUPPET_PADPLUS_TOKEN environment variable at here.
      })
    )
  }

  return botList
}
github wechaty / wechaty / tests / fixtures / smoke-testing.ts View on Github external
function getBotList (): Wechaty[] {
  const botList = [
    new Wechaty({ puppet: 'wechaty-puppet-mock' }),
    new Wechaty({ puppet: 'wechaty-puppet-wechat4u' }),
    // new Wechaty({ puppet: 'wechaty-puppet-puppeteer' }),
  ]

  if (!isPR) {
    botList.push(
      new Wechaty({
        puppet: 'wechaty-puppet-padplus',
        // we use WECHATY_PUPPET_PADPLUS_TOKEN environment variable at here.
      })
    )
  }

  return botList
}
github wechaty / wechaty-getting-started / examples / simplest-bot / bot.js View on Github external
const { Wechaty, Room } = require('wechaty')
const qrTerm            = require('qrcode-terminal')

const bot = new Wechaty()

bot.on('scan', (qrcode, status) => {
  qrTerm.generate(qrcode, { small: true })  // show qrcode on console

  const qrcodeImageUrl = [
    'https://api.qrserver.com/v1/create-qr-code/?data=',
    encodeURIComponent(qrcode),
    '&size=220x220&margin=20',
  ].join('')

  console.log(qrcodeImageUrl)
})

bot.on('login', user => {
  console.log(`${user} login`)
})
github Papeone / wechatrobot / routes / robots.js View on Github external
//     });
        //     return;
        // }
        if (Data.getWechatyStatus(userKey)) {
            res.send({
                success: false,
                msg: "用户已登录"
            });
            return;
        }
        let wechatyCache = Data.getWechaty(userKey);
        if (wechatyCache) {
            console.log(`wechatyCache.options.name============================${wechatyCache.options.name}`);
            wechatyCache.stop();
        }
        const wechaty = new Wechaty({
            name: userKey
        });
        Data.pushWechaty(userKey, wechaty);
        wechaty.on('scan', (qrcode, status) => {
            Scan.onScan(userKey, qrcode, status, (url) => {
                try {
                    res.send({
                        success: true,
                        msg: "请扫描二维码登录",
                        data: {
                            url: url
                        }
                    })
                } catch (e) {

                }
github wechaty / wechaty-getting-started / examples / advanced / media-file-bot.js View on Github external
Message,
} = require('wechaty')

const welcome = `
=============== Powered by Wechaty ===============
-------- https://github.com/chatie/wechaty --------

I'm a bot, I can save file to local for you!
__________________________________________________

Please wait... I'm trying to login in...

`
console.log(welcome)

const bot = new Wechaty()

bot.on('scan',    onScan)
bot.on('login',   onLogin)
bot.on('logout',  onLogout)
bot.on('message', onMessage)
bot.on('error',   onError)

bot.start()
.catch(console.error)

function onScan (qrcode, status) {
  qrTerm.generate(qrcode, { small: true })  // show qrcode on console
}

function onLogin (user) {
  console.log(`${user} login`)
github wechaty / docker-wechaty-getting-started / tests / fixtures / javascript.js View on Github external
import { Wechaty } from 'wechaty'
const bot = new Wechaty()
bot.on('scan', qrcode => {
  console.log(qrcode)
  console.log('SMOKE TESTING PASSED')
  process.exit(0)
})
bot.start()

setTimeout(() => process.exit(1), 60 * 1000)
github wechaty / wechaty-getting-started / examples / basic / demo-in-tutorial.js View on Github external
const qrTerm = require('qrcode-terminal')

const { 
  Wechaty, 
  Room 
} = require('wechaty')

const bot = new Wechaty()

bot.on('scan',    function (qrcode, status) {
  qrTerm.generate(qrcode, { small: true })
})

bot.on('login',   function (user) {
  console.log(`${user} login`)
})

bot.on('logout',  function (user) {
  console.log(`${user} logout`)
})

bot.on('friendship', async function (friendship) {
  console.log(`get FRIENDSHIP event!`)
github wechaty / docker-wechaty-getting-started / src / javascript-vanilla.js View on Github external
*   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
const {
  Wechaty,
}             = require('wechaty')

const qrTerm  = require('qrcode-terminal')

/**
 *
 * 1. Declare your Bot!
 *
 */
const bot = new Wechaty({
  name : 'javascript-es6',
})

/**
 *
 * 2. Register event handlers for Bot
 *
 */
bot
.on('login',  onLogin)
.on('scan',   onScan)
.on('error',  onError)
.on('message', onMessage)

/**
 *
github wechaty / wechaty-getting-started / examples / starter-bot.ts View on Github external
log.info('StarterBot', '%s(%s) - %s', ScanStatus[status], status, qrcodeImageUrl)
}

function onLogin (user: Contact) {
  log.info('StarterBot', '%s login', user)
}

function onLogout (user: Contact) {
  log.info('StarterBot', '%s logout', user)
}

async function onMessage (msg: Message) {
  log.info('StarterBot', msg.toString())
}

const bot = new Wechaty({ name: 'wechaty' })

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

bot.start()
  .then(() => log.info('StarterBot', 'Starter Bot Started.'))
  .catch(e => log.error('StarterBot', e))
github wechaty / docker-wechaty-getting-started / src / javascript-es6.js View on Github external
*   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
import {
  Wechaty,
}           from 'wechaty'

import qrTerm from 'qrcode-terminal'

/**
 *
 * 1. Declare your Bot!
 *
 */
const bot = new Wechaty({
  name : 'javascript-es6',
})

/**
 *
 * 2. Register event handlers for Bot
 *
 */
bot
.on('login',  onLogin)
.on('scan',   onScan)
.on('error',  onError)
.on('message', onMessage)

/**
 *