mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 07:37:39 +00:00
feat(docs): add mkdocs
This commit is contained in:
@@ -31,7 +31,7 @@ export function sendDiscordMessage(link: Link, store: Store) {
|
||||
'> provided by [streetmerchant](https://github.com/jef/streetmerchant) with :heart:'
|
||||
)
|
||||
.setThumbnail(
|
||||
'https://raw.githubusercontent.com/jef/streetmerchant/main/media/streetmerchant-square.png'
|
||||
'https://raw.githubusercontent.com/jef/streetmerchant/main/docs/assets/images/streetmerchant-square.png'
|
||||
)
|
||||
.setColor('#52b788')
|
||||
.setTimestamp();
|
||||
@@ -57,7 +57,9 @@ export function sendDiscordMessage(link: Link, store: Store) {
|
||||
});
|
||||
}
|
||||
|
||||
(await Promise.all(promises)).forEach(({client}) => client.destroy());
|
||||
(await Promise.all(promises)).forEach(({client}) =>
|
||||
client.destroy()
|
||||
);
|
||||
|
||||
logger.info('✔ discord message sent');
|
||||
} catch (error: unknown) {
|
||||
|
||||
@@ -45,13 +45,14 @@ const adjustLightsWithAPI = (hueBridge: Api) => {
|
||||
const arrayOfIDs = lightIds.split(',');
|
||||
arrayOfIDs.forEach((light) => {
|
||||
logger.debug('adjusting all hue lights');
|
||||
(hueBridge.lights.setLightState(light, lightState) as Promise<any>).catch(
|
||||
(error: Error) => {
|
||||
logger.error('Failed to adjust all lights.');
|
||||
logger.error(error);
|
||||
throw error;
|
||||
}
|
||||
);
|
||||
(hueBridge.lights.setLightState(
|
||||
light,
|
||||
lightState
|
||||
) as Promise<any>).catch((error: Error) => {
|
||||
logger.error('Failed to adjust all lights.');
|
||||
logger.error(error);
|
||||
throw error;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// Adjust all light IDs
|
||||
@@ -102,15 +103,26 @@ export function adjustPhilipsHueLights() {
|
||||
} else if (hue.apiKey && hue.clientId && hue.clientSecret) {
|
||||
logger.info('↗ adjusting Philips Hue lights over cloud');
|
||||
(async () => {
|
||||
logger.debug('Attempting to connect to Philips Hue bridge over cloud');
|
||||
const remoteBootstrap = hueAPI.api.createRemote(clientId, clientSecret);
|
||||
logger.debug(
|
||||
'Attempting to connect to Philips Hue bridge over cloud'
|
||||
);
|
||||
const remoteBootstrap = hueAPI.api.createRemote(
|
||||
clientId,
|
||||
clientSecret
|
||||
);
|
||||
if (hue.accessToken && hue.refreshToken) {
|
||||
remoteBootstrap
|
||||
.connectWithTokens(accessToken, refreshToken, remoteApiUsername)
|
||||
.connectWithTokens(
|
||||
accessToken,
|
||||
refreshToken,
|
||||
remoteApiUsername
|
||||
)
|
||||
.then(
|
||||
(hueBridge) => {
|
||||
adjustLightsWithAPI(hueBridge);
|
||||
logger.info('✔ adjusted Philips Hue lights over cloud');
|
||||
logger.info(
|
||||
'✔ adjusted Philips Hue lights over cloud'
|
||||
);
|
||||
},
|
||||
(error: Error) => {
|
||||
logger.error(
|
||||
|
||||
@@ -4,7 +4,7 @@ import {WebClient} from '@slack/web-api';
|
||||
import {config} from '../config';
|
||||
|
||||
const slack = config.notifications.slack;
|
||||
const channel = slack.channel;
|
||||
const channel = slack.channel.replace('#', '');
|
||||
const token = slack.token;
|
||||
const web = new WebClient(token);
|
||||
|
||||
|
||||
+17
-11
@@ -20,19 +20,25 @@ export function playSound() {
|
||||
if (config.notifications.playSound && player.player !== null) {
|
||||
logger.debug('↗ playing sound');
|
||||
|
||||
fs.access(config.notifications.playSound, fs.constants.F_OK, (error) => {
|
||||
if (error) {
|
||||
logger.error(`✖ error opening sound file: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
player.play(config.notifications.playSound, (error: Error) => {
|
||||
fs.access(
|
||||
config.notifications.playSound,
|
||||
fs.constants.F_OK,
|
||||
(error) => {
|
||||
if (error) {
|
||||
logger.error("✖ couldn't play sound", error);
|
||||
logger.error(
|
||||
`✖ error opening sound file: ${error.message}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info('✔ played sound');
|
||||
});
|
||||
});
|
||||
player.play(config.notifications.playSound, (error: Error) => {
|
||||
if (error) {
|
||||
logger.error("✖ couldn't play sound", error);
|
||||
}
|
||||
|
||||
logger.info('✔ played sound');
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,9 @@ const chatClient: ChatClient = new ChatClient(
|
||||
{
|
||||
accessToken,
|
||||
expiryTimestamp:
|
||||
expiryDate === null ? null : expiryDate.getTime(),
|
||||
expiryDate === null
|
||||
? null
|
||||
: expiryDate.getTime(),
|
||||
refreshToken
|
||||
},
|
||||
null,
|
||||
@@ -90,7 +92,9 @@ export function sendTwitchMessage(link: Link, store: Store) {
|
||||
logger.debug('↗ sending twitch message');
|
||||
|
||||
messages.push(
|
||||
`${Print.inStock(link, store)}\n${link.cartUrl ? link.cartUrl : link.url}`
|
||||
`${Print.inStock(link, store)}\n${
|
||||
link.cartUrl ? link.cartUrl : link.url
|
||||
}`
|
||||
);
|
||||
|
||||
if (!alreadySaying) {
|
||||
|
||||
Reference in New Issue
Block a user