#!/usr/bin/env python3 """Parse messy, manually copied Discord trading messages into a deduplicated CSV. No Discord API, account automation, or scraping is used. Requires Python 3.10+. Windows PowerShell: Get-Clipboard -Raw | py discord_trade_parser.py py discord_trade_parser.py trades.txt py discord_trade_parser.py pastes --detailed Recognized message boundaries: [\n11:46\n]\nUsername (@handle) [Role],\n:\nTrading ... [11:46]\nUsername\n:\nTrading ... ### 11:33Username (@handle)*:*\nTrading ... Default CSV has the original two columns: offer, looking_for. Use --detailed to additionally export LF / MLF / NLF, hashed authors, repost counts, and update counts. An SQLite database preserves the latest observed listing across multiple processing runs. Process older files first. Reported scam warnings with named accounts go to scammer_warnings.csv. """ from __future__ import annotations import argparse from collections import Counter import csv from dataclasses import dataclass from difflib import SequenceMatcher import glob import hashlib import html import json from pathlib import Path import re import sqlite3 import sys import unicodedata import uuid from typing import Iterable, Iterator TIME = re.compile(r"(?:[01]?\d|2[0-3]):[0-5]\d") BRACKETED_TIME = re.compile(r"\[\s*((?:[01]?\d|2[0-3]):[0-5]\d)\s*\]") INLINE_HEADER = re.compile(r"^(?P