Merge branch 'release/v1.2.0'
Conflicts: CHANGELOG.md feed-bot.js
This commit is contained in:
commit
b13ffebdc4
|
@ -23,6 +23,7 @@
|
||||||
"always"
|
"always"
|
||||||
],
|
],
|
||||||
"no-undef": "error",
|
"no-undef": "error",
|
||||||
"no-unused-vars": "warn"
|
"no-unused-vars": "warn",
|
||||||
|
"eqeqeq": ["error", "always"]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
log
|
||||||
|
subscribers.json
|
||||||
|
|
||||||
# Created by https://www.gitignore.io/api/visualstudiocode,node
|
# Created by https://www.gitignore.io/api/visualstudiocode,node
|
||||||
|
|
||||||
|
|
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,5 +1,20 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v1.2.0
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Chat message/command to request a list of subscribed users
|
||||||
|
- The ability for users to 'subscribe' so they are tagged whenever a new link is posted
|
||||||
|
- Logging to a file
|
||||||
|
- Ability for user to request an upload of the logs file
|
||||||
|
|
||||||
|
### Updated
|
||||||
|
|
||||||
|
- Added basic spam reduction when logging so the same message won't get logged multiple times in a row
|
||||||
|
- Refactored a bunch of code to improve efficiency
|
||||||
|
- Updated timer logic to only ever use a single timer, and share it between posting and reconnecting
|
||||||
|
|
||||||
## v1.1.2
|
## v1.1.2
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
18
README.md
18
README.md
|
@ -3,19 +3,9 @@
|
||||||
- Posts latest link from RSS feed into specified Discord channel
|
- Posts latest link from RSS feed into specified Discord channel
|
||||||
- Configurable polling interval
|
- Configurable polling interval
|
||||||
- Doesn't post the link if it has already been posted in last 100 messages
|
- Doesn't post the link if it has already been posted in last 100 messages
|
||||||
- YouTube mode - detects both youtube.com and youtu.be links, and doesn't post again if *either* have already been posted (BETA)
|
- YouTube mode - detects both youtube.com and youtu.be links, and doesn't post again if *either* have already been posted
|
||||||
|
- Subscription - users can subscribe and have their username tagged when a new link is posted
|
||||||
|
|
||||||
Feel free to contact me with suggestions and feature requests - if you need a new feature, just let me know and I will see what I can do! (No promises though :p)
|
Please view the github wiki for details regarding installation and commands for interacting with the bot
|
||||||
|
|
||||||
# Installation
|
Feel free to contact me with suggestions and feature requests - if you need a new feature, just let me know and I will see what I can do! (No promises though :p)
|
||||||
|
|
||||||
1. Make sure you have nodejs (v6+) and npm installed
|
|
||||||
2. Download the zip from [releases](https://github.com/benji7425/discord-feed-bot/releases) and extract
|
|
||||||
3. Open a terminal in extracted folder
|
|
||||||
4. Run `npm install` and wait for it to finish
|
|
||||||
5. Edit *config.json* to include your RSS feed and channel ID
|
|
||||||
6. Create *bot-config.json* to include your bot token:
|
|
||||||
`{
|
|
||||||
"token": "abc123blahblahblahyourtokengoeshere"
|
|
||||||
}`
|
|
||||||
7. Run `node feed-bot.js`
|
|
|
@ -3,5 +3,12 @@
|
||||||
"channelID": "264420391282409473",
|
"channelID": "264420391282409473",
|
||||||
"pollingInterval": 5000,
|
"pollingInterval": 5000,
|
||||||
"numLinksToCache": 10,
|
"numLinksToCache": 10,
|
||||||
"youtubeMode": true
|
"youtubeMode": true,
|
||||||
|
"logRequestMessage": "!logsplease",
|
||||||
|
"subscribeRequestMessage": "!subscribe",
|
||||||
|
"unsubscribeRequestMessage": "!unsubscribe",
|
||||||
|
"subscribersListRequestMessage": "!sublist",
|
||||||
|
"helpRequestMessage": "!help",
|
||||||
|
"logFile": "./log",
|
||||||
|
"subscribersFile": "./subscribers.json"
|
||||||
}
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
If browsing on GitHub, please use the sidebar on the right to navigate the wiki.
|
||||||
|
|
||||||
|
Please use releases from the 'releases' page when installing rather than just cloning the repository yourself
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Commands
|
||||||
|
|
||||||
|
There is a very basic level of interaction with the bot available via chat commands, all of which are prefixed with an exclamation mark '!'
|
||||||
|
|
||||||
|
| command | action |
|
||||||
|
|--------------|-----------------------------------------------------------------------------------------|
|
||||||
|
| !help | list available commands |
|
||||||
|
| !subscribe | subscribe to feed notifications, so your username gets tagged when a new link is posted |
|
||||||
|
| !unsubscribe | unsubscribe from feed notifications |
|
||||||
|
| !sublist | view list of subscribed users |
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
1. Make sure you have nodejs (v6+) and npm installed
|
||||||
|
2. Download the zip from [releases](https://github.com/benji7425/discord-feed-bot/releases) and extract
|
||||||
|
3. Open a terminal in extracted folder
|
||||||
|
4. Run `npm install` and wait for it to finish
|
||||||
|
5. Edit *config.json* to include your RSS feed and channel ID
|
||||||
|
6. Create *bot-config.json* to include your bot token:
|
||||||
|
`{
|
||||||
|
"token": "abc123blahblahblahyourtokengoeshere"
|
||||||
|
}`
|
||||||
|
7. Run `node feed-bot.js`
|
200
feed-bot.js
200
feed-bot.js
|
@ -4,6 +4,7 @@ var Url = require("url"); //for url parsing
|
||||||
var Uri = require("urijs"); //for finding urls within message strings
|
var Uri = require("urijs"); //for finding urls within message strings
|
||||||
var Discord = require("discord.io"); //for obvious reasons
|
var Discord = require("discord.io"); //for obvious reasons
|
||||||
var FeedRead = require("feed-read"); //for rss feed reading
|
var FeedRead = require("feed-read"); //for rss feed reading
|
||||||
|
var JsonFile = require("jsonfile"); //reading/writing json
|
||||||
|
|
||||||
//my imports
|
//my imports
|
||||||
var Log = require("./log.js"); //some very simple logging functions I made
|
var Log = require("./log.js"); //some very simple logging functions I made
|
||||||
|
@ -12,8 +13,6 @@ var Config = require("./config.json"); //config file containing other settings
|
||||||
|
|
||||||
var DiscordClient = {
|
var DiscordClient = {
|
||||||
bot: null,
|
bot: null,
|
||||||
feedInterval: null,
|
|
||||||
reconnectInterval: null,
|
|
||||||
startup: function () {
|
startup: function () {
|
||||||
//check if we can connect to discordapp.com to authenticate the bot
|
//check if we can connect to discordapp.com to authenticate the bot
|
||||||
Dns.resolve("discordapp.com", function (err) {
|
Dns.resolve("discordapp.com", function (err) {
|
||||||
|
@ -36,31 +35,60 @@ var DiscordClient = {
|
||||||
onReady: function () {
|
onReady: function () {
|
||||||
Log.info("Registered/connected bot " + DiscordClient.bot.username + " - (" + DiscordClient.bot.id + ")");
|
Log.info("Registered/connected bot " + DiscordClient.bot.username + " - (" + DiscordClient.bot.id + ")");
|
||||||
|
|
||||||
clearInterval(DiscordClient.reconnectInterval);
|
|
||||||
|
|
||||||
Log.info("Setting up timer to check feed every " + Config.pollingInterval + " milliseconds");
|
|
||||||
DiscordClient.feedInterval = setInterval(Feed.checkAndPost, Config.pollingInterval); //set up the timer to check the feed
|
|
||||||
|
|
||||||
DiscordClient.checkPastMessagesForLinks(); //we need to check past messages for links on startup, but also on reconnect because we don't know what has happened during the downtime
|
DiscordClient.checkPastMessagesForLinks(); //we need to check past messages for links on startup, but also on reconnect because we don't know what has happened during the downtime
|
||||||
|
|
||||||
|
intervalFunc = () => {
|
||||||
|
Feed.check((err, articles) => {
|
||||||
|
Links.validate(err, articles, DiscordClient.post);
|
||||||
|
});
|
||||||
|
};
|
||||||
},
|
},
|
||||||
onDisconnect: function (err, code) {
|
onDisconnect: function (err, code) {
|
||||||
Log.event("Bot was disconnected! " + (err ? err : "") + (code ? code : "No disconnect code provided.") + "\nClearing the feed timer and starting reconnect timer", "Discord.io");
|
Log.event("Bot was disconnected! " + (err ? err : "") + (code ? code : "No disconnect code provided.") + "\nClearing the feed timer and starting reconnect timer", "Discord.io");
|
||||||
|
|
||||||
clearInterval(DiscordClient.feedInterval)
|
intervalFunc = DiscordClient.startup; //reassign the interval function to try restart the bot every 5 sec
|
||||||
|
|
||||||
DiscordClient.reconnectInterval = setInterval(function () {
|
|
||||||
DiscordClient.startup();
|
|
||||||
}, (Config.reconnectInterval || Config.pollingInterval));
|
|
||||||
},
|
},
|
||||||
onMessage: function (user, userID, channelID, message) {
|
onMessage: function (user, userID, channelID, message) {
|
||||||
//check if the message is in the right channel, contains a link, and is not the latest link from the rss feed
|
if (channelID === Config.channelID) {
|
||||||
if (channelID === Config.channelID && Links.messageContainsLink(message) && (message !== Links.latestFromFeed)) {
|
//contains a link, and is not the latest link from the rss feed
|
||||||
Log.event("Detected posted link in this message: " + message, "Discord.io");
|
if (Links.messageContainsLink(message) && (message !== Links.latestFromFeedlatestFeedLink)) {
|
||||||
|
Log.event("Detected posted link in this message: " + message, "Discord.io");
|
||||||
|
|
||||||
//extract the url from the string, and cache it
|
//extract the url from the string, and cache it
|
||||||
Uri.withinString(message, function (url) {
|
Uri.withinString(message, function (url) {
|
||||||
Links.cache(Links.standardise(url));
|
Links.cache(Links.standardise(url));
|
||||||
return url;
|
return url;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
switch (message) {
|
||||||
|
case Config.subscribeRequestMessage:
|
||||||
|
Subscriptions.subscribe(channelID, userID, user);
|
||||||
|
break;
|
||||||
|
case Config.unsubscribeRequestMessage:
|
||||||
|
Subscriptions.unsubscribe(channelID, userID, user);
|
||||||
|
break;
|
||||||
|
case Config.subscribersListRequestMessage:
|
||||||
|
DiscordClient.bot.sendMessage({
|
||||||
|
to: Config.channelID,
|
||||||
|
message: DiscordClient.bot.fixMessage("<@" + Subscriptions.subscribers.join("> <@") + ">")
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case Config.helpRequestMessage:
|
||||||
|
DiscordClient.bot.sendMessage({
|
||||||
|
to: Config.channelID,
|
||||||
|
message: Config.subscribeRequestMessage + ", " + Config.unsubscribeRequestMessage + ", " + Config.subscribersListRequestMessage
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (message === Config.logRequestMessage) {
|
||||||
|
DiscordClient.bot.uploadFile({
|
||||||
|
to: channelID,
|
||||||
|
file: Config.logFile
|
||||||
|
}, (err, message) => {
|
||||||
|
if (err) Log.error("Failed to upload log file: " + message, err);
|
||||||
|
else Log.event("Uploaded log file for user " + user + "(" + userID + ")");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -91,6 +119,60 @@ var DiscordClient = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
post: function (link) {
|
||||||
|
var tags = "";
|
||||||
|
for (var userID in Subscriptions.subscribers)
|
||||||
|
tags += "<@" + Subscriptions.subscribers[userID] + "> ";
|
||||||
|
|
||||||
|
//send a messsage containing the new feed link to our discord channel
|
||||||
|
DiscordClient.bot.sendMessage({
|
||||||
|
to: Config.channelID,
|
||||||
|
message: tags + link
|
||||||
|
}, function (err, message) {
|
||||||
|
if (err) {
|
||||||
|
Log.error("ERROR: Failed to send message" + message ? message : "", err);
|
||||||
|
//if there is an error posting the message, check if it is because the bot isn't connected
|
||||||
|
if (!DiscordClient.bot.connected) DiscordClient.onDisconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var Subscriptions = {
|
||||||
|
subscribers: [],
|
||||||
|
parse: function () {
|
||||||
|
JsonFile.readFile(Config.subscribersFile, (err, obj) => {
|
||||||
|
if (err) Log.error("Unable to parse json subscribers file", err);
|
||||||
|
this.subscribers = obj || [];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
subscribe: function (channelID, userID, user) {
|
||||||
|
if (this.subscribers.indexOf(userID) === -1) {
|
||||||
|
this.subscribers.push(userID); //subscribe the user if they aren't already subscribed
|
||||||
|
this.writeToFile();
|
||||||
|
Log.event("Subscribed user " + (user ? user + "(" + userID + ")" : userID));
|
||||||
|
|
||||||
|
DiscordClient.bot.sendMessage({
|
||||||
|
to: channelID,
|
||||||
|
message: "You have successfully subscribed"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unsubscribe: function (channelID, userID, user) {
|
||||||
|
if (this.subscribers.indexOf(userID) > -1) {
|
||||||
|
this.subscribers.splice(this.subscribers.indexOf(userID));
|
||||||
|
this.writeToFile();
|
||||||
|
Log.event("Unsubscribed user " + (user ? user + "(" + userID + ")" : userID));
|
||||||
|
|
||||||
|
DiscordClient.bot.sendMessage({
|
||||||
|
to: channelID,
|
||||||
|
message: "You have successfully unsubscribed"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
writeToFile: function () {
|
||||||
|
JsonFile.writeFile(Config.subscribersFile, this.subscribers, (err) => { if (err) Log.error("Unable to write subscribers to json file", err); });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,14 +180,13 @@ var YouTube = {
|
||||||
url: {
|
url: {
|
||||||
share: "http://youtu.be/",
|
share: "http://youtu.be/",
|
||||||
full: "http://www.youtube.com/watch?v=",
|
full: "http://www.youtube.com/watch?v=",
|
||||||
convertShareToFull: function (shareUrl) {
|
createFullUrl: function (shareUrl) {
|
||||||
return shareUrl.replace(YouTube.url.share, YouTube.url.full);
|
return shareUrl.replace(YouTube.url.share, YouTube.url.full);
|
||||||
},
|
},
|
||||||
convertFullToShare: function (fullUrl) {
|
createShareUrl: function (fullUrl) {
|
||||||
var shareUrl = fullUrl.replace(YouTube.url.full, YouTube.url.share);
|
var shareUrl = fullUrl.replace(YouTube.url.full, YouTube.url.share);
|
||||||
|
|
||||||
if (shareUrl.includes("&"))
|
if (shareUrl.includes("&")) shareUrl = shareUrl.slice(0, fullUrl.indexOf("&"));
|
||||||
shareUrl = shareUrl.slice(0, fullUrl.indexOf("&"));
|
|
||||||
|
|
||||||
return shareUrl;
|
return shareUrl;
|
||||||
}
|
}
|
||||||
|
@ -123,81 +204,68 @@ var Links = {
|
||||||
return messageLower.includes("http://") || messageLower.includes("https://") || messageLower.includes("www.");
|
return messageLower.includes("http://") || messageLower.includes("https://") || messageLower.includes("www.");
|
||||||
},
|
},
|
||||||
cached: [],
|
cached: [],
|
||||||
latestFromFeed: "",
|
latestFeedLink: "",
|
||||||
cache: function (link) {
|
cache: function (link) {
|
||||||
link = Links.standardise(link);
|
link = Links.standardise(link);
|
||||||
|
|
||||||
if (Config.youtubeMode && link.includes(YouTube.url.full)) {
|
if (Config.youtubeMode) link = YouTube.url.createShareUrl(link);
|
||||||
link = YouTube.url.convertFullToShare(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
//store the new link if not stored already
|
//store the new link if not stored already
|
||||||
if (!Links.checkCache(link)) {
|
if (!Links.isCached(link)) {
|
||||||
Links.cached.push(link);
|
Links.cached.push(link);
|
||||||
Log.info("Cached URL: " + link);
|
Log.info("Cached URL: " + link);
|
||||||
}
|
}
|
||||||
//get rid of the first array element if we have reached our cache limit
|
|
||||||
if (Links.cached.length > (Config.numLinksToCache || 10))
|
if (Links.cached.length > Config.numLinksToCache) Links.cached.shift(); //get rid of the first array element if we have reached our cache limit
|
||||||
Links.cached.shift();
|
|
||||||
},
|
},
|
||||||
checkCache: function (link) {
|
isCached: function (link) {
|
||||||
link = Links.standardise(link);
|
link = Links.standardise(link);
|
||||||
|
|
||||||
if (Config.youtubeMode && link.includes(YouTube.url.full)) {
|
if (Config.youtubeMode)
|
||||||
return Links.cached.includes(YouTube.url.convertFullToShare(link));
|
return Links.cached.includes(YouTube.url.createShareUrl(link));
|
||||||
}
|
|
||||||
return Links.cached.includes(link);
|
return Links.cached.includes(link);
|
||||||
},
|
},
|
||||||
validateAndPost: function (err, articles) {
|
validate: function (err, articles, callback) {
|
||||||
if (err) Log.error("FEED ERROR: Error reading RSS feed.", err);
|
if (err) Log.error("FEED ERROR: Error reading RSS feed.", err);
|
||||||
else {
|
else {
|
||||||
var latestLink = Links.standardise(articles[0].link); //get the latest link and check if it has already been posted and cached
|
var latestLink = Links.standardise(articles[0].link);
|
||||||
|
if (Config.youtubeMode) latestLink = YouTube.url.createShareUrl(latestLink);
|
||||||
|
|
||||||
//check whether the latest link out the feed exists in our cache
|
//make sure we don't spam the latest link
|
||||||
if (!Links.checkCache(latestLink)) {
|
if (latestLink === Links.latestFeedLink)
|
||||||
if (Config.youtubeMode && latestLink.includes(YouTube.url.full))
|
return;
|
||||||
latestLink = YouTube.url.convertFullToShare(latestLink);
|
|
||||||
Log.info("Attempting to post new link: " + latestLink);
|
|
||||||
|
|
||||||
//send a messsage containing the new feed link to our discord channel
|
//make sure the latest link hasn't been posted already
|
||||||
DiscordClient.bot.sendMessage({
|
if (Links.isCached(latestLink)) {
|
||||||
to: Config.channelID,
|
Log.info("Didn't post new feed link because already detected as posted " + latestLink);
|
||||||
message: latestLink
|
|
||||||
}, function (err, message) {
|
|
||||||
if (err) {
|
|
||||||
Log.error("ERROR: Failed to send message: " + message.substring(0, 15) + "...", err);
|
|
||||||
//if there is an error posting the message, check if it is because the bot isn't connected
|
|
||||||
if (DiscordClient.bot.connected)
|
|
||||||
Log.info("Connectivity seems fine - I have no idea why the message didn't post");
|
|
||||||
else {
|
|
||||||
Log.error("DiscordClient appears to be disconnected! Attempting to reconnect...", err);
|
|
||||||
|
|
||||||
DiscordClient.bot.connect(); //attempt to reconnect
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Links.cache(latestLink); //finally make sure the link is cached, so it doesn't get posted again
|
|
||||||
}
|
}
|
||||||
else if (Links.latestFromFeed != latestLink)
|
else {
|
||||||
Log.info("Didn't post new feed link because already detected as posted " + latestLink); //alternatively, if we have a new link from the feed, but its been posted already, just alert the console
|
callback(latestLink);
|
||||||
|
|
||||||
Links.latestFromFeed = latestLink; //ensure our latest feed link variable is up to date, so we can track when the feed updates
|
Links.cache(latestLink); //make sure the link is cached, so it doesn't get posted again
|
||||||
|
}
|
||||||
|
|
||||||
|
Links.latestFeedLink = latestLink; //ensure our latest feed link variable is up to date, so we can track when the feed updates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var Feed = {
|
var Feed = {
|
||||||
urlObj: Url.parse(Config.feedUrl),
|
urlObj: Url.parse(Config.feedUrl),
|
||||||
checkAndPost: function () {
|
check: function (callback) {
|
||||||
Dns.resolve(Feed.urlObj.host, function (err) { //check that we have an internet connection (well not exactly - check that we have a connection to the host of the feedUrl)
|
Dns.resolve(Feed.urlObj.host, function (err) { //check that we have an internet connection (well not exactly - check that we have a connection to the host of the feedUrl)
|
||||||
if (err) Log.error("CONNECTION ERROR: Cannot resolve host.", err);
|
if (err) Log.error("CONNECTION ERROR: Cannot resolve host.", err);
|
||||||
else FeedRead(Config.feedUrl, Links.validateAndPost);
|
else FeedRead(Config.feedUrl, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var intervalFunc = () => { }; //do nothing by default
|
||||||
|
|
||||||
//IIFE to kickstart the bot when the app loads
|
//IIFE to kickstart the bot when the app loads
|
||||||
(function () {
|
(function () {
|
||||||
|
Subscriptions.parse();
|
||||||
DiscordClient.startup();
|
DiscordClient.startup();
|
||||||
|
setInterval(() => { intervalFunc(); }, Config.pollingInterval);
|
||||||
})();
|
})();
|
26
log.js
26
log.js
|
@ -1,26 +1,40 @@
|
||||||
var console = require("console");
|
//external library imports
|
||||||
|
var Console = require("console"); //access to debug console
|
||||||
|
var FileWriter = require("simple-file-writer"); //file writer for logging
|
||||||
|
|
||||||
|
//my imports
|
||||||
|
var Config = require("./config.json"); //config file containing other settings
|
||||||
|
|
||||||
|
var logWriter = new FileWriter(Config.logFile);
|
||||||
|
var latestLog = "";
|
||||||
|
|
||||||
function log(message) {
|
function log(message) {
|
||||||
if (message)
|
if (message && message !== latestLog) {
|
||||||
|
latestLog = message; //spam reduction
|
||||||
|
|
||||||
//attach a formatted date string to the beginning of everything we log
|
//attach a formatted date string to the beginning of everything we log
|
||||||
console.log(new Date().toLocaleString() + " " + message);
|
var dateMessage = new Date().toLocaleString() + " " + message;
|
||||||
|
|
||||||
|
Console.log(dateMessage);
|
||||||
|
logWriter.write(dateMessage + "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
info: function (message) {
|
info: function (message) {
|
||||||
if (message)
|
if (message)
|
||||||
log("INFO: " + message);
|
log("[INFO] " + message);
|
||||||
},
|
},
|
||||||
event: function (message, sender) {
|
event: function (message, sender) {
|
||||||
//if we received a message, log it - include sender information if it was passed
|
//if we received a message, log it - include sender information if it was passed
|
||||||
if (message) {
|
if (message) {
|
||||||
log("EVENT: " + (sender ? sender + " has sent an event: " : "") + message);
|
log("[EVENT] " + (sender ? sender + " has sent an event: " : "") + message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (message, innerEx) {
|
error: function (message, innerEx) {
|
||||||
if (message) {
|
if (message) {
|
||||||
//log the message, attach innerEx information if it was passed
|
//log the message, attach innerEx information if it was passed
|
||||||
log("ERROR: " + message + (innerEx ? ". Inner exception details: " + (innerEx.message || innerEx) : ""));
|
log("[ERROR] " + message + (innerEx ? ". Inner exception details: " + (innerEx.message || innerEx) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -19,6 +19,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.io": "^2.2.4",
|
"discord.io": "^2.2.4",
|
||||||
"feed-read": "0.0.1",
|
"feed-read": "0.0.1",
|
||||||
|
"simple-file-writer": "^2.0.0",
|
||||||
|
"jsonfile": "^2.4.0",
|
||||||
"urijs": "^1.18.2"
|
"urijs": "^1.18.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue