mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 02:57:34 +00:00
@@ -66,6 +66,8 @@ PROXY_ADDRESS=""
|
||||
PROXY_PROTOCOL=""
|
||||
PROXY_PORT=""
|
||||
PUSHBULLET=""
|
||||
PUSHOVER_EXPIRE=""
|
||||
PUSHOVER_RETRY=""
|
||||
PUSHOVER_TOKEN=""
|
||||
PUSHOVER_USER=""
|
||||
PUSHOVER_PRIORITY=""
|
||||
|
||||
@@ -87,6 +87,8 @@ Generate required keys using [instructions](https://developers.meethue.com/devel
|
||||
|
||||
For cloud only usage, instructions to generate are located [here](https://developers.meethue.com/develop/hue-api/remote-authentication/).
|
||||
|
||||
> :point_right: Here's a [video demonstration](https://vimeo.com/476083242).
|
||||
|
||||
| Environment variable | Description |
|
||||
|:---:|---|
|
||||
| `PHILIPS_HUE_API_KEY` | Hue Bridge API Key |
|
||||
@@ -99,15 +101,13 @@ For cloud only usage, instructions to generate are located [here](https://develo
|
||||
| `PHILIPS_HUE_CLOUD_CLIENT_ID` | Cloud Client ID. Cloud only |
|
||||
| `PHILIPS_HUE_CLOUD_CLIENT_SECRET` | Cloud Client Secret. Cloud only |
|
||||
|
||||
> :point_right: Here's a [video demonstration](https://vimeo.com/476083242).
|
||||
|
||||
## Pushbullet
|
||||
|
||||
Generate token at https://www.pushbullet.com/#settings/account.
|
||||
|
||||
| Environment variable | Description |
|
||||
|:---:|---|
|
||||
| `PUSHBULLET` | PushBullet API key |
|
||||
| `PUSHBULLET` | API key |
|
||||
|
||||
## Pushover
|
||||
|
||||
@@ -115,23 +115,28 @@ Generate token at https://pushover.net/apps/build.
|
||||
|
||||
| Environment variable | Description |
|
||||
|:---:|---|
|
||||
| `PUSHOVER_TOKEN` | Pushover access token |
|
||||
| `PUSHOVER_USER` | Pushover username |
|
||||
| `PUSHOVER_PRIORITY` | Pushover message priority |
|
||||
| `PUSHOVER_EXPIRE` | How many seconds your notification will continue to be retried for (every `PUSHOVER_RETRY` seconds) |
|
||||
| `PUSHOVER_RETRY` | How often (in seconds) the Pushover servers will send the same notification to the user |
|
||||
| `PUSHOVER_PRIORITY` | Message priority |
|
||||
| `PUSHOVER_TOKEN` | API token |
|
||||
| `PUSHOVER_USER` | Username |
|
||||
|
||||
???+ note
|
||||
`PUSHOVER_EXPIRE` and `PUSHOVER_RETRY` are only used when `PUSHOVER_PRIORITY="2"`
|
||||
|
||||
## Slack
|
||||
|
||||
| Environment variable | Description |
|
||||
|:---:|---|
|
||||
| `SLACK_CHANNEL` | Slack channel for posting |
|
||||
| `SLACK_TOKEN` | Slack API token |
|
||||
| `SLACK_CHANNEL` | Channel for posting |
|
||||
| `SLACK_TOKEN` | API token |
|
||||
|
||||
## Telegram
|
||||
|
||||
| Environment variable | Description |
|
||||
|:---:|---|
|
||||
| `TELEGRAM_ACCESS_TOKEN` | Telegram access token |
|
||||
| `TELEGRAM_CHAT_ID` | Telegram chat ID. Can be comma separated, e.g.: `123456789,987654321` |
|
||||
| `TELEGRAM_ACCESS_TOKEN` | Access token |
|
||||
| `TELEGRAM_CHAT_ID` | Chat ID. Can be comma separated, e.g.: `123456789,987654321` |
|
||||
|
||||
## Twilio
|
||||
|
||||
@@ -139,9 +144,9 @@ Token generation can be found at https://twilio.com/console.
|
||||
|
||||
| Environment variable | Description |
|
||||
|:---:|---|
|
||||
| `TWILIO_ACCOUNT_SID` | Twilio Account SID |
|
||||
| `TWILIO_AUTH_TOKEN` | Twilio Auth Token |
|
||||
| `TWILIO_FROM_NUMBER` | Twilio provided phone number to send messages from |
|
||||
| `TWILIO_ACCOUNT_SID` | Account SID |
|
||||
| `TWILIO_AUTH_TOKEN` | Auth Token |
|
||||
| `TWILIO_FROM_NUMBER` | Provided phone number to send messages from |
|
||||
| `TWILIO_TO_NUMBER` | Mobile number to send SMS to |
|
||||
|
||||
???+ note
|
||||
|
||||
@@ -241,7 +241,9 @@ const notifications = {
|
||||
playSound: envOrString(process.env.PLAY_SOUND),
|
||||
pushbullet: envOrString(process.env.PUSHBULLET),
|
||||
pushover: {
|
||||
expire: envOrNumber(process.env.PUSHOVER_EXPIRE),
|
||||
priority: envOrNumber(process.env.PUSHOVER_PRIORITY),
|
||||
retry: envOrNumber(process.env.PUSHOVER_RETRY),
|
||||
token: envOrString(process.env.PUSHOVER_TOKEN),
|
||||
username: envOrString(process.env.PUSHOVER_USER)
|
||||
},
|
||||
|
||||
@@ -4,20 +4,30 @@ import Push, {PushoverMessage} from 'pushover-notifications';
|
||||
import {config} from '../config';
|
||||
|
||||
const pushover = config.notifications.pushover;
|
||||
const push = new Push({
|
||||
token: pushover.token,
|
||||
user: pushover.username
|
||||
});
|
||||
|
||||
export function sendPushoverNotification(link: Link, store: Store) {
|
||||
if (pushover.token && pushover.username) {
|
||||
logger.debug('↗ sending pushover message');
|
||||
|
||||
const message: PushoverMessage = {
|
||||
message: link.cartUrl ? link.cartUrl : link.url,
|
||||
priority: pushover.priority,
|
||||
title: Print.inStock(link, store)
|
||||
};
|
||||
const push = new Push({
|
||||
token: pushover.token,
|
||||
user: pushover.username
|
||||
});
|
||||
|
||||
const message: PushoverMessage =
|
||||
pushover.priority < 2
|
||||
? {
|
||||
message: link.cartUrl ? link.cartUrl : link.url,
|
||||
priority: pushover.priority,
|
||||
title: Print.inStock(link, store)
|
||||
}
|
||||
: {
|
||||
expire: pushover.expire,
|
||||
message: link.cartUrl ? link.cartUrl : link.url,
|
||||
priority: pushover.priority,
|
||||
retry: pushover.retry,
|
||||
title: Print.inStock(link, store)
|
||||
};
|
||||
|
||||
push.send(message, (error: Error) => {
|
||||
if (error) {
|
||||
|
||||
+7
-5
@@ -37,15 +37,17 @@ declare module 'pushover-notifications' {
|
||||
}
|
||||
|
||||
export interface PushoverMessage {
|
||||
message: string;
|
||||
file?: string | {name: string; data: string};
|
||||
device?: string;
|
||||
expire?: number;
|
||||
file?: string | {name: string; data: string};
|
||||
message: string;
|
||||
priority?: number;
|
||||
retry?: number;
|
||||
sound?: Sound;
|
||||
timestamp?: number;
|
||||
title?: string;
|
||||
url?: string;
|
||||
url_title?: string;
|
||||
priority?: number;
|
||||
sound?: Sound;
|
||||
timestamp?: number;
|
||||
}
|
||||
|
||||
export class Pushover {
|
||||
|
||||
Reference in New Issue
Block a user