Merge branch 'fix-message-length'
This commit is contained in:
commit
b114725ded
44
CHANGELOG.md
44
CHANGELOG.md
|
@ -1,52 +1,46 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## v3.1.2
|
## Unreleased
|
||||||
|
### Added
|
||||||
|
- Add rudimentary pagination for viewing feeds when there are more than 10
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Fix articles not posting if contents too long for a single discord message
|
||||||
|
|
||||||
|
## v3.1.2
|
||||||
|
### Fixed
|
||||||
- Deleted channels with feeds sending the bot into a reconnect loop
|
- Deleted channels with feeds sending the bot into a reconnect loop
|
||||||
|
|
||||||
## v3.1.1
|
## v3.1.1
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Empty RSS feed crash
|
- Empty RSS feed crash
|
||||||
|
|
||||||
## v3.1.0
|
## v3.1.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- RSS element content is now included in the post the bot makes when there is a new feed
|
- RSS element content is now included in the post the bot makes when there is a new feed
|
||||||
- Warning message after setup command if supplied URL does not return valid RSS
|
- Warning message after setup command if supplied URL does not return valid RSS
|
||||||
- Guild join and leave messages in the console
|
- Guild join and leave messages in the console
|
||||||
- Removal of guild data if the bot leaves a guild
|
- Removal of guild data if the bot leaves a guild
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
- Route a lot of mostly irrelevant console spam to a file instead of the console
|
- Route a lot of mostly irrelevant console spam to a file instead of the console
|
||||||
- Updated launch command to pass max-old-space-size parameter to limit memory usage
|
- Updated launch command to pass max-old-space-size parameter to limit memory usage
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed syntax error when role omitted in feed setup command; it is now properly optional
|
- Fixed syntax error when role omitted in feed setup command; it is now properly optional
|
||||||
- Fixed the wrong feed sometimes being removed when using the remove-feed command
|
- Fixed the wrong feed sometimes being removed when using the remove-feed command
|
||||||
|
|
||||||
## v3.0.1
|
## v3.0.1
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed nicknamed bot not responding to users on android
|
- Fixed nicknamed bot not responding to users on android
|
||||||
- Fixed "playing" message including "https://" in front of site url
|
- Fixed "playing" message including "https://" in front of site url
|
||||||
|
|
||||||
## v3.0.0
|
## v3.0.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Significantly more debug logging
|
- Significantly more debug logging
|
||||||
- Fancy new @bot help command
|
- Fancy new @bot help command
|
||||||
|
|
||||||
### Updatd
|
### Updatd
|
||||||
|
|
||||||
- Significant back-end updates
|
- Significant back-end updates
|
||||||
- Commands now invoked with an @mention to the bot
|
- Commands now invoked with an @mention to the bot
|
||||||
- Updated error handling for Discord API errors
|
- Updated error handling for Discord API errors
|
||||||
|
@ -55,13 +49,11 @@
|
||||||
- Removed "command not recognised" response, it caused 'fake' errors if multiple bots being run off the same token
|
- Removed "command not recognised" response, it caused 'fake' errors if multiple bots being run off the same token
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed full and short youtube urls not being properly converted
|
- Fixed full and short youtube urls not being properly converted
|
||||||
- Fixed "multiple instance" issue
|
- Fixed "multiple instance" issue
|
||||||
- Fixed a couple of occasional memory leaks
|
- Fixed a couple of occasional memory leaks
|
||||||
|
|
||||||
## v2.0.0-b1
|
## v2.0.0-b1
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Multi-guild support
|
- Multi-guild support
|
||||||
- In-chat commands for setup and configuration
|
- In-chat commands for setup and configuration
|
||||||
|
@ -70,47 +62,35 @@
|
||||||
- Remove an existing feed
|
- Remove an existing feed
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
- Make save file configurable to allow use as a module with other bots
|
- Make save file configurable to allow use as a module with other bots
|
||||||
- Update config file structure
|
- Update config file structure
|
||||||
- Now uses discord.js instead of discord.io
|
- Now uses discord.js instead of discord.io
|
||||||
- YouTube links automatically handled; no more separate "YouTube mode" config item
|
- YouTube links automatically handled; no more separate "YouTube mode" config item
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Crash if trying to view feeds list before any feeds have been set up
|
- Crash if trying to view feeds list before any feeds have been set up
|
||||||
|
|
||||||
## v1.4.0
|
## v1.4.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Support for posting links from multiple feeds
|
- Support for posting links from multiple feeds
|
||||||
- Tagging of separate roles for each feed being checked
|
- Tagging of separate roles for each feed being checked
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
- Updated bot connection code to use my discord-bot-wrapper
|
- Updated bot connection code to use my discord-bot-wrapper
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
- !logsplease command removed as the OTT logging was just being annoying
|
- !logsplease command removed as the OTT logging was just being annoying
|
||||||
|
|
||||||
## v1.3.2
|
## v1.3.2
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed list posting channel messages being ignored
|
- Fixed list posting channel messages being ignored
|
||||||
|
|
||||||
## v1.3.1
|
## v1.3.1
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Developer commands can now be used from any channel or PM
|
- Developer commands can now be used from any channel or PM
|
||||||
|
|
||||||
## v1.3.0
|
## v1.3.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Deletion of "You have successfully subscribed" messages after a short delay (configurable)
|
- Deletion of "You have successfully subscribed" messages after a short delay (configurable)
|
||||||
- 'Developer' commands that can only be accessed by specified users
|
- 'Developer' commands that can only be accessed by specified users
|
||||||
- !cacheList developer command to view the cached URLs
|
- !cacheList developer command to view the cached URLs
|
||||||
|
@ -123,44 +103,34 @@
|
||||||
- The role is mentioned when the link is posted, rather than a long chain of user IDs
|
- The role is mentioned when the link is posted, rather than a long chain of user IDs
|
||||||
|
|
||||||
## v1.2.1
|
## v1.2.1
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed multiple users being unsubscribed when one user unsubscribes
|
- Fixed multiple users being unsubscribed when one user unsubscribes
|
||||||
|
|
||||||
## v1.2.0
|
## v1.2.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Chat message/command to request a list of subscribed users
|
- 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
|
- The ability for users to 'subscribe' so they are tagged whenever a new link is posted
|
||||||
- Logging to a file
|
- Logging to a file
|
||||||
- Ability for user to request an upload of the logs file
|
- Ability for user to request an upload of the logs file
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
- Added basic spam reduction when logging so the same message won't get logged multiple times in a row
|
- 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
|
- 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
|
- 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
|
||||||
- Updated reconnect logic to hopefully be more stable
|
- Updated reconnect logic to hopefully be more stable
|
||||||
|
|
||||||
## v1.1.1
|
## v1.1.1
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Reconnect timer to repeatedly try reconnect at intervals
|
- Reconnect timer to repeatedly try reconnect at intervals
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
- Updated support for https conversion to http to hopefully be more consistent
|
- Updated support for https conversion to http to hopefully be more consistent
|
||||||
|
|
||||||
## v1.1.0
|
## v1.1.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Added togglable YouTube mode
|
- Added togglable YouTube mode
|
||||||
- Converts full URLs to YouTube share URLs
|
- Converts full URLs to YouTube share URLs
|
||||||
- Checks against both YouTube full and share URLs to ensure same video not posted twice
|
- Checks against both YouTube full and share URLs to ensure same video not posted twice
|
||||||
|
@ -171,4 +141,4 @@
|
||||||
- Changed expected name for bot config file to bot-config.json rather than botConfig.json
|
- Changed expected name for bot config file to bot-config.json rather than botConfig.json
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- New timer being created every time the bot reconnected
|
- New timer being created every time the bot reconnected
|
12
README.md
12
README.md
|
@ -22,31 +22,31 @@ If you agree, invite to your server with [this link](https://discordapp.com/oaut
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
You can ask the bot for help with commands by typing `@RSS_Bot help`
|
You can ask the bot for help with commands by typing `@RSS Bot help`
|
||||||
|
|
||||||
### Add a new feed
|
### Add a new feed
|
||||||
|
|
||||||
`@RSS_Bot add-feed <url> <#channel> [@role]`
|
`@RSS Bot add-feed <url> <#channel> [@role]`
|
||||||
- *url* must be an RSS feed URL
|
- *url* must be an RSS feed URL
|
||||||
- *#channel* must be a channel mention
|
- *#channel* must be a channel mention
|
||||||
- *@role* must be a role mention (make sure "Anyone can mention this role" is turned on during setup)
|
- *@role* must be a role mention (make sure "Anyone can mention this role" is turned on during setup)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
`@RSS_Bot add-feed http://lorem-rss.herokuapp.com/feed?unit=second&interval=30 #rss-posts @subscribers`
|
`@RSS Bot add-feed http://lorem-rss.herokuapp.com/feed?unit=second&interval=30 #rss-posts @subscribers`
|
||||||
|
|
||||||
### View feeds configured for this server
|
### View feeds configured for this server
|
||||||
|
|
||||||
`@RSS_Bot view-feeds`
|
`@RSS Bot view-feeds`
|
||||||
This will display a list of RSS feeds configured for this server, along with a unique ID for each
|
This will display a list of RSS feeds configured for this server, along with a unique ID for each
|
||||||
|
|
||||||
### Remove a configured feed
|
### Remove a configured feed
|
||||||
|
|
||||||
`@RSS_Bot remove-feed <feed-id>`
|
`@RSS Bot remove-feed <feed-id>`
|
||||||
|
|
||||||
To remove a feed you will need it's unique ID, which you can find by running the above *view-feeds* command
|
To remove a feed you will need it's unique ID, which you can find by running the above *view-feeds* command
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
`@RSS_Bot remove-feed ABc-123dEF`
|
`@RSS Bot remove-feed ABc-123dEF`
|
||||||
|
|
||||||
## Permissions
|
## Permissions
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const Core = require("../../discord-bot-core");
|
const Core = require("../../discord-bot-core");
|
||||||
|
const Config = require("../config.json");
|
||||||
|
|
||||||
module.exports = new Core.Command({
|
module.exports = new Core.Command({
|
||||||
name: "view-feeds",
|
name: "view-feeds",
|
||||||
|
@ -12,5 +13,11 @@ function invoke({ message, params, guildData, client }) {
|
||||||
if (!guildData)
|
if (!guildData)
|
||||||
return Promise.reject("Guild not setup");
|
return Promise.reject("Guild not setup");
|
||||||
|
|
||||||
return Promise.resolve(guildData.feeds.map(f => f.toString()).join("\n"));
|
const startIdx = params[0] ? (params[0] - 1) * Config.viewFeedsPaginationLimit : 0;
|
||||||
|
const endIdx = startIdx + Config.viewFeedsPaginationLimit + 1;
|
||||||
|
|
||||||
|
let responseStr = guildData.feeds.map(f => f.toString()).slice(startIdx, endIdx).join("\n");
|
||||||
|
if (guildData.feeds.length > endIdx)
|
||||||
|
responseStr += `Use *view-feeds ${startIdx + 2}* to view more`;
|
||||||
|
return Promise.resolve(responseStr);
|
||||||
}
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
{
|
{
|
||||||
"maxCacheSize": 100,
|
"maxCacheSize": 100,
|
||||||
"feedCheckIntervalSec": 30
|
"feedCheckIntervalSec": 30,
|
||||||
|
"charLimit": 500,
|
||||||
|
"viewFeedsPaginationLimit": 10
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
//my imports
|
|
||||||
const DiscordUtil = require("../../discord-bot-core").util;
|
const DiscordUtil = require("../../discord-bot-core").util;
|
||||||
|
// @ts-ignore
|
||||||
//external lib imports
|
const Config = require("../config.json");
|
||||||
const Dns = require("dns"); //for host resolution checking
|
const Dns = require("dns"); //for host resolution checking
|
||||||
const Url = require("url"); //for url parsing
|
const Url = require("url"); //for url parsing
|
||||||
const FeedRead = require("feed-read"); //for extracing new links from RSS feeds
|
const FeedRead = require("feed-read"); //for extracing new links from RSS feeds
|
||||||
|
@ -34,7 +33,7 @@ module.exports = class FeedData {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@param param*/
|
/**@param guild*/
|
||||||
updatePastPostedLinks(guild) {
|
updatePastPostedLinks(guild) {
|
||||||
const channel = guild.channels.get(this.channelID);
|
const channel = guild.channels.get(this.channelID);
|
||||||
|
|
||||||
|
@ -53,7 +52,7 @@ module.exports = class FeedData {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@param param */
|
/**@param guild */
|
||||||
fetchLatest(guild) {
|
fetchLatest(guild) {
|
||||||
Dns.resolve(Url.parse(this.url).host || "", err => {
|
Dns.resolve(Url.parse(this.url).host || "", err => {
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -100,7 +99,7 @@ function formatPost(article) {
|
||||||
if (article.title)
|
if (article.title)
|
||||||
message += `\n**${article.title}**`;
|
message += `\n**${article.title}**`;
|
||||||
if (article.content)
|
if (article.content)
|
||||||
message += `\n${article.content}`;
|
message += article.content.length > Config.charLimit ? "\nArticle content too long for a single Discord message!" : `\n${article.content}`;
|
||||||
if (article.link)
|
if (article.link)
|
||||||
message += `\n\n${normaliseUrl(article.link)}`;
|
message += `\n\n${normaliseUrl(article.link)}`;
|
||||||
return message;
|
return message;
|
||||||
|
|
|
@ -92,10 +92,6 @@ module.exports = class Client extends Discord.Client {
|
||||||
err => { if (err) CoreUtil.dateError(`Error writing data file! ${err.message || err}`); });
|
err => { if (err) CoreUtil.dateError(`Error writing data file! ${err.message || err}`); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {*} json
|
|
||||||
* @param {*} guildDataModel
|
|
||||||
*/
|
|
||||||
fromJSON(json) {
|
fromJSON(json) {
|
||||||
const guildsData = Object.keys(json);
|
const guildsData = Object.keys(json);
|
||||||
guildsData.forEach(guildID => {
|
guildsData.forEach(guildID => {
|
||||||
|
|
|
@ -4,7 +4,6 @@ const ParentPackageJSON = require("../package.json");
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const InternalConfig = require("./internal-config.json");
|
const InternalConfig = require("./internal-config.json");
|
||||||
|
|
||||||
/**@param param*/
|
|
||||||
function handleMessage(client, message, commands, guildData) {
|
function handleMessage(client, message, commands, guildData) {
|
||||||
if (!message.content.startsWith(message.guild.me.toString()) //criteria for a command is the bot being tagged
|
if (!message.content.startsWith(message.guild.me.toString()) //criteria for a command is the bot being tagged
|
||||||
&& !message.content.startsWith(message.guild.me.toString().replace("!", ""))) //hacky fix for android mentions not including an exclamation mark
|
&& !message.content.startsWith(message.guild.me.toString().replace("!", ""))) //hacky fix for android mentions not including an exclamation mark
|
||||||
|
@ -33,7 +32,6 @@ function handleMessage(client, message, commands, guildData) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@param param*/
|
|
||||||
function handleInternalCommand(message, split, commands, isMemberAdmin) {
|
function handleInternalCommand(message, split, commands, isMemberAdmin) {
|
||||||
if (!split[1])
|
if (!split[1])
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"main": "app/index.js",
|
"main": "app/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "cd ./discord-bot-core && npm install",
|
"postinstall": "cd ./discord-bot-core && npm install",
|
||||||
"start": "node app/index.js token.json guilds.json --max-old-space-size=64"
|
"start": "node app/index.js token.json guilds.json --max-old-space-size=64 --name=rss-feed"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "11.2.0",
|
"discord.js": "11.2.0",
|
||||||
|
|
Loading…
Reference in a new issue