Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
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
}
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`)
})
// });
// 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) {
}
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`)
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)
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!`)
* 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)
/**
*
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))
* 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)
/**
*