Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. /**
  2. * General commands
  3. *
  4. * Add custom commands here.
  5. */
  6.  
  7. tell: 'say',
  8. say: function(arg, by, room, con) {
  9. if (!this.canUse('say', room, by)) return false;
  10. this.say(con, room, stripCommands(arg) + ' (' + by + ' said this)');
  11. },
  12. joke: function(arg, by, room, con) {
  13. if (!this.canUse('joke', room, by) || room.charAt(0) === ',') return false;
  14. var self = this;
  15.  
  16. var reqOpt = {
  17. hostname: 'api.icndb.com',
  18. path: '/jokes/random',
  19. method: 'GET'
  20. };
  21. var req = http.request(reqOpt, function(res) {
  22. res.on('data', function(chunk) {
  23. try {
  24. var data = JSON.parse(chunk);
  25. self.say(con, room, data.value.joke.replace(/"/g, "\""));
  26. } catch (e) {
  27. self.say(con, room, 'Sorry, couldn\'t fetch a random joke... :(');
  28. }
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement