depricate mtwitter in favour of mfeed twitter

This commit is contained in:
hgw 2023-10-02 02:11:26 +00:00
parent fff1de85ff
commit d0e5a5140d
4 changed files with 18 additions and 4 deletions

View File

@ -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

10
bot.js
View File

@ -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

View File

@ -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);
}

View File

@ -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)