diff --git a/.gitignore b/.gitignore index cf7c602..c2658d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ node_modules/ -config.json \ No newline at end of file diff --git a/README.md b/README.md index e1b8f3e..d23bdcb 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,57 @@ # Link-Flayer -Node.JS Discord RSS Bot + +**Discord RSS News Bot** Link Flayer is a Discord Bot designed to provide your Discord server with news. -Available Commands +**Setup** +- *npm install link-flayer* or *git clone https://github.com/johnfacey/link-flayer.git* +- Add your token from Discord Bot Interface to the *config.json* [https://discord.com/developers/applications/] +
+Example: config.json
+{
+ "prefix": "!",
+ "token": "{Your Discord Bot Token Here}"
+}
+
+
+- Configure your feeds.json: Each node with a "title" and "link" attribute.
+
+
+Example: feeds.json
+[
+ {
+ "title": "CNN Top Stories",
+ "link": "http://rss.cnn.com/rss/cnn_topstories.rss"
+ },
+ {
+ "title": "Reddit Front Page",
+ "link": "http://www.reddit.com/.rss"
+ },
+ {
+ "title": "Arstechnica",
+ "link": "http://feeds.arstechnica.com/arstechnica/index"
+ }
+
+]
+
+
+**Usage**
+
+- *npm start*
+
+
+
+**Available Commands**
-* !help - Lists the available commands: *!help*
+* **!help** - Lists the available commands: *!help*
-* !search - Searches the RSS Sources: *!search google*
+* **!search** - Searches the RSS Sources: *!search google*
-* !get - Retrieves Search By Index: *!get 25*
+* **!get** - Retrieves Search By Index: *!get 25*
-* !add - Add a new RSS Source Feed dynamically: *!add http://www.engadget.com/rss.xml*
+* **!add** - Add a new RSS Source Feed dynamically: *!add http://www.engadget.com/rss.xml*
-* !update - Updates all current RSS Feeds: *!update*
+* **!update** - Updates all current RSS Feeds: *!update*
diff --git a/commands/add.js b/commands/add.js
index 5edeef8..95515cb 100644
--- a/commands/add.js
+++ b/commands/add.js
@@ -9,9 +9,10 @@ module.exports = {
message.reply(`Please use in !get [number] format`);
return;
}
- var command = args[0];
- var param1 = args[1];
- libFlayer.addSource(param1);
+ var title = args[0];
+ var link = args[1];
+
+ libFlayer.addSource(title,link);
libFlayer.loadFeeds();
},
diff --git a/commands/get.js b/commands/get.js
index 65877a0..f626874 100644
--- a/commands/get.js
+++ b/commands/get.js
@@ -6,7 +6,7 @@ module.exports = {
execute(message, args) {
if (args.length < 1) {
- message.reply(`Please use in !get [number] format`);
+ message.reply(`Use !get [number] Ex: !get 25`);
return;
}
var search = args[0];
diff --git a/commands/help.js b/commands/help.js
index 13f15d7..415701d 100644
--- a/commands/help.js
+++ b/commands/help.js
@@ -4,6 +4,10 @@ module.exports = {
name: 'help',
description: 'Help',
execute(message) {
- message.reply('For a list of available commands type !commands');
+ message.reply('!help - Lists the available commands');
+ message.reply('**!search** - Searches the RSS Sources: *!search google*');
+ message.reply('**!get**- Retrieves Search By Index: *!get 25*');
+ message.reply('**!add** - Add a new RSS Source Feed dynamically: *!add http://www.engadget.com/rss.xml*');
+ message.reply('**!update** - Updates all current RSS Feeds: *!update*');
}
};
\ No newline at end of file
diff --git a/commands/search.js b/commands/search.js
index ca11479..e79dd8e 100644
--- a/commands/search.js
+++ b/commands/search.js
@@ -11,13 +11,14 @@ module.exports = {
}
var search = args[0];
-
+ var found = false;
message.reply('Searching for: ' + search);
let i = 0;
var feedArray = libFlayer.getFeeds();
feedArray.forEach(linkFlay => {
if (linkFlay.title.toLowerCase().indexOf(search.toLowerCase()) > -1) {
+ found = true;
console.log(linkFlay.title);
message.reply(`Use !get ${i} to view: ${linkFlay.title}`);
@@ -25,5 +26,9 @@ module.exports = {
i++;
});
+ if (!found) {
+ message.reply(`No results found for: ${search}`);
+ }
+
}
};
\ No newline at end of file
diff --git a/commands/sources.js b/commands/sources.js
index b0e0f19..fe399e5 100644
--- a/commands/sources.js
+++ b/commands/sources.js
@@ -5,9 +5,6 @@ module.exports = {
description: 'List RSS Sources',
execute(message, args) {
- var command = args[0];
- var search = args[1];
-
var sourceArray = libFlayer.getSources();
sourceArray.forEach(source => {
message.reply(`[${source.title}](${source.link})`);
diff --git a/commands/update.js b/commands/update.js
index 9af3c29..49d0139 100644
--- a/commands/update.js
+++ b/commands/update.js
@@ -4,7 +4,7 @@ module.exports = {
name: 'update',
description: 'Get RSS Source Link',
execute(message, args) {
-
+
message.reply(`Updating Sources`);
libFlayer.loadFeeds();
feedArray = libFlayer.getFeeds();
diff --git a/index.js b/index.js
index 9524f5e..f72bd91 100644
--- a/index.js
+++ b/index.js
@@ -35,5 +35,5 @@ client.on('message', message => {
});
console.log("Link Flayer Bot Activating");
-client.login(token);
-libFlayer.loadFeeds();
+client.login(token); //Load Client Discord Token
+libFlayer.loadFeeds(); //Load Configured Feeds
diff --git a/libFlayer.js b/libFlayer.js
index 03851c2..4cdff1f 100644
--- a/libFlayer.js
+++ b/libFlayer.js
@@ -5,9 +5,9 @@ let feeds = require('./feeds.json');
let linkFlayerMap = [];
-exports.addSource = function(source){
+exports.addSource = function(title,source){
var linkData = {
- title: `${source}`,
+ title: `${title}`,
link: `${source}`
}
feeds.push(linkData);