I would put it in a class, just in case of more then one TTY or whatever...
If you don't put it in a class, put the stuff you do in init() in create() instead, then it will be called when the module initializes and you will get the expected behaviour.