more config part 4

This commit is contained in:
Christopher Hase 2025-03-31 11:06:14 +02:00
parent db846c890e
commit fa246b2fa8
3 changed files with 33 additions and 8 deletions

17
README.md Normal file
View file

@ -0,0 +1,17 @@
# I-Ching
The I-Ching (a.k.a. the *Book of Changes*) is an ancient method of divination based on
cleromancy (assigning meaning to the generation of apparently random numbers.) Six numbers
between 6 and 9 are generated in order to create a hexagram, the meaning of which is
contained in the I Ching book.
You can find lots of great information on the 2000+ year history of the I-Ching on
[Wikipedia](https://en.wikipedia.org/wiki/I_Ching)
This app will send an I-Ching horoscope to the pre-configured mailhog instance in configurable intervalls.
This app uses the I-Ching library app https://github.com/Velfi/i-ching.git.
## Configuration
It is possible to configure the intervall of days between the sending of horoscopes and the time of sending.

View file

@ -6,6 +6,8 @@ interface Config {
daysInterval: number; daysInterval: number;
timeOfDay: string; timeOfDay: string;
emailReceiver: string; emailReceiver: string;
mailHost: string;
mailPort: number;
} }
// Node structure for the Parse Tree (it's a degenerated tree with one or zero children per node) // Node structure for the Parse Tree (it's a degenerated tree with one or zero children per node)
@ -19,13 +21,6 @@ var config : Config;
const nodemailer = require('nodemailer'); const nodemailer = require('nodemailer');
// Create Transporter
const transporter = nodemailer.createTransport({
host: "mailhog.mailhog.svc.cluster.local", // MailHog ClusterIP
port: 1025, // Standard-MailHog SMTP-Port
secure: false // MailHog needs no encryption
});
function executeCommand(): void { function executeCommand(): void {
exec('iching divine', (error, stdout, stderr) => { exec('iching divine', (error, stdout, stderr) => {
@ -73,6 +68,17 @@ function loadConfig(): Config {
// Send E-Mail // Send E-Mail
async function sendEmail(content: string) { async function sendEmail(content: string) {
// Create Transporter
const transporter = nodemailer.createTransport({
//host: "mailhog.mailhog.svc.cluster.local", // MailHog ClusterIP
host: config.mailHost,
//port: 1025, // Standard-MailHog SMTP-Port
port: config.mailPort,
secure: false // MailHog needs no encryption
});
try { try {
const info = await transporter.sendMail({ const info = await transporter.sendMail({
from: '"The Oracle" <the.oracle@holy.mountain>', from: '"The Oracle" <the.oracle@holy.mountain>',

View file

@ -1,5 +1,7 @@
{ {
"daysInterval": 2, "daysInterval": 2,
"timeOfDay": "8:00", "timeOfDay": "8:00",
"emailReceiver": "test@mailhog.local" "emailReceiver": "test@mailhog.local",
"mailHost": "mailhog.mailhog.svc.cluster.local",
"mailPort": 1025
} }