Merge branch 'fix-message-length'
This commit is contained in:
commit
b114725ded
42
CHANGELOG.md
42
CHANGELOG.md
|
@ -1,52 +1,46 @@
|
|||
# Changelog
|
||||
|
||||
## v3.1.2
|
||||
## Unreleased
|
||||
### Added
|
||||
- Add rudimentary pagination for viewing feeds when there are more than 10
|
||||
|
||||
### 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
|
||||
|
||||
## v3.1.1
|
||||
|
||||
### Fixed
|
||||
|
||||
- Empty RSS feed crash
|
||||
|
||||
## v3.1.0
|
||||
|
||||
### Added
|
||||
|
||||
- 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
|
||||
- Guild join and leave messages in the console
|
||||
- Removal of guild data if the bot leaves a guild
|
||||
|
||||
### Updated
|
||||
|
||||
- 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
|
||||
|
||||
### Fixed
|
||||
|
||||
- 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
|
||||
|
||||
## v3.0.1
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed nicknamed bot not responding to users on android
|
||||
- Fixed "playing" message including "https://" in front of site url
|
||||
|
||||
## v3.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- Significantly more debug logging
|
||||
- Fancy new @bot help command
|
||||
|
||||
### Updatd
|
||||
|
||||
- Significant back-end updates
|
||||
- Commands now invoked with an @mention to the bot
|
||||
- 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
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed full and short youtube urls not being properly converted
|
||||
- Fixed "multiple instance" issue
|
||||
- Fixed a couple of occasional memory leaks
|
||||
|
||||
## v2.0.0-b1
|
||||
|
||||
### Added
|
||||
- Multi-guild support
|
||||
- In-chat commands for setup and configuration
|
||||
|
@ -70,47 +62,35 @@
|
|||
- Remove an existing feed
|
||||
|
||||
### Updated
|
||||
|
||||
- Make save file configurable to allow use as a module with other bots
|
||||
- Update config file structure
|
||||
- Now uses discord.js instead of discord.io
|
||||
- YouTube links automatically handled; no more separate "YouTube mode" config item
|
||||
|
||||
### Fixed
|
||||
|
||||
- Crash if trying to view feeds list before any feeds have been set up
|
||||
|
||||
## v1.4.0
|
||||
|
||||
### Added
|
||||
|
||||
- Support for posting links from multiple feeds
|
||||
- Tagging of separate roles for each feed being checked
|
||||
|
||||
### Updated
|
||||
|
||||
- Updated bot connection code to use my discord-bot-wrapper
|
||||
|
||||
### Removed
|
||||
|
||||
- !logsplease command removed as the OTT logging was just being annoying
|
||||
|
||||
## v1.3.2
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed list posting channel messages being ignored
|
||||
|
||||
## v1.3.1
|
||||
|
||||
### Fixed
|
||||
|
||||
- Developer commands can now be used from any channel or PM
|
||||
|
||||
## v1.3.0
|
||||
|
||||
### Added
|
||||
|
||||
- Deletion of "You have successfully subscribed" messages after a short delay (configurable)
|
||||
- 'Developer' commands that can only be accessed by specified users
|
||||
- !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
|
||||
|
||||
## v1.2.1
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed multiple users being unsubscribed when one user unsubscribes
|
||||
|
||||
## 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
|
||||
|
||||
### Updated
|
||||
- Updated reconnect logic to hopefully be more stable
|
||||
|
||||
## v1.1.1
|
||||
|
||||
### Added
|
||||
- Reconnect timer to repeatedly try reconnect at intervals
|
||||
|
||||
### Updated
|
||||
|
||||
- Updated support for https conversion to http to hopefully be more consistent
|
||||
|
||||
## v1.1.0
|
||||
|
||||
### Added
|
||||
|
||||
- Added togglable YouTube mode
|
||||
- Converts full URLs to YouTube share URLs
|
||||
- Checks against both YouTube full and share URLs to ensure same video not posted twice
|
||||
|
|
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
|
||||
|
||||
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
|
||||
|
||||
`@RSS_Bot add-feed <url> <#channel> [@role]`
|
||||
`@RSS Bot add-feed <url> <#channel> [@role]`
|
||||
- *url* must be an RSS feed URL
|
||||
- *#channel* must be a channel mention
|
||||
- *@role* must be a role mention (make sure "Anyone can mention this role" is turned on during setup)
|
||||
|
||||
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
|
||||
|
||||
`@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
|
||||
|
||||
### 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
|
||||
|
||||
Example:
|
||||
`@RSS_Bot remove-feed ABc-123dEF`
|
||||
`@RSS Bot remove-feed ABc-123dEF`
|
||||
|
||||
## Permissions
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const Core = require("../../discord-bot-core");
|
||||
const Config = require("../config.json");
|
||||
|
||||
module.exports = new Core.Command({
|
||||
name: "view-feeds",
|
||||
|
@ -12,5 +13,11 @@ function invoke({ message, params, guildData, client }) {
|
|||
if (!guildData)
|
||||
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,
|
||||
"feedCheckIntervalSec": 30
|
||||
"feedCheckIntervalSec": 30,
|
||||
"charLimit": 500,
|
||||
"viewFeedsPaginationLimit": 10
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
//my imports
|
||||
const DiscordUtil = require("../../discord-bot-core").util;
|
||||
|
||||
//external lib imports
|
||||
// @ts-ignore
|
||||
const Config = require("../config.json");
|
||||
const Dns = require("dns"); //for host resolution checking
|
||||
const Url = require("url"); //for url parsing
|
||||
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) {
|
||||
const channel = guild.channels.get(this.channelID);
|
||||
|
||||
|
@ -53,7 +52,7 @@ module.exports = class FeedData {
|
|||
});
|
||||
}
|
||||
|
||||
/**@param param */
|
||||
/**@param guild */
|
||||
fetchLatest(guild) {
|
||||
Dns.resolve(Url.parse(this.url).host || "", err => {
|
||||
if (err)
|
||||
|
@ -100,7 +99,7 @@ function formatPost(article) {
|
|||
if (article.title)
|
||||
message += `\n**${article.title}**`;
|
||||
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)
|
||||
message += `\n\n${normaliseUrl(article.link)}`;
|
||||
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}`); });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} json
|
||||
* @param {*} guildDataModel
|
||||
*/
|
||||
fromJSON(json) {
|
||||
const guildsData = Object.keys(json);
|
||||
guildsData.forEach(guildID => {
|
||||
|
|
|
@ -4,7 +4,6 @@ const ParentPackageJSON = require("../package.json");
|
|||
// @ts-ignore
|
||||
const InternalConfig = require("./internal-config.json");
|
||||
|
||||
/**@param param*/
|
||||
function handleMessage(client, message, commands, guildData) {
|
||||
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
|
||||
|
@ -33,7 +32,6 @@ function handleMessage(client, message, commands, guildData) {
|
|||
});
|
||||
}
|
||||
|
||||
/**@param param*/
|
||||
function handleInternalCommand(message, split, commands, isMemberAdmin) {
|
||||
if (!split[1])
|
||||
return;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"main": "app/index.js",
|
||||
"scripts": {
|
||||
"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": {
|
||||
"discord.js": "11.2.0",
|
||||
|
|
Loading…
Reference in New Issue