u
This commit is contained in:
		
							parent
							
								
									e5c4ffc89f
								
							
						
					
					
						commit
						31febc9a1a
					
				
							
								
								
									
										24
									
								
								messenger.js
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								messenger.js
									
									
									
									
									
								
							| @ -42,14 +42,14 @@ module.exports = { | ||||
|     appid, // for 'UNICLOUD', 'TENCENT'
 | ||||
|   } = {}) { | ||||
|     if (/^\+\d+-\d+$/.test(phone)) { | ||||
|       if (config.vendor === 'DXTON' && msg) { | ||||
|         return await this.sendSmsDxton(phone, msg, config) | ||||
|       } else if (config.vendor === 'ALIYUN' && msgParam && msgTemplate) { | ||||
|         return await this.sendSmsAliyun(phone, msgParam, msgTemplate, signName, config) | ||||
|       } else if (config.vendor === 'UNICLOUD' && msgParam && msgTemplate) { | ||||
|         return await this.sendSmsUnicloud({ phone, msgParam, msgTemplate, appid, config }) | ||||
|       } else if (config.vendor === 'TENCENT' && msgParam && msgTemplate) { | ||||
|         return await this.sendSmsTencent({ phone, msgParam, msgTemplate, appid, signName, config }) | ||||
|       if (config.vendor === 'DXTON') { | ||||
|         return await this.sendSmsDxton({ phone, config, msg }) | ||||
|       } else if (config.vendor === 'ALIYUN') { | ||||
|         return await this.sendSmsAliyun({ phone, config, msgParam, msgTemplate, signName }) | ||||
|       } else if (config.vendor === 'UNICLOUD') { | ||||
|         return await this.sendSmsUnicloud({ phone, config, msgParam, msgTemplate, appid }) | ||||
|       } else if (config.vendor === 'TENCENT') { | ||||
|         return await this.sendSmsTencent({ phone, config, msgParam, msgTemplate, appid, signName }) | ||||
|       } else { | ||||
|         return { _state: 'SMS_UNKNOWN_VENDOR', error: { unknownVendor: config.vendor } } | ||||
|       } | ||||
| @ -64,7 +64,7 @@ module.exports = { | ||||
|         - 国外: http://sms.106jiekou.com/utf8/worldapi.aspx?account=9999&password=接口密码&mobile=手机号码&content=尊敬的用户您已经注册成功,用户名:{0} 密码:{1} 感谢您的注册!     
 | ||||
|         - response 的 content-type 为 text/html | ||||
|   */ | ||||
|   async sendSmsDxton (phone, msg, config) { | ||||
|   async sendSmsDxton ({ phone, config, msg }) { | ||||
|     var matches = phone.match(/\d+/g) | ||||
|     var smsNumber, smsUrl | ||||
|     if (matches[0] === '86') { | ||||
| @ -97,7 +97,7 @@ module.exports = { | ||||
|     }) | ||||
|   }, | ||||
| 
 | ||||
|   async sendSmsAliyun (phone, msgParam, msgTemplate, signName, config) { | ||||
|   async sendSmsAliyun ({ phone, config, msgParam, msgTemplate, signName }) { | ||||
|     sender.smsClientAliyun = sender.smsClientAliyun || new (require('@alicloud/sms-sdk'))(config) // https://www.npmjs.com/package/@alicloud/sms-sdk
 | ||||
| 
 | ||||
|     const [countryCode, callNumber] = phone.match(/\d+/g) | ||||
| @ -125,7 +125,7 @@ module.exports = { | ||||
|       ) | ||||
|   }, | ||||
| 
 | ||||
|   async sendSmsUnicloud ({ phone, msgTemplate, msgParam, appid, config } = {}) { | ||||
|   async sendSmsUnicloud ({ phone, config, msgTemplate, msgParam, appid } = {}) { | ||||
|     try { | ||||
|       const result = await uniCloud.sendSms({ | ||||
|         appid: appid || config.smsAppid, | ||||
| @ -146,7 +146,7 @@ module.exports = { | ||||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   async sendSmsTencent ({ phone, msgTemplate, msgParam, appid, signName, config } = {}) { | ||||
|   async sendSmsTencent ({ phone, config, msgTemplate, msgParam, appid, signName } = {}) { | ||||
|     sender.smsClientTencent = sender.smsClientTencent || new (require('tencentcloud-sdk-nodejs').sms.v20210111.Client)(config) // https://cloud.tencent.com/document/product/382/43197
 | ||||
| 
 | ||||
|     return await sender.smsClientTencent | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user