update error logging
cutting all kind of prefixes for prompt making
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import "dotenv/config";
|
||||
import {drizzle, LibSQLDatabase} from "drizzle-orm/libsql";
|
||||
import {Environment} from "../common/environment";
|
||||
import {logError} from "../util/utils";
|
||||
|
||||
export class DatabaseManager {
|
||||
|
||||
@@ -10,7 +11,7 @@ export class DatabaseManager {
|
||||
try {
|
||||
DatabaseManager.db = drizzle(Environment.DB_PATH);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
logError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
import * as fs from "fs";
|
||||
import {Environment} from "../common/environment";
|
||||
import {logError} from "../util/utils";
|
||||
|
||||
|
||||
export let muted: Set<number> = new Set<number>();
|
||||
@@ -57,7 +58,7 @@ export async function readData(): Promise<void> {
|
||||
|
||||
return Promise.resolve();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
logError(e);
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +92,7 @@ export async function retrieveAnswers(): Promise<void> {
|
||||
json.day.forEach(e => dayAnswers.push(e));
|
||||
return Promise.resolve();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
logError(e);
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,8 @@ import {DatabaseManager} from "./database-manager";
|
||||
import {StoredMessage} from "../model/stored-message";
|
||||
import {and, eq} from "drizzle-orm";
|
||||
import {inArray} from "drizzle-orm/sql/expressions/conditions";
|
||||
import {Message} from "typescript-telegram-bot-api";
|
||||
import {Dao} from "../base/dao";
|
||||
import {buildExcludedSet, extractTextMessage} from "../util/utils";
|
||||
import {Environment} from "../common/environment";
|
||||
import {buildExcludedSet} from "../util/utils";
|
||||
|
||||
export class MessageDao extends Dao<StoredMessage> {
|
||||
|
||||
@@ -82,14 +80,14 @@ export class MessageDao extends Dao<StoredMessage> {
|
||||
return true;
|
||||
}
|
||||
|
||||
mapTo(messages: Message[]): MessageInsert[] {
|
||||
mapStoredTo(messages: StoredMessage[]): MessageInsert[] {
|
||||
return messages.map(msg => {
|
||||
return {
|
||||
chatId: msg.chat.id,
|
||||
id: msg.message_id,
|
||||
replyToMessageId: msg.reply_to_message?.message_id,
|
||||
fromId: msg.from.id,
|
||||
text: extractTextMessage(msg, Environment.BOT_PREFIX),
|
||||
chatId: msg.chatId,
|
||||
id: msg.id,
|
||||
replyToMessageId: msg.replyToMessageId,
|
||||
fromId: msg.fromId,
|
||||
text: msg.text,
|
||||
date: msg.date,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user