websockets to follow same nodebb modules pattern to avoid circular dependencies

a shy attempt to follow the same pattern, local testing looks okay. Please Ctrl+F "websockets." quickly find the module.exports replacements. 

I hit the same issue as [this]((https://github.com/akhoury/nodebb-plugin-ubbmigrator/issues/2) earlier today, but in websocket.js

Also, it's worth mentioning that I also made couple more cleanups in the file, not worth a separate request, i think; 

* pulled require('gravatar') to the top, again.
* removed a global var, I am assuming mistakenly left in there [websockets.js:225] (https://github.com/designcreateplay/NodeBB/blob/master/src/websockets.js#L225): 
 
```
{... picture: require('gravatar').url('', { s: '24' }, https = nconf.get('https'))  ....}
```
```nconf.get('https')``` is express's req.secure, which returns a boolean, expected as the 3rd arg for ```gravatar.url()```