Skip to content
This repository has been archived by the owner on May 6, 2019. It is now read-only.

Commit

Permalink
Fixing help texts
Browse files Browse the repository at this point in the history
Fixed help texts for !help fun (!animals and !translate)
Renamed test - images.js to animals.js
  • Loading branch information
Gravestorm committed Mar 24, 2016
1 parent 0fabfee commit 00b7ccc
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 36 deletions.
66 changes: 41 additions & 25 deletions i18n/_source.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,30 @@
"text": "Get various animal pictures",
"done": true
},
"animals_cat": {
"text": "Bombs chat with adorable cats",
"done": false
},
"animals_dog": {
"text": "Bombs chat with adorable dogs",
"done": false
},
"animals_header_text": {
"text": "Responds with a picture.\nYou can specify a number of pictures by writing `bomb` `number` after a command. (e.g. `!cat bomb 2`)",
"done": false
},
"animals_pug": {
"text": "Bombs chat with adorable pugs",
"done": false
},
"animals_snake": {
"text": "Bombs chat with adorable snakes",
"done": false
},
"avatar": {
"text": "Responds with your avatar, unless a username is specified",
"done": true
},
"cat": {
"text": "Bombs chat with adorable cats",
"done": true
},
"champgg_setup": {
"text": "Please setup Champion.gg in config.js to use the **`!lol`** command.",
"done": true
Expand Down Expand Up @@ -91,10 +107,6 @@
"text": "Usage: **`!decide`** `something` **`or`** `something...`",
"done": true
},
"dog": {
"text": "Bombs chat with adorable dogs",
"done": true
},
"dota2": {
"text": "DOTA 2",
"done": true
Expand Down Expand Up @@ -183,10 +195,6 @@
"text": "Usage: **`!join`** `invitation link`",
"done": true
},
"leet": {
"text": "1337ifies the sentence",
"done": true
},
"leet_usage": {
"text": "Usage: **`!leet`** `sentence`",
"done": true
Expand Down Expand Up @@ -291,10 +299,6 @@
"text": "Usage: **`!popkey`** `gif tags`",
"done": true
},
"pug": {
"text": "Bombs chat with adorable pugs",
"done": true
},
"quote": {
"text": "Responds with a quote, if no number is written, a random one",
"done": true
Expand Down Expand Up @@ -323,10 +327,6 @@
"text": "Set all help text to respond in a specified language",
"done": true
},
"snoop": {
"text": "Snoopifies tha sentence",
"done": true
},
"snoop_usage": {
"text": "Usage: **`!snoop`** `sentence`",
"done": true
Expand All @@ -335,6 +335,26 @@
"text": "You need to specify a summoner name.",
"done": true
},
"translate": {
"text": "Translate text in funny ways",
"done": false
},
"translate_header_text": {
"text": "Translation commands:",
"done": false
},
"translate_leet": {
"text": "1337ifies the sentence",
"done": false
},
"translate_snoop": {
"text": "Snoopifies tha sentence",
"done": false
},
"translate_yoda": {
"text": "Yodaifies the sentence",
"done": false
},
"uptime": {
"text": "Shows how long the bot has been online",
"done": true
Expand Down Expand Up @@ -383,10 +403,6 @@
"text": "Usage: **`!wolfram`** `query`",
"done": true
},
"yoda": {
"text": "Yodaifies the sentence",
"done": true
},
"yoda_usage": {
"text": "Usage: **`!yoda`** `sentence`",
"done": true
Expand All @@ -407,4 +423,4 @@
"text": "Usage: **`!youtube`** `video tags`",
"done": true
}
}
}
23 changes: 15 additions & 8 deletions src/commands/fun/animals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Promise from 'bluebird';
import _request from 'request';
import R from 'ramda';

import { subCommands as helpText } from '../help';
import sentry from '../../sentry';


Expand Down Expand Up @@ -97,7 +98,13 @@ function snake(bot, msg, suffix) {
});
}

function animals(bot, msg) {
bot.sendMessage(msg.channel, helpText(bot, msg, 'animals'));
}

export default {
animal: animals,
animals,
cat,
cats: cat,
'\ud83d\udc31': cat,
Expand All @@ -114,13 +121,13 @@ export default {
};

export const help = {
cat: {
parameters: ['bomb', 'number']
},
dog: {
parameters: ['bomb', 'number']
},
pug: {
parameters: ['bomb', 'number']
animals: {
header_text: 'animals_header_text',
subcommands: [
{name: 'cat'},
{name: 'dog'},
{name: 'pug'},
{name: 'snake'}
]
}
};
17 changes: 14 additions & 3 deletions src/commands/fun/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import leetify from 'leet';
import _request from 'request';
import R from 'ramda';

import { subCommands as helpText } from '../help';
import sentry from '../../sentry';
import T from '../../translate';

Expand Down Expand Up @@ -57,18 +58,28 @@ function yoda(bot, msg, phrase) {
});
}

function translate(bot, msg) {
bot.sendMessage(msg.channel, helpText(bot, msg, 'translate'));
}

export default {
leet,
leetify: leet,
1337: leet,
snoop,
snoopify: snoop,
translate,
yoda: yoda,
yodaify: yoda
};

export const help = {
leet: {parameters: 'sentence'},
snoopify: {parameters: 'sentence'},
yoda: {parameters: 'sentence'}
translate: {
header_text: 'translate_header_text',
subcommands: [
{name: 'leet'},
{name: 'snoop'},
{name: 'yoda'}
]
}
};
124 changes: 124 additions & 0 deletions tests/fun/animals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import chai from 'chai';
import nock from 'nock';
import path from 'path';

import images from '../../src/commands/fun/animals';


chai.should();
const res_fixture_cat = require(path.join(__dirname, '../fixtures/cat.json'));
const res_fixture_pug = require(path.join(__dirname, '../fixtures/pug.json'));
const res_fixture_snake = require(path.join(__dirname, '../fixtures/snake.json'));
const res_fixture_pugbomb = require(path.join(__dirname, '../fixtures/pugbomb.json'));

describe('images', () => {
describe('cat', () => {
it('should return cat images', done => {
function sendMessage(channel, res) {
channel.should.equal('test');
res.should.equal('http://random.cat/i/7VnxKqw.jpg');
done();
}

nock.cleanAll();
nock('http://random.cat')
.get('/meow.php')
.reply(200, res_fixture_cat);

images.cat({sendMessage}, {channel: 'test'});
});

it('should return 5 cat images', done => {
function sendMessage(channel, res) {
channel.should.equal('test');
res.should.equal(`http://random.cat/i/7VnxKqw.jpg
http://random.cat/i/7VnxKqw.jpg
http://random.cat/i/7VnxKqw.jpg
http://random.cat/i/7VnxKqw.jpg
http://random.cat/i/7VnxKqw.jpg`);
done();
}

nock.cleanAll();
nock('http://random.cat')
.get('/meow.php')
.times(5)
.reply(200, res_fixture_cat);

images.cat({sendMessage}, {channel: 'test'}, 'bomb 5');
});
});

describe('pug', () => {
it('should return pug images', done => {
function sendMessage(channel, res) {
channel.should.equal('test');
res.should.equal(`http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg`);
done();
}

nock.cleanAll();
nock('https://pugme.herokuapp.com')
.get('/bomb?count=1')
.reply(200, res_fixture_pug);

images.pug({sendMessage}, {channel: 'test'});
});

it('should return 5 pug images', done => {
function sendMessage(channel, res) {
channel.should.equal('test');
res.should.equal(`http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg
http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg
http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg
http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg
http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg`);
done();
}

nock.cleanAll();
nock('https://pugme.herokuapp.com')
.get('/bomb?count=5')
.reply(200, res_fixture_pugbomb);

images.pug({sendMessage}, {channel: 'test'}, 'bomb 5');
});
});

describe('snake', () => {
it('should return snake images', done => {
function sendMessage(channel, res) {
channel.should.equal('test');
res.should.equal('http://fur.im/snek/61.png');
done();
}

nock.cleanAll();
nock('http://fur.im/snek')
.get('/snek.php')
.reply(200, res_fixture_snake);

images.snake({sendMessage}, {channel: 'test'});
});

it('should return 5 snake images', done => {
function sendMessage(channel, res) {
channel.should.equal('test');
res.should.equal(`http://fur.im/snek/61.png
http://fur.im/snek/61.png
http://fur.im/snek/61.png
http://fur.im/snek/61.png
http://fur.im/snek/61.png`);
done();
}

nock.cleanAll();
nock('http://fur.im/snek')
.get('/snek.php')
.times(5)
.reply(200, res_fixture_snake);

images.snake({sendMessage}, {channel: 'test'}, 'bomb 5');
});
});
});

0 comments on commit 00b7ccc

Please sign in to comment.