-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fc9996
commit 56923c5
Showing
11 changed files
with
109 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,34 @@ | ||
# push-all-in-one | ||
|
||
本项目的目标是支持 Server酱、酷推、Bark App、Telegram Bot、钉钉机器人、企业微信机器人、企业微信应用和自定义推送等多种推送方式,目前还在开发中。 | ||
本项目的目标是支持 Server酱、酷推、Bark App、Telegram Bot、钉钉机器人、企业微信机器人、企业微信应用和自定义推送等多种推送方式,目前还在开发中。 | ||
|
||
## 安装 | ||
|
||
```sh | ||
npm i push-all-in-one -S | ||
``` | ||
|
||
## 使用 | ||
|
||
```ts | ||
import { ServerChanTurbo, CoolPush, Dingtalk, Text } from 'push-all-in-one' | ||
|
||
const SCTKEY = 'SCTxxxxxxxxxxxxxxxxxxx' | ||
const serverChanTurbo = new ServerChanTurbo(SCTKEY) | ||
serverChanTurbo.send('你好', '你好,我很可爱') | ||
|
||
const SKEY = '022bxxxxxxxxxxxxxxxxxx' | ||
const coolPush = new CoolPush(SKEY) | ||
coolPush.send('你好,我很可爱') | ||
|
||
const dingtalk = new Dingtalk({ | ||
accessToken: 'xxxxxxxxxxxxxx', | ||
secret: 'SECxxxxxxxxxxxxxxxx', | ||
}) | ||
const text = new Text('我就是我, @1825718XXXX 是不一样的烟火') | ||
text.atPhone('1825718XXXX') | ||
dingtalk.send(text) | ||
// Dingtalk 相关更多请参考 https://github.com/CaoMeiYouRen/ts-dingtalk-robot | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export const __PROD__ = process.env.NODE_ENV === 'production' | ||
export const __DEV__ = process.env.NODE_ENV === 'development' | ||
export const __DEV__ = process.env.NODE_ENV === 'development' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export * from './push/dingtalk' | ||
export * from './push/dingtalk/index' | ||
export * from './push/cool-push' | ||
// export * from './push/email' | ||
export * from './push/server-chan' | ||
export * from './push/server-chan-turbo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
interface Send { | ||
send(...args: any[]): Promise<any> | ||
} | ||
export { Send } | ||
export { Send } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Send } from '../interfaces/send' | ||
import { ajax } from '@/utils/ajax' | ||
import { AxiosResponse } from 'axios' | ||
import debug from 'debug' | ||
|
||
const Debugger = debug('push:cool-push') | ||
|
||
/** | ||
* 推送类型,见 [Cool Push](https://cp.xuthus.cc/)。 | ||
* 暂不支持 一对多推送/指定特定的qq号或者群/企业微信消息推送/钉钉群消息/邮箱消息推送 | ||
*/ | ||
type PushType = 'send' | 'group' | 'psend' | 'pgroup' | 'wx' | 'tg' | ||
|
||
/** | ||
* Cool Push QQ消息推送服务。使用说明见 [Cool Push](https://cp.xuthus.cc/) | ||
* | ||
* @author CaoMeiYouRen | ||
* @date 2021-02-27 | ||
* @export | ||
* @class CoolPush | ||
*/ | ||
export class CoolPush implements Send { | ||
/** | ||
* 请前往 https://cp.xuthus.cc/ 领取 | ||
* | ||
* @private | ||
*/ | ||
private SKEY: string | ||
/** | ||
* | ||
* @author CaoMeiYouRen | ||
* @date 2021-02-27 | ||
* @param SKEY 请前往 https://cp.xuthus.cc/ 领取 | ||
*/ | ||
constructor(SKEY: string) { | ||
this.SKEY = SKEY | ||
Debugger('set SKEY: "%s"', SKEY) | ||
if (!this.SKEY) { | ||
throw new Error('SKEY is required!') | ||
} | ||
} | ||
/** | ||
* | ||
* | ||
* @author CaoMeiYouRen | ||
* @date 2021-02-27 | ||
* @param content 要发送的内容 | ||
* @param [type='send'] 推送类型 | ||
* @returns | ||
*/ | ||
send(content: string, type: PushType = 'send'): Promise<AxiosResponse<any>> { | ||
return ajax({ | ||
url: `https://push.xuthus.cc/${type}/${this.SKEY}`, | ||
query: { | ||
c: content, | ||
}, | ||
method: 'POST', | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters