From d0e5a5140d62bd1c19b03f3e4d35ec79c3791bac Mon Sep 17 00:00:00 2001 From: hgw Date: Mon, 2 Oct 2023 02:11:26 +0000 Subject: [PATCH] depricate mtwitter in favour of mfeed twitter --- README.md | 1 - bot.js | 10 ++++++++++ commands/{twitter.js => feed-predef.js} | 10 ++++++++-- commands/help.js | 1 - 4 files changed, 18 insertions(+), 4 deletions(-) rename commands/{twitter.js => feed-predef.js} (96%) diff --git a/README.md b/README.md index ae5df8f..094fc83 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ This bot is not completed, expect bugs/crashes/errors. Use in production is disa ## Commands - `m!feed [USER/FEED/ALIAS] [ENTRIES]` - Return the last x amount of entries from any RSS feed or your own saved feeds (if you have saved feeds) -- `m!twitter [USER] [ENTRIES]` - Return the last x amount of tweets from a particular user. - `m!opt [CATEGORY] [OPTION] [VALUE]` - Control bot options, see wiki for info on usage. ## Deployment diff --git a/bot.js b/bot.js index a6acb2b..106ec89 100644 --- a/bot.js +++ b/bot.js @@ -67,6 +67,9 @@ async function opt(chan, user, setting, setting2, value, value2) { async function feed(chan, nick, provfeed, n) { var userconf = fs.readFileSync('./config/usersettings.json') var uconfig = JSON.parse(userconf) + var provfeed = provfeed.toLowerCase() + var predefinedFeeds = ['twitter', 'github'] + var predefString = provfeed.split("/") if (provfeed === undefined) { consoleLog('[bot.feed] No feed provided') bot.say(chan, errorMsg+" No feed has been provided.") @@ -79,9 +82,16 @@ async function feed(chan, nick, provfeed, n) { consoleLog('[bot.feed] no amount was passed, reverting to default') var n = config.feed.default_amount; } + if (isValidUrl(provfeed) === true) { //URL Lookup consoleLog('[bot.feed] Valid URL requested') openPostWorker(chan, 'feed-preset', provfeed, n); + + } else if (predefinedFeeds.includes(predefString[0])) { + console.log(predefString[0]) + //bot.say(chan, "Should work good") + openPostWorker(chan, "feed-predef", provfeed, n) + } else if (provfeed === nick) { //User Feed Lookup consoleLog('[bot.feed] User feed requested') if ( uconfig[nick] !== undefined ) { //If users nickname exists in json file diff --git a/commands/twitter.js b/commands/feed-predef.js similarity index 96% rename from commands/twitter.js rename to commands/feed-predef.js index 6bfeb8f..f76aab0 100644 --- a/commands/twitter.js +++ b/commands/feed-predef.js @@ -46,7 +46,7 @@ function errorMessage(error, code, extra) { process.exit() } -async function fetchFeed(feedURL, n) { +async function twitter(feedURL, n) { var content = []; consoleLog('[twitter.fetchFeed] fetching @'+feedURL) @@ -114,4 +114,10 @@ async function fetchFeed(feedURL, n) { sendUpstream(content); } -fetchFeed(provfeed, n); +var provfeed = provfeed.toLowerCase().split("/") +if (provfeed[0] == "twitter") { + twitter(provfeed[1], n); +} + + + diff --git a/commands/help.js b/commands/help.js index 441e42d..1b572e0 100644 --- a/commands/help.js +++ b/commands/help.js @@ -65,7 +65,6 @@ async function help(sub) { } content.push('Mercury RSS Client - https://git.supernets.org/hgw/mercury') content.push('m!feed [USER/FEED/ALIAS] [ENTRIES] - Return the last x amount of entries from any RSS feed or your own saved feeds (if you have saved feeds)') - content.push("m!twitter [USER] [ENTRIES] - Return the last x amount of tweets from a particular user") content.push("m!opt [CATEGORY] [OPTION] [VALUE] - Control bot options, see wiki for info on usage.") content.push('m!help - Brings up this dialogue') sendUpstream(content)