From d708dca108dcbfe3d67dfe90c27de9cdb41184a6 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 7 Dec 2024 00:50:33 +0100 Subject: feat: Add SQLITE database entry logging --- src/main/kotlin/moe/nea/ledger/modules/BankDetection.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/main/kotlin/moe/nea/ledger/modules/BankDetection.kt') diff --git a/src/main/kotlin/moe/nea/ledger/modules/BankDetection.kt b/src/main/kotlin/moe/nea/ledger/modules/BankDetection.kt index 8d0fd81..e9a6c26 100644 --- a/src/main/kotlin/moe/nea/ledger/modules/BankDetection.kt +++ b/src/main/kotlin/moe/nea/ledger/modules/BankDetection.kt @@ -1,8 +1,11 @@ package moe.nea.ledger.modules +import moe.nea.ledger.ItemChange +import moe.nea.ledger.ItemId import moe.nea.ledger.LedgerEntry import moe.nea.ledger.LedgerLogger import moe.nea.ledger.SHORT_NUMBER_PATTERN +import moe.nea.ledger.TransactionType import moe.nea.ledger.events.ChatReceived import moe.nea.ledger.parseShortNumber import moe.nea.ledger.useMatcher @@ -22,18 +25,22 @@ class BankDetection @Inject constructor(val ledger: LedgerLogger) { withdrawPattern.useMatcher(event.message) { ledger.logEntry( LedgerEntry( - "BANK_WITHDRAW", + TransactionType.BANK_WITHDRAW, event.timestamp, - parseShortNumber(group("amount")), + listOf(ItemChange(ItemId.COINS, + parseShortNumber(group("amount")), + ItemChange.ChangeDirection.TRANSFORM)), ) ) } depositPattern.useMatcher(event.message) { ledger.logEntry( LedgerEntry( - "BANK_DEPOSIT", + TransactionType.BANK_DEPOSIT, event.timestamp, - parseShortNumber(group("amount")), + listOf(ItemChange(ItemId.COINS, + parseShortNumber(group("amount")), + ItemChange.ChangeDirection.TRANSFORM)), ) ) } -- cgit