Skip to content

Commit

Permalink
修复群发问题,增加定时群发
Browse files Browse the repository at this point in the history
  • Loading branch information
huanz committed Mar 11, 2018
1 parent f306720 commit f641231
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ API.preview_appmsg('Zaker-yhz', 100000126).then(res => {
* 群发消息
* @param {string} appMsgId
* @param {number} groupid - 分组id,默认-1 所有用户
* @param {number} send_time - 定时群发,默认-0 不定时群发 定时群发设置定时时间戳(单位秒)
*/
API.masssend(appMsgId).then(() => {
console.log('success');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "wechat-mp-hack",
"version": "1.1.1",
"version": "1.1.2",
"description": "微信公众号接口,无需微信认证实现自动创建素材、自动群发图文消息",
"main": "dist/index.js",
"scripts": {
"start": "babel-node ./run.js",
"prepublish": "babel src -d dist"
"prepublish": "babel src -d dist --copy-files"
},
"keywords": [
"wechat",
Expand Down
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,14 @@ export default class Wechat extends events {
* 群发消息
* @param {string} appMsgId
* @param {number} groupid - 分组id,默认-1 所有用户
* @param {number} send_time - 定时群发,默认-0 不定时群发 定时群发设置定时时间戳(单位秒)
*/
@login
masssend(appmsgid, groupid = -1) {
masssend(appmsgid, groupid = -1, send_time = 0) {
let params = {
appmsgid: appmsgid,
groupid: groupid
groupid: groupid,
send_time: send_time
};
if (this.data.mass_protect) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -641,14 +643,16 @@ export default class Wechat extends events {
}
safesend(obj) {
return WechatRequest({
url: `${Config.api.masssend}?t=ajax-response&token=${this.data.token}&req_need_vidsn=1&add_tx_video=1`,
url: `${Config.api.masssend}?t=ajax-response&token=${this.data.token}${obj.send_time ? `&action=time_send${obj.send_time}` : ''}`,
form: {
token: this.data.token,
f: 'json',
ajax: 1,
random: Math.random(),
smart_product: 0,
type: 10,
appmsgid: obj.appmsgid,
send_time: obj.send_time,
cardlimit: 1,
sex: 0,
groupid: obj.groupid,
Expand Down
37 changes: 31 additions & 6 deletions src/util/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,44 @@ const ERROR_MAP = {
'65101': '图文模版数量已达到上限,请删除后再操作',
'64560': '请勿插入历史图文消息页链接',
'64561': '请勿插入mp.weixin.qq.com域名下的非图文消息链接',
'64562': '请勿插入非mp.weixin.qq.com域名的链接'
'64562': '请勿插入非mp.weixin.qq.com域名的链接',
'67016': '视频还在审核中,若审核失败则将无法播放',
'67015': '视频已被下架或删除,无法播放,请重新选择',
'67012': '设置失败,定时时间与已有互选广告订单时间冲突',
'67013': '设置失败,定时时间超过卡券有效期',
'200013': '操作太频繁,请稍后再试',
'67014': '该时刻定时消息过多,请选择其他时刻',
'67011': '设置的定时群发时间错误,请重新选择',
'64004': '今天的群发数量已到,无法群发或剩余定时群发数量不足',
'67008': '消息中可能含有具备安全风险的链接,请检查',
'200008': '请输入验证码',
'14002': '没有“审核通过”的门店。确认有至少一个“审核通过”的门店后可进行卡券投放。',
'200001': '文章包含的语音已被删除,请重新添加。',
'14003': '投放用户缺少测试权限,请先设置白名单',
'67010': '本月发表付费文章已达10篇'
};

const msg = (code) => {
return ERROR_MAP[code] || '系统繁忙,请稍后重试';
};

const userMsg = (e) => {
if (typeof e === 'object' && typeof e.base_resp === 'object') {
e.base_resp.msg = msg(e.base_resp.ret);
}
return e;
}

const Log = {
info(e) {
console.log(`\x1b[34m${JSON.stringify(e)}\x1b[0m`);
console.log(`\x1b[34m${JSON.stringify(userMsg(e))}\x1b[0m`);
},
error(e) {
console.error(`\x1b[31m${JSON.stringify(e)}\x1b[0m`);
console.error(`\x1b[31m${JSON.stringify(userMsg(e))}\x1b[0m`);
},
msg(code) {
return ERROR_MAP[code] || '系统繁忙,请稍后重试';
}
msg
};



export default Log;

0 comments on commit f641231

Please sign in to comment.