This is slightly complicated by the fact you can "mention" a discussion in 2 different ways. You can mention a post across discussions using the Mentions extension, or you can post a link.
The first one is likely the easiest to handle, because the Mention extension already establishes relationships between the posts and trigger events.
However for the simple link this requires parsing posts and finding which URLs link to discussions on the same forum, then extracting the discussion ID from that URL.