feat: persist settings and enrich conversation context

This commit is contained in:
jjbrunton committed 2026-08-08 18:18:28 +01:00
1 parent a36723a325
commit 2c100d72b6
84 files changed
+2248 -644

No files matched your search

+9 -1
View File
@@ -242,11 +242,13 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
);
const isChatSub = subredditEntry?.type === 'chat';
const postImageUrl = isChatSub ? null : redditApi.getImageUrl(post);
const postUrl = redditApi.getPostUrl(post);
postsRepo.insert({
id: post.id,
subreddit: post.subreddit,
author: post.author,
title: post.title,
postUrl,
imageUrl: postImageUrl,
processedAt: Date.now(),
});
@@ -309,7 +311,11 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
logger.info(`Sending message to u/${post.author}...`);
webServer?.pushLog('info', `Sending message to u/${post.author}...`);
const chat = await chatService.startConversation(post.author, processed.generatedMessage);
const chat = await chatService.startConversation(
post.author,
processed.generatedMessage,
post.author_fullname,
);
const success = chat !== null;
if (success) {
@@ -327,6 +333,7 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
message: processed.generatedMessage,
sentAt: Date.now(),
strategyId: processed.strategyId,
chatRoomId: chat.roomId,
});
const currentCount = currentHourlySendCount(rateLimiter);
@@ -338,6 +345,7 @@ export async function runMainLoop(app: AppContainer): Promise<void> {
`Sent message to u/${post.author} (r/${post.subreddit})`,
post.author,
postImageUrl ?? undefined,
{ postTitle: post.title, postUrl },
);
webServer?.pushLog('info', `✅ Message sent to u/${post.author} (${currentCount}/${config.rateLimit.maxMessagesPerHour} this hour)`);
webServer?.updateStats(currentCount);