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

name attachment with more detail filename, and add APPMSGTYPE_READER_TYPE 100001 #114

上级 8f52fe45
......@@ -6,6 +6,8 @@
* https://github.com/zixia/wechaty
*
*/
import * as moment from 'moment'
import {
Config,
log,
......@@ -63,7 +65,9 @@ export class MediaMessage extends Message {
// had set in Message
// url = this.rawObj.MMAppMsgDownloadUrl
break
case AppMsgType.URL:
case AppMsgType.READER_TYPE:
if (!this.rawObj.Url) {
throw new Error('no Url')
}
......@@ -71,6 +75,7 @@ export class MediaMessage extends Message {
// url = this.rawObj.Url
break
default:
const e = new Error('ready() unsupported typeApp(): ' + this.typeApp())
log.warn('MediaMessage', e.message)
......@@ -140,7 +145,14 @@ export class MediaMessage extends Message {
throw new Error('no rawObj')
}
let filename = this.rawObj.FileName || this.rawObj.MediaId || this.rawObj.MsgId
const objFileName = this.rawObj.FileName || this.rawObj.MediaId || this.rawObj.MsgId
let filename = moment().format('YYYY-MM-DD HH:mm:ss')
+ ' #' + this._counter
+ ' ' + this.getSenderString()
+ ' ' + objFileName
filename = filename.replace(/ /g, '_')
const re = /\.[a-z0-9]{1,7}$/i
if (!re.test(filename)) {
......
......@@ -184,7 +184,7 @@ export const enum MsgType {
export class Message implements Sayable {
public static counter = 0
private _counter: number
public _counter: number
public static TYPE: MsgTypeMap = {
TEXT: 1,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册