Messages Handling

master
sloppyjosh 2024-02-27 01:39:51 -05:00
parent 2a4b73ff14
commit bcce59cf9f
7 changed files with 98 additions and 17 deletions

View File

@ -1,4 +1,4 @@
import { DatabaseService } from './database'; import { DatabaseService } from './Database';
/** /**
* Manages and executes database maintenance tasks such as purging old comments. * Manages and executes database maintenance tasks such as purging old comments.

View File

@ -5,8 +5,8 @@ import WorkflowOrchestrator from './workflows/WorkflowOrchestrator';
import SessionManager from './rdrama/session/SessionManager'; import SessionManager from './rdrama/session/SessionManager';
import { CommentParser } from './rdrama/services/CommentParser'; import { CommentParser } from './rdrama/services/CommentParser';
import { DatabaseInitializer } from './db/initializeDatabase'; import { DatabaseInitializer } from './db/initializeDatabase';
import { DatabaseService } from './db/services/database'; import { DatabaseService } from './db/services/Database';
import { DatabaseMaintenanceService } from './db/services/databaseMaintenance'; import { DatabaseMaintenanceService } from './db/services/DatabaseMaintenance';
import { CommentProcessor } from './rdrama/services/CommentProcessor'; import { CommentProcessor } from './rdrama/services/CommentProcessor';
// Import other necessary services or configurations // Import other necessary services or configurations

View File

@ -0,0 +1,13 @@
Hi {rdramaUsername},
This is an automated message to address a recent comment you made mentioning a Reddit user. Our platform values respect and privacy for individuals across the internet. As part of our community standards, we urge you to consider the impact of publicly mentioning users from other platforms without their consent.
Please be aware that we have notified the mentioned Reddit user about this instance. However, we strongly encourage you to reflect on this behavior and strive for positive interactions moving forward. Publicly mentioning users can lead to unwanted attention and discomfort, which contradicts our community's standards.
Let's work together to maintain a respectful and welcoming environment for all users. Please consider this message a friendly reminder to uphold these values in your future posts and comments.
Thank you for your understanding and cooperation.
Best,
[Your Bot Name] - Automated Message (Unmonitored Account)
---END---

View File

@ -0,0 +1,18 @@
Hello {username},
We hope this message finds you well. We're reaching out to inform you that there has been a mention of your Reddit username in a discussion on a different platform. This notification is part of our commitment to online privacy and community care.
The mention was made in the context of a post or comment on rDrama. While we understand this might be of interest to you, we also recognize the importance of privacy and discretion. As such, we're not providing a direct link to the discussion to prevent any unintended traffic or attention.
If you wish to view the mention, please note that some effort is required on your part to access it. The information needed to locate the discussion is as follows:
- Platform: rDrama
- Partial URL: rdrama[dot]net/post/{postId}
- Mention context (optional placeholder if you have specific context information): {mentionContext}
Please replace "[dot]" with "." to form the actual URL and consider your privacy and well-being before deciding to visit the site.
We understand if this news is unwelcome or concerning. If you have any questions or need support regarding this matter, please don't hesitate to reach out to us.
Take care,
[Your Platform Name or Team]

View File

@ -1,5 +1,5 @@
import { Comment } from '../models/Comment'; import { Comment } from '../models/Comment';
import { DatabaseService } from '../../db/services/database'; import { DatabaseService } from '../../db/services/Database';
import { CommentFetcher } from './CommentFetcher'; import { CommentFetcher } from './CommentFetcher';
/** /**

View File

@ -0,0 +1,44 @@
import fs from 'fs';
import path from 'path';
export class MessageService {
private redditMessages: string[] = [];
private rdramaMessages: string[] = [];
constructor() {
this.loadMessages();
}
private loadMessages() {
try {
const redditMessagesPath = path.join(__dirname, 'messages', 'reddit_messages.txt');
this.redditMessages = fs.readFileSync(redditMessagesPath, 'utf-8').split('---END---').filter(line => line.trim());
} catch (error) {
console.error('Failed to load Reddit messages:', error);
}
try {
const rdramaMessagesPath = path.join(__dirname, 'messages', 'rdrama_messages.txt');
this.rdramaMessages = fs.readFileSync(rdramaMessagesPath, 'utf-8').split('---END---').filter(line => line.trim());
} catch (error) {
console.error('Failed to load rDrama messages:', error);
}
}
public getRandomRedditMessage(placeholders: { [key: string]: string }): string {
const message = this.redditMessages[Math.floor(Math.random() * this.redditMessages.length)];
return this.replacePlaceholders(message, placeholders);
}
public getRandomRdramaMessage(placeholders: { [key: string]: string }): string {
const message = this.rdramaMessages[Math.floor(Math.random() * this.rdramaMessages.length)];
return this.replacePlaceholders(message, placeholders);
}
private replacePlaceholders(message: string, placeholders: { [key: string]: string }): string {
return Object.keys(placeholders).reduce((acc, key) => {
const regex = new RegExp(`{${key}}`, 'g');
return acc.replace(regex, placeholders[key]);
}, message);
}
}

View File

@ -1,14 +1,20 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2022", "target": "ES2022",
"module": "commonjs", "module": "commonjs",
"lib": ["es2022"], "lib": [
"outDir": "./dist", "es2022"
"rootDir": "./src", ],
"strict": true, "outDir": "./dist",
"esModuleInterop": true, "rootDir": "./src",
"types": ["node"], "strict": true,
"moduleResolution": "node" "esModuleInterop": true,
}, "types": [
"include": ["src/**/*"] "node"
} ],
"moduleResolution": "node"
},
"include": [
"src/**/*"
]
}