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

Merge branch 'master' of github.com:Chatie/wechaty

......@@ -6,8 +6,8 @@
#
set -e
HOME=/bot
PATH=$PATH:/wechaty/bin:/wechaty/node_modules/.bin
export HOME=/bot
export PATH=$PATH:/wechaty/bin:/wechaty/node_modules/.bin
function wechaty::banner() {
echo
......
......@@ -17,8 +17,6 @@
* limitations under the License.
*
*/
/* tslint:disable:variable-name */
import { generate } from 'qrcode-terminal'
import {
......@@ -74,7 +72,7 @@ bot
.on('logout' , user => log.info('Bot', `${user.name()} logouted`))
.on('error' , e => log.info('Bot', 'error: %s', e))
.on('login', async function(this, user) {
.on('login', async function(user) {
const msg = `${user.name()} logined`
log.info('Bot', msg)
......
{
"name": "wechaty",
"version": "0.17.1",
"version": "0.17.17",
"description": "Wechat for Bot(Personal Account)",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
......@@ -159,7 +159,7 @@
"cookie-parser": "^1.4.0",
"coveralls": "^3.0.0",
"cross-env": "^5.1.6",
"eslint": "^4.8.0",
"eslint": "^5.0.0",
"finis": "^0.4.1",
"fluent-ffmpeg": "^2.1.0",
"git-scripts": "git+https://github.com/nkzawa/git-scripts.git",
......@@ -174,12 +174,12 @@
"sinon": "^6.0.0",
"sinon-test": "^2.2.0",
"sloc": "^0.2.0",
"ts-node": "^6.0.5",
"ts-node": "^7.0.0",
"tslint": "^5.9.1",
"tslint-config-standard": "^7.0.0",
"tuling123-client": "^0.0.2",
"typedoc": "^0.11.1",
"typescript": "^2.9.0-dev.20180509"
"typescript": "^2.9.2"
},
"files_comment__whitelist_npm_publish": "http://stackoverflow.com/a/8617868/1123955",
"files": [
......
......@@ -16,6 +16,8 @@
* limitations under the License.
*
*/
/// <reference path="./typings.d.ts" />
import fs from 'fs'
import os from 'os'
import path from 'path'
......
......@@ -137,7 +137,7 @@ export class IoClient {
})
}
private async onMessage(m: Message) {
private async onMessage(_: Message) {
// const from = m.from()
// const to = m.to()
// const content = m.toString()
......@@ -149,10 +149,10 @@ export class IoClient {
// , m.toStringDigest()
// )
if (/^wechaty|chatie|botie/i.test(m.text()) && !m.self()) {
await m.say('https://www.chatie.io')
.then(_ => log.info('Bot', 'REPLIED to magic word "chatie"'))
}
// if (/^wechaty|chatie|botie/i.test(m.text()) && !m.self()) {
// await m.say('https://www.chatie.io')
// .then(_ => log.info('Bot', 'REPLIED to magic word "chatie"'))
// }
}
public async stop(): Promise<void> {
......
......@@ -138,6 +138,7 @@ export class Io {
this.lifeTimer = setInterval(() => {
if (this.ws && this.connected()) {
log.silly('Io', 'start() setInterval() ws.ping()')
// TODO: check 'pong' event on ws
this.ws.ping()
}
}, 1000 * 10)
......
......@@ -163,6 +163,8 @@ export class PadchatManager extends PadchatRpc {
&& this.cacheRoomMemberRawPayload
&& this.cacheRoomRawPayload
) {
log.silly('PuppetPadchatManager', 'releaseCache() closing caches ...')
await this.cacheContactRawPayload.close(),
await this.cacheRoomMemberRawPayload.close(),
await this.cacheRoomRawPayload.close(),
......@@ -325,6 +327,8 @@ export class PadchatManager extends PadchatRpc {
}
const checkScanInternalLoop = async () => {
log.silly('PuppetPadchatManager', `startCheckScan() checkScanInternalLoop()`)
/**
* While we want to Wait user response
*/
......@@ -418,10 +422,14 @@ export class PadchatManager extends PadchatRpc {
}
checkScanInternalLoop()
.then(() => {
log.silly('PuppetPadchatManager', `startCheckScan() checkScanInternalLoop() resolved`)
})
.catch(e => {
log.warn('PuppetPadchatManager', 'startCheckScan() checkScanLoop() exception: %s', e)
this.emit('reset', 'startCheckScan() checkScanLoop() exception')
})
log.silly('PuppetPadchatManager', `startCheckScan() checkScanInternalLoop() set`)
}
/**
......
......@@ -216,12 +216,13 @@ export class PadchatRpc extends EventEmitter {
this.debounceQueue.next('ws.on(message)')
})
ws.on('pong', data => {
log.silly('PadchatRpc', 'initWebSocket() ws.on(pong)')
if (!this.throttleQueue || !this.debounceQueue) {
log.warn('PadchatRpc', 'initWebSocket() ws.on(pong) throttleQueue or debounceQueue not exist')
return
}
this.throttleQueue.next(data.toString())
this.debounceQueue.next(data.toString())
this.throttleQueue.next('pong: ' + data.toString())
this.debounceQueue.next('pong: ' + data.toString())
})
}
......
......@@ -248,11 +248,21 @@ export class PuppetPadchat extends Puppet {
}
protected async reset(reason: string): Promise<void> {
log.verbose('PuppetPadchat', 'restart(%s)', reason)
log.verbose('PuppetPadchat', 'reset(%s)', reason)
await this.stop()
await this.start()
try {
log.silly('PuppetPadchat', 'reset() before stop')
await this.stop()
log.silly('PuppetPadchat', 'reset() after stop')
await this.start()
log.silly('PuppetPadchat', 'reset() after start')
} catch (e) {
log.error('PuppetPadchat', 'reset() exception: %s', e.message)
this.emit('error', e)
throw e
}
log.silly('PuppetPadchat', 'reset() done')
}
protected async onPadchatMessage(rawPayload: PadchatMessagePayload): Promise<void> {
......@@ -517,15 +527,8 @@ export class PuppetPadchat extends Puppet {
await this.padchatManager.stop()
/**
* MUST use setImmediate at here(the end of this function),
* because we need to run the micro task registered by the `emit` method
*/
setImmediate(() => {
if (this.padchatManager) {
this.padchatManager.removeAllListeners()
}
})
this.padchatManager.removeAllListeners()
this.padchatManager = undefined
this.state.off(true)
this.emit('stop')
......@@ -1069,7 +1072,10 @@ export class PuppetPadchat extends Puppet {
await this.roomPayloadDirty(roomId)
await this.roomMemberPayloadDirty(roomId)
// XXX: Do we need to re-load payload at here?
// Reload room information here
await new Promise(r => setTimeout(r, 1000))
await this.roomPayload(roomId)
await this.roomMemberPayload(roomId, contactId)
}
public async roomTopic(roomId: string) : Promise<string>
......
......@@ -39,7 +39,7 @@ export function contactRawPayloadParser(
* user_name: '' }
*/
// console.log(rawPayload)
throw Error('cannot get user_name for payload: ' + JSON.stringify(rawPayload))
throw Error('cannot get user_name from raw payload: ' + JSON.stringify(rawPayload))
}
if (isRoomId(rawPayload.user_name)) {
......
......@@ -1287,7 +1287,7 @@ export class PuppetPuppeteer extends Puppet {
}
const buffer = await new Promise<Buffer>((resolve, reject) => {
file.pipe(bl((err: Error, data: Buffer) => {
file.pipe(new bl((err: Error, data: Buffer) => {
if (err) reject(err)
else resolve(data)
}))
......
......@@ -16,6 +16,8 @@
* limitations under the License.
*
*/
/// <reference path="./typings.d.ts" />
import { PuppetWechat4u } from './puppet-wechat4u'
export {
......
此差异已折叠。
......@@ -7,9 +7,11 @@
, "traceResolution" : false
, "noLib" : false
, "declaration" : true
, "declarationMap" : true
, "sourceMap" : true
, "skipLibCheck" : true
, "esModuleInterop" : true
, "resolveJsonModule": true
, "emitDecoratorMetadata" : true
, "experimentalDecorators" : true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册