提交 de33a787 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

bug fix

上级 cfe64fe3
......@@ -34,12 +34,16 @@ bot.init()
bot.on('message', (m) => {
m.ready()
.then (msg => log.info ('Bot', 'recv: %s' , msg))
.then (msg => {
log.info ('Bot', 'recv: %s' , msg)
log.info ('Bot', 'weixin from id: %s' , msg.get('from').get('weixin'))
log.info ('Bot', 'weixin to id: %s' , msg.get('to').get('weixin'))
})
.catch(e => log.error('Bot', 'ready: %s' , e))
if (/^ding|ping$/i.test(m.get('content'))) {
if (/^(ding|ping)$/i.test(m.get('content'))) {
const r = new Wechaty.Message()
r.set('to', m.get('from'))
r.set('to', m.inGroup() ? m.get('group') : m.get('from'))
r.set('content', 'dong')
bot.send(r)
.then(() => { log.warn('Bot', 'REPLY: dong') })
......
......@@ -46,7 +46,8 @@ class Message {
return `Message#${Message.counter}(${fromStr}: ${content})`
function html2str(html) {
return html.replace(/(<([^>]+)>)/ig,'')
return html.toString()
.replace(/(<([^>]+)>)/ig,'')
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, '>')
......
......@@ -20,13 +20,14 @@ const Group = require('./group')
class Wechaty extends EventEmitter {
// cookie,Uin, Sid,SKey
constructor(puppet) {
constructor(options) {
super()
puppet = puppet || 'web'
options = options || {}
puppet = options.puppet || 'web'
switch(puppet) {
case 'web':
this.puppet = new Puppet.Web()
this.puppet = new Puppet.Web({port: options.port})
break
default:
throw new Error('Puppet unknown: ' + puppet)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册