mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 22:39:26 +01:00
Merge remote branch 'upstream/master' into rain
This commit is contained in:
commit
be80b185ed
20
install.sh
20
install.sh
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
cat LICENCE
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
@ -16,8 +16,20 @@ wget http://d3js.org/d3.v3.zip
|
||||
unzip d3.v3.zip
|
||||
rm d3.v3.zip
|
||||
|
||||
cd ..
|
||||
cd ../..
|
||||
|
||||
cp config.json.sample config.json
|
||||
if [ ! -f config.json ];
|
||||
then
|
||||
echo 'Creating configuration file...'
|
||||
cp config.json.sample config.json
|
||||
vim config.json
|
||||
fi
|
||||
|
||||
read -p "Setup complete. Run depressionbot now? [y/N]"
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
echo 'Okay. To run the bot, use "node run.js"'
|
||||
exit
|
||||
fi
|
||||
node run.js
|
||||
|
||||
echo 'Setup complete. Now edit config.json with your preferences and run the bot with "node run.js"'
|
||||
|
@ -22,4 +22,4 @@ which was posted in the current channel.
|
||||
#### ~ud [headword]
|
||||
Returns the first [Urban Dictionary](http://www.urbandictionary.com) definition for the headword provided.
|
||||
#### ~xkcd <comic ID>
|
||||
Returns a link to the [xkcd](http://xkcd.com) comic specified, or the latest one if a comic is not given.
|
||||
Returns a link to the [xkcd](http://xkcd.com) comic specified, or the latest one if a comic is not given. Use '*' to return a link to a random comic.
|
||||
|
@ -34,26 +34,42 @@ var link = function(dbot) {
|
||||
},
|
||||
|
||||
'~xkcd': function(event) {
|
||||
var comicId = event.params[1];
|
||||
if(comicId){
|
||||
comicId = comicId + "/";
|
||||
} else {
|
||||
comicId = "";
|
||||
var comicId = event.params[1] || "";
|
||||
|
||||
if(comicId == "*") {
|
||||
request("http://xkcd.com/info.0.json", function(error, response, body){
|
||||
try {
|
||||
if(response.statusCode == "200") {
|
||||
data = JSON.parse(body);
|
||||
event.params[1] = (Math.floor(Math.random() * data.num) + 1);
|
||||
dbot.commands['~xkcd'](event);
|
||||
}
|
||||
} catch(err) { };
|
||||
});
|
||||
} else {
|
||||
if(comicId !== "") {
|
||||
comicId = comicId + "/";
|
||||
}
|
||||
|
||||
var link = "http://xkcd.com/"+comicId+"info.0.json";
|
||||
request(link, function(error, response, body) {
|
||||
try {
|
||||
if (response.statusCode == "200") {
|
||||
data = JSON.parse(body);
|
||||
event.reply(dbot.t("xkcd",data));
|
||||
} else {
|
||||
event.reply(dbot.t("no-hits"));
|
||||
}
|
||||
} catch(err) { };
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
'~ud': function(event) {
|
||||
var query = event.input[1];
|
||||
var reqUrl = 'http://api.urbandictionary.com/v0/define?term=' + encodeURI(query);
|
||||
|
||||
request(reqUrl, function(error, response, body) {
|
||||
try {
|
||||
var result = JSON.parse(body);
|
||||
@ -73,7 +89,6 @@ var link = function(dbot) {
|
||||
var urlMatches = event.message.match(this.urlRegex);
|
||||
if(urlMatches !== null) {
|
||||
this.links[event.channel.name] = urlMatches[0];
|
||||
|
||||
if(dbot.config.link.autoTitle == true) {
|
||||
this.fetchTitle(event, urlMatches[0]);
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ea795e4d17aa500923468366e73a10f6fbc94ade
|
||||
Subproject commit 171d246b744ad59a66fcab37b8c9ccde793d9213
|
Loading…
Reference in New Issue
Block a user