ctcp: Turn into a generic CTCP function. Add VERSION handler.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit d20bbca0d00cf7a76ea4536a041f7eda388d6a00)