feat: persist settings and enrich conversation context
This commit is contained in:
1 parent
a36723a325
commit
2c100d72b6
84 files changed
+2248
-644
No files matched your search
+9
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user