Refactor the quote buttons function

Nearly forgot to push this up, got out of dream land at 3am…

Anyway, quote buttons function now works on strings – we avoid stupid stuff like dealing with newlines in the middle of it. There's also a pattern in it so we can factor that out as well later, once some more tests are established (I have only manually tested it, and not exhaustively. It is very difficult to test this at the moment as we can't easily replicate jumping between threads (yet))