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

#40 all files passed tsc compile

上级 2c245792
......@@ -43,7 +43,7 @@ bot
.on('logout' , user => log.info('Bot', `${user.name()} logouted`))
.on('error' , e => log.info('Bot', 'error: %s', e))
.on('scan', (url, code) => {
if (!/201|200/.test(code)) {
if (!/201|200/.test(String(code))) {
let loginUrl = url.replace(/\/qrcode\//, '/l/')
require('qrcode-terminal').generate(loginUrl)
}
......
......@@ -45,7 +45,7 @@ bot
.on('logout' , user => log.info('Bot', `${user.name()} logouted`))
.on('error' , e => log.info('Bot', 'error: %s', e))
.on('scan', (url, code) => {
if (!/201|200/.test(code)) {
if (!/201|200/.test(String(code))) {
let loginUrl = url.replace(/\/qrcode\//, '/l/')
require('qrcode-terminal').generate(loginUrl)
}
......
......@@ -50,7 +50,7 @@ Loading...
bot
.on('login' , user => log.info('Bot', `bot login: ${user}`))
.on('logout' , e => log.info('Bot', 'bot logout.'))
.on('scan', ({url, code}) => {
.on('scan', (url, code) => {
console.log(`Scan QR Code in url to login: ${code}\n${url}`)
})
.on('message', async m => {
......
......@@ -143,11 +143,20 @@ type ScanInfo = {
code: number
}
type RecommendInfo = {
UserName: string
NickName: string
Content: string // request message
Ticket: string // a pass token
VerifyFlag: number
}
export default Config
export {
Config
, HeadType
, PuppetType
, RecommendInfo
, ScanInfo
, WatchdogFood
, WechatyEventName
......
......@@ -6,7 +6,11 @@
* https://github.com/wechaty/wechaty
*
*/
import Config from './config'
import {
Config
, RecommendInfo
} from './config'
import Contact from './contact'
import Room from './room'
import UtilLib from './util-lib'
......@@ -21,6 +25,8 @@ type MessageRawObj = {
Status: string
MMDigest: string
MMDisplayTime: string // Javascript timestamp of milliseconds
RecommendInfo?: RecommendInfo
}
type MessageObj = {
......@@ -73,7 +79,7 @@ class Message {
throw Error('abstract method')
}
constructor(private rawObj?: MessageRawObj) {
constructor(public rawObj?: MessageRawObj) {
Message.counter++
if (typeof rawObj === 'string') {
......
......@@ -60,14 +60,15 @@ test('Firer.checkRoomJoin', t => {
let result
contentList.forEach(([content, inviter, inviteeList]) => {
result = Firer.checkRoomJoin(content)
result = Firer.checkRoomJoin(content as string)
t.truthy(result, 'should check room join message right for ' + content)
t.deepEqual(result[0], inviteeList, 'should get inviteeList right')
t.is(result[1], inviter, 'should get inviter right')
})
result = Firer.checkRoomJoin('fsadfsadfsdfsdfs')
t.false(result, 'should get false if message is not expected')
t.throws(() => {
Firer.checkRoomJoin('fsadfsadfsdfsdfs')
}, 'should throws if message is not expected')
})
test('Firer.checkRoomLeave', t => {
......@@ -81,8 +82,9 @@ test('Firer.checkRoomLeave', t => {
t.truthy(leaver, 'should get leaver for leave message')
t.is(leaver, data[1], 'should get leaver name right')
leaver = Firer.checkRoomLeave('fafdsfsdfafa')
t.false(leaver, 'should get false if message is not expected')
t.throws(() => {
Firer.checkRoomLeave('fafdsfsdfafa')
}, 'should throw if message is not expected')
})
test('Firer.checkRoomTopic', t => {
......
......@@ -20,6 +20,10 @@
/* tslint:disable:no-var-requires */
const retryPromise = require('retry-promise').default
import {
// RecommendInfo
} from '../config'
import Contact from '../contact'
import Message from '../message'
import log from '../brolog-env'
......@@ -53,7 +57,7 @@ const regexConfig = {
, roomTopic: /^"?(.+?)"? changed the group name to "(.+)"$/
}
async function fireFriendRequest(m) {
async function fireFriendRequest(m: Message) {
const info = m.rawObj.RecommendInfo
log.verbose('PuppetWebFirer', 'fireFriendRequest(%s)', info)
......
......@@ -3,10 +3,12 @@ import { test } from 'ava'
import Config from '../config'
import Contact from '../contact'
import Message from '../message'
import Puppet from '../puppet'
import PuppetWebFriendRequest from './friend-request'
Config.puppetInstance({})
Config.puppetInstance({
userId: 'xxx'
} as Puppet)
test('PuppetWebFriendRequest.receive smoking test', t => {
/* tslint:disable:max-line-length */
......
......@@ -19,18 +19,13 @@
/* tslint:disable:no-var-requires */
const retryPromise = require('retry-promise').default
import Contact from '../contact'
import Config from '../config'
import FriendRequest from '../friend-request'
import log from '../brolog-env'
type RecommendInfo = {
UserName: string
NickName: string
Content: string // request message
Ticket: string // a pass token
VerifyFlag: number
}
import Contact from '../contact'
import {
Config
, RecommendInfo
} from '../config'
import FriendRequest from '../friend-request'
import log from '../brolog-env'
class PuppetWebFriendRequest extends FriendRequest {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册