Modify published message, extract 'if' content to main()

It is now possible to run:
>>> from samples import twistedclient
>>> twistedclient.main()