mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 09:57:38 +00:00
chore: clean up and bump node version
This commit is contained in:
@@ -4,7 +4,7 @@ import {config} from '../config';
|
||||
import {join} from 'path';
|
||||
import notifier from 'node-notifier';
|
||||
|
||||
const desktop = config.notifications.desktop;
|
||||
const {desktop} = config.notifications;
|
||||
|
||||
export function sendDesktopNotification(link: Link, store: Store) {
|
||||
if (desktop) {
|
||||
|
||||
@@ -3,8 +3,7 @@ import Discord from 'discord.js';
|
||||
import {config} from '../config';
|
||||
import {logger} from '../logger';
|
||||
|
||||
const discord = config.notifications.discord;
|
||||
const {notifyGroup, webhooks, notifyGroupSeries} = discord;
|
||||
const {notifyGroup, webhooks, notifyGroupSeries} = config.notifications.discord;
|
||||
|
||||
function getIdAndToken(webhook: string) {
|
||||
const match = /.*\/webhooks\/(\d+)\/(.+)/.exec(webhook);
|
||||
|
||||
@@ -4,7 +4,7 @@ import Mail from 'nodemailer/lib/mailer';
|
||||
import {config} from '../config';
|
||||
import nodemailer from 'nodemailer';
|
||||
|
||||
const email = config.notifications.email;
|
||||
const {email} = config.notifications;
|
||||
|
||||
const transportOptions: any = {};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import MqttClient, {IClientOptions, IClientPublishOptions} from 'mqtt';
|
||||
import {Print, logger} from '../logger';
|
||||
import {config} from '../config';
|
||||
|
||||
const mqtt = config.notifications.mqtt;
|
||||
const {mqtt} = config.notifications;
|
||||
let client: MqttClient.Client;
|
||||
|
||||
if (mqtt.broker) {
|
||||
|
||||
@@ -3,18 +3,19 @@ import {config} from '../config';
|
||||
import {v3 as hueAPI} from 'node-hue-api';
|
||||
import {logger} from '../logger';
|
||||
|
||||
const hue = config.notifications.philips_hue;
|
||||
const apiKey = hue.apiKey;
|
||||
const bridgeIp = hue.bridgeIp;
|
||||
const lightIds = hue.lightIds;
|
||||
const lightColor = hue.lightColor;
|
||||
const lightPattern = hue.lightPattern;
|
||||
const LightState = hueAPI.lightStates.LightState;
|
||||
const clientId = hue.clientId;
|
||||
const clientSecret = hue.clientSecret;
|
||||
const accessToken = hue.accessToken;
|
||||
const refreshToken = hue.refreshToken;
|
||||
const remoteApiUsername = hue.remoteApiUsername;
|
||||
const {LightState} = hueAPI.lightStates;
|
||||
const {
|
||||
apiKey,
|
||||
bridgeIp,
|
||||
lightIds,
|
||||
lightColor,
|
||||
lightPattern,
|
||||
clientId,
|
||||
clientSecret,
|
||||
accessToken,
|
||||
refreshToken,
|
||||
remoteApiUsername
|
||||
} = config.notifications.philips_hue;
|
||||
|
||||
// Default Light State
|
||||
const lightState = new LightState()
|
||||
@@ -81,7 +82,7 @@ const adjustLightsWithAPI = (hueBridge: Api) => {
|
||||
|
||||
export function adjustPhilipsHueLights() {
|
||||
// Check if the required variables have been set
|
||||
if (hue.apiKey && hue.bridgeIp) {
|
||||
if (apiKey && bridgeIp) {
|
||||
logger.info('↗ adjusting Philips Hue lights over LAN');
|
||||
(async () => {
|
||||
logger.debug(
|
||||
@@ -100,7 +101,7 @@ export function adjustPhilipsHueLights() {
|
||||
}
|
||||
);
|
||||
})();
|
||||
} else if (hue.apiKey && hue.clientId && hue.clientSecret) {
|
||||
} else if (apiKey && clientId && clientSecret) {
|
||||
logger.info('↗ adjusting Philips Hue lights over cloud');
|
||||
(async () => {
|
||||
logger.debug(
|
||||
@@ -110,7 +111,7 @@ export function adjustPhilipsHueLights() {
|
||||
clientId,
|
||||
clientSecret
|
||||
);
|
||||
if (hue.accessToken && hue.refreshToken) {
|
||||
if (accessToken && refreshToken) {
|
||||
remoteBootstrap
|
||||
.connectWithTokens(
|
||||
accessToken,
|
||||
|
||||
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
|
||||
import PushBullet from '@jef/pushbullet';
|
||||
import {config} from '../config';
|
||||
|
||||
const pushbullet = config.notifications.pushbullet;
|
||||
const {pushbullet} = config.notifications;
|
||||
|
||||
export function sendPushbulletNotification(link: Link, store: Store) {
|
||||
if (pushbullet) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
|
||||
import Push, {PushoverMessage} from 'pushover-notifications';
|
||||
import {config} from '../config';
|
||||
|
||||
const pushover = config.notifications.pushover;
|
||||
const {pushover} = config.notifications;
|
||||
|
||||
export function sendPushoverNotification(link: Link, store: Store) {
|
||||
if (pushover.token && pushover.username) {
|
||||
|
||||
@@ -3,13 +3,11 @@ import {Print, logger} from '../logger';
|
||||
import {WebClient} from '@slack/web-api';
|
||||
import {config} from '../config';
|
||||
|
||||
const slack = config.notifications.slack;
|
||||
const channel = slack.channel.replace('#', '');
|
||||
const token = slack.token;
|
||||
const {channel, token} = config.notifications.slack;
|
||||
const web = new WebClient(token);
|
||||
|
||||
export function sendSlackMessage(link: Link, store: Store) {
|
||||
if (slack.channel && slack.token) {
|
||||
if (channel && token) {
|
||||
logger.debug('↗ sending slack message');
|
||||
|
||||
(async () => {
|
||||
@@ -17,7 +15,7 @@ export function sendSlackMessage(link: Link, store: Store) {
|
||||
|
||||
try {
|
||||
const result = await web.chat.postMessage({
|
||||
channel,
|
||||
channel: channel.replace('#', ''),
|
||||
text: `${Print.inStock(link, store)}\n${givenUrl}`
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import Mail from 'nodemailer/lib/mailer';
|
||||
import {config} from '../config';
|
||||
import {transporter} from './email';
|
||||
|
||||
const [email, phone] = [config.notifications.email, config.notifications.phone];
|
||||
const {email, phone} = config.notifications;
|
||||
|
||||
if (phone.number.length > 0 && (!email.username || !email.password)) {
|
||||
logger.warn(
|
||||
|
||||
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
|
||||
import {TelegramClient} from 'messaging-api-telegram';
|
||||
import {config} from '../config';
|
||||
|
||||
const telegram = config.notifications.telegram;
|
||||
const {telegram} = config.notifications;
|
||||
|
||||
const client = new TelegramClient({
|
||||
accessToken: telegram.accessToken
|
||||
|
||||
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
|
||||
import {Twilio} from 'twilio';
|
||||
import {config} from '../config';
|
||||
|
||||
const twilio = config.notifications.twilio;
|
||||
const {twilio} = config.notifications;
|
||||
let client: Twilio;
|
||||
|
||||
if (twilio.accountSid && twilio.authToken) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {existsSync, promises, readFileSync} from 'fs';
|
||||
import {ChatClient} from 'twitch-chat-client';
|
||||
import {config} from '../config';
|
||||
|
||||
const twitch = config.notifications.twitch;
|
||||
const {twitch} = config.notifications;
|
||||
|
||||
const messages: string[] = [];
|
||||
let alreadySaying = false;
|
||||
|
||||
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
|
||||
import Twitter from 'twitter';
|
||||
import {config} from '../config';
|
||||
|
||||
const twitter = config.notifications.twitter;
|
||||
const {twitter} = config.notifications;
|
||||
|
||||
const client = new Twitter({
|
||||
access_token_key: twitter.accessTokenKey,
|
||||
|
||||
Reference in New Issue
Block a user