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

Method sendText

src/core.js:417–451  ·  view source on GitHub ↗
(msg, to)

Source from the content-addressed store, hash-verified

415 }
416
417 sendText (msg, to) {
418 return Promise.resolve().then(() => {
419 let params = {
420 'pass_ticket': this.PROP.passTicket,
421 'lang': 'zh_CN'
422 }
423 let clientMsgId = getClientMsgId()
424 let data = {
425 'BaseRequest': this.getBaseRequest(),
426 'Scene': 0,
427 'Msg': {
428 'Type': this.CONF.MSGTYPE_TEXT,
429 'Content': msg,
430 'FromUserName': this.user['UserName'],
431 'ToUserName': to,
432 'LocalID': clientMsgId,
433 'ClientMsgId': clientMsgId
434 }
435 }
436 return this.request({
437 method: 'POST',
438 url: this.CONF.API_webwxsendmsg,
439 params: params,
440 data: data
441 }).then(res => {
442 let data = res.data
443 assert.equal(data.BaseResponse.Ret, 0, res)
444 return data
445 })
446 }).catch(err => {
447 debug(err)
448 err.tips = '发送文本信息失败'
449 throw err
450 })
451 }
452
453 sendEmoticon (id, to) {
454 return Promise.resolve().then(() => {

Callers 1

sendMsgMethod · 0.80

Calls 2

getBaseRequestMethod · 0.95
getClientMsgIdFunction · 0.90

Tested by

no test coverage detected