I found a KM macro on the Internet, which copies the two-factor code to the clipboard.
https://tyler.io/a-better-way-to-copy-two-factor-codes-on-macos/
This also works very reliably for me under macOS Big Sur and macOS Monterey.
03)2FA <091D 220308T094346>.kmmacros (43,9 KB)
Click to show image
However, I have an advertiser who puts a dot directly after the number code - 765452. - because the number code is the end of a sentence.
Could someone please help me with which input you have to add to the following script to get this dot removed.
sqlite3 "$HOME/Library/Messages/chat.db" "select text from message order by date desc limit 1" | perl -lpe "s/.* (\d+) .*/\1/g"