MCPcopy
hub / github.com/nodeWechat/wechat4u / sendDoc

Method sendDoc

src/core.js:709–745  ·  view source on GitHub ↗
(mediaId, name, size, ext, to)

Source from the content-addressed store, hash-verified

707 }
708
709 sendDoc (mediaId, name, size, ext, to) {
710 return Promise.resolve().then(() => {
711 let params = {
712 'pass_ticket': this.PROP.passTicket,
713 'fun': 'async',
714 'f': 'json',
715 'lang': 'zh_CN'
716 }
717 let clientMsgId = getClientMsgId()
718 let data = {
719 'BaseRequest': this.getBaseRequest(),
720 'Scene': 0,
721 'Msg': {
722 'Type': this.CONF.APPMSGTYPE_ATTACH,
723 'Content': `<appmsg appid='wxeb7ec651dd0aefa9' sdkver=''><title>${name}</title><des></des><action></action><type>6</type><content></content><url></url><lowurl></lowurl><appattach><totallen>${size}</totallen><attachid>${mediaId}</attachid><fileext>${ext}</fileext></appattach><extinfo></extinfo></appmsg>`,
724 'FromUserName': this.user.UserName,
725 'ToUserName': to,
726 'LocalID': clientMsgId,
727 'ClientMsgId': clientMsgId
728 }
729 }
730 return this.request({
731 method: 'POST',
732 url: this.CONF.API_webwxsendappmsg,
733 params: params,
734 data: data
735 }).then(res => {
736 let data = res.data
737 assert.equal(data.BaseResponse.Ret, 0, res)
738 return data
739 })
740 }).catch(err => {
741 debug(err)
742 err.tips = '发送文件失败'
743 throw err
744 })
745 }
746
747 forwardMsg (msg, to) {
748 return Promise.resolve().then(() => {

Callers 1

sendMsgMethod · 0.80

Calls 2

getBaseRequestMethod · 0.95
getClientMsgIdFunction · 0.90

Tested by

no test coverage detected