Add feed deletion & better help menus
This commit is contained in:
parent
cebfcfe272
commit
dba5b2ecf1
8
bot.js
8
bot.js
@ -71,10 +71,14 @@ function openPostWorker(chan, command, d1, d2, d3, d4, d5, d6) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function help(chan, sub) {
|
async function help(chan, sub) {
|
||||||
|
var sub = sub.toLowerCase()
|
||||||
openPostWorker(chan, 'help', sub)
|
openPostWorker(chan, 'help', sub)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function opt(chan, user, setting, setting2, value, value2) {
|
async function opt(chan, user, setting, setting2, value, value2) {
|
||||||
|
if (setting == undefined && setting2 == undefined && value == undefined && value2 == undefined) {
|
||||||
|
openPostWorker(chan, 'help', 'opt')
|
||||||
|
}
|
||||||
if (setting == 'operset' || setting == "get") {
|
if (setting == 'operset' || setting == "get") {
|
||||||
await checkUserHostmask(user)
|
await checkUserHostmask(user)
|
||||||
}
|
}
|
||||||
@ -163,8 +167,12 @@ bot.addListener('message', function(nick, to, text, from) {
|
|||||||
} else if (command === config.irc.prefix+'twitter') {
|
} else if (command === config.irc.prefix+'twitter') {
|
||||||
twitter(to, args[1], args[2])
|
twitter(to, args[1], args[2])
|
||||||
} else if (command === config.irc.prefix+'opt') {
|
} else if (command === config.irc.prefix+'opt') {
|
||||||
|
if (args[1] == undefined ) {
|
||||||
|
help(to, "opt")
|
||||||
|
} else {
|
||||||
opt(to, nick, args[1], args[2], args[3], args[4])
|
opt(to, nick, args[1], args[2], args[3], args[4])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
msgTimeout.add(to);
|
msgTimeout.add(to);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
msgTimeout.delete(to);
|
msgTimeout.delete(to);
|
||||||
|
@ -40,6 +40,11 @@ function errorMessage(error, code, extra) {
|
|||||||
|
|
||||||
async function help(sub) {
|
async function help(sub) {
|
||||||
content = [];
|
content = [];
|
||||||
|
if ( config.irc.prefix == undefined ) {
|
||||||
|
var prefix = 'm!'
|
||||||
|
} else {
|
||||||
|
var prefix = config.irc.prefix
|
||||||
|
}
|
||||||
if (sub === undefined) {
|
if (sub === undefined) {
|
||||||
var sub = "default"
|
var sub = "default"
|
||||||
}
|
}
|
||||||
@ -63,19 +68,28 @@ async function help(sub) {
|
|||||||
consoleLog('[help.default] Logo disabled, not including in output')
|
consoleLog('[help.default] Logo disabled, not including in output')
|
||||||
}
|
}
|
||||||
content.push('Mercury RSS Client - https://git.supernets.org/hgw/mercury')
|
content.push('Mercury RSS Client - https://git.supernets.org/hgw/mercury')
|
||||||
content.push(config.irc.prefix+'feed [USER/FEED/ALIAS] [ENTRIES(opt)] - Return the last x amount of entries from any RSS feed + more (see m!help feed)')
|
content.push(prefix+'feed [USER/FEED/ALIAS] [ENTRIES(opt)] - Return the last x amount of entries from any RSS feed + more (see m!help feed)')
|
||||||
content.push(config.irc.prefix+"opt [CATEGORY] [OPTION] [VALUE] - Control bot options, see wiki for info on usage.")
|
content.push(prefix+"opt [CATEGORY] [OPTION] [VALUE] - Control bot options, see wiki for info on usage.")
|
||||||
content.push(config.irc.prefix+'help [COMMAND(opt)] - Brings up this dialogue or instructions for a specific command if specified')
|
content.push(prefix+'help [COMMAND(opt)] - Brings up this dialogue or instructions for a specific command if specified')
|
||||||
content.push('Help shown here may not be comprehensive, more detailed documentation is available on the repository.')
|
content.push('Help shown here may not be comprehensive, more detailed documentation is available on the repository.')
|
||||||
sendUpstream(content)
|
sendUpstream(content)
|
||||||
}
|
}
|
||||||
if (sub === "feed") {
|
if (sub === "feed") {
|
||||||
content.push(config.irc.prefix+'feed Help')
|
content.push(prefix+'feed Help Menu')
|
||||||
content.push(config.irc.prefix+'feed [URL] [ENTRIES (opt)] - Last entries from any valid RSS feed URL.')
|
content.push(prefix+'feed [URL] [ENTRIES (opt)] - Last entries from any valid RSS feed URL.')
|
||||||
content.push(config.irc.prefix+'feed twitter/[USERNAME] [ENTRIES (opt)] - Last tweets from any X/Twitter account.')
|
content.push(prefix+'feed twitter/[USERNAME] [ENTRIES (opt)] - Last tweets from any X/Twitter account.')
|
||||||
content.push(config.irc.prefix+'feed github/[USER]/[REPO]/[MODE (opt)] [ENTRIES (opt)] - Last commits/releases from any repo. Mode can be "commits" or "releases"')
|
content.push(prefix+'feed github/[USER]/[REPO]/[MODE (opt)] [ENTRIES (opt)] - Last commits/releases from any repo. Mode can be "commits" or "releases"')
|
||||||
content.push(config.irc.prefix+'feed me OR [NICK] - Your own personalised RSS feed, see repo for configuration')
|
content.push(prefix+'feed me OR [NICK] - Your own personalised RSS feed, see repo for configuration')
|
||||||
content.push(config.irc.prefix+'feed [ALIAS] [ENTRIES(opt)] - Last entries from a feed associated with a set alias, repo for configuration')
|
content.push(prefix+'feed [ALIAS] [ENTRIES(opt)] - Last entries from a feed associated with a set alias, repo for configuration')
|
||||||
|
sendUpstream(content)
|
||||||
|
}
|
||||||
|
if (sub === "opt") {
|
||||||
|
content.push(prefix+'opt Help Menu')
|
||||||
|
content.push(prefix+'opt feed - Modify user feed settings, run \"'+prefix+'opt feed\" for more details')
|
||||||
|
content.push(prefix+'opt alias - Modify aliases, run \"'+prefix+'opt alias\" for more details')
|
||||||
|
content.push(prefix+'opt set - Modify user bot settings, run \"'+prefix+'opt set\" for more details')
|
||||||
|
content.push(prefix+'opt get - Displays specific bot setting')
|
||||||
|
content.push(prefix+'opt operset - Modify global bot settings (ADMIN)')
|
||||||
sendUpstream(content)
|
sendUpstream(content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,12 @@ function errorMessage(error, code, extra) {
|
|||||||
process.exit()
|
process.exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function arrayRemove(array, value) {
|
||||||
|
return array.filter(function (o) {
|
||||||
|
return o != value;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function testFeed(feedURL) {
|
async function testFeed(feedURL) {
|
||||||
try {
|
try {
|
||||||
consoleLog('[options.testFeed] Testing '+feed)
|
consoleLog('[options.testFeed] Testing '+feed)
|
||||||
@ -67,8 +73,20 @@ async function testFeed(feedURL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function feed(nick, setting, value) {
|
async function feed(nick, setting, value) {
|
||||||
|
if (setting == undefined ) {
|
||||||
|
content = []
|
||||||
|
content.push(config.irc.prefix+'opt feed Help Menu')
|
||||||
|
content.push(config.irc.prefix+'opt feed add [VALUE] - Adds a valid RSS feed URL to your feed list')
|
||||||
|
content.push(config.irc.prefix+'opt feed del [VALUE] - Removes any existing RSS feed from your feed list')
|
||||||
|
content.push(config.irc.prefix+'opt feed list - Lists all of the exiting feeds in your feed list')
|
||||||
|
var output = content.join("\n")
|
||||||
|
sendUpstream(output)
|
||||||
|
}
|
||||||
|
if (setting != undefined ) {
|
||||||
|
var setting = setting.toLowerCase()
|
||||||
|
}
|
||||||
if (setting === 'add') {
|
if (setting === 'add') {
|
||||||
consoleLog('[options.feed] '+nick+' is adding '+value)
|
consoleLog('[options.feed] '+nick+' is adding feed entry: '+value)
|
||||||
await testFeed(value);
|
await testFeed(value);
|
||||||
var file = editJsonFile('/home/node/app/config/usersettings.json');
|
var file = editJsonFile('/home/node/app/config/usersettings.json');
|
||||||
try {
|
try {
|
||||||
@ -85,6 +103,18 @@ async function feed(nick, setting, value) {
|
|||||||
sendUpstream(value + ' added to your feed list')
|
sendUpstream(value + ' added to your feed list')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (setting === "del") {
|
||||||
|
consoleLog('[options.feed] '+nick+' is removing feed entry: '+value)
|
||||||
|
var array = uconfig[nick].feeds
|
||||||
|
var file = editJsonFile('/home/node/app/config/usersettings.json');
|
||||||
|
if (array.includes(value) == false ) {
|
||||||
|
sendUpstream(errorMsg+' '+value+' is not saved in your feed list')
|
||||||
|
}
|
||||||
|
var newArray = arrayRemove(array, value)
|
||||||
|
file.set(nick+'.feeds', newArray)
|
||||||
|
file.save();
|
||||||
|
sendUpstream('Feed entry removed ('+value+' ==> BTFO\'d)')
|
||||||
|
}
|
||||||
if (setting === 'list') {
|
if (setting === 'list') {
|
||||||
content = [];
|
content = [];
|
||||||
try {
|
try {
|
||||||
@ -103,6 +133,18 @@ async function feed(nick, setting, value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function alias(setting, value, url, nick) {
|
async function alias(setting, value, url, nick) {
|
||||||
|
if (setting == undefined ) {
|
||||||
|
content = []
|
||||||
|
content.push(config.irc.prefix+'opt alias Help Menu')
|
||||||
|
content.push(config.irc.prefix+'opt alias add [ALIAS] [URL] - Adds an alias for any valid RSS feed')
|
||||||
|
content.push(config.irc.prefix+'opt alias del [ALIAS] [URL] - Removes an alias')
|
||||||
|
content.push(config.irc.prefix+'opt alias list - Lists all of your existing alises')
|
||||||
|
var output = content.join("\n")
|
||||||
|
sendUpstream(output)
|
||||||
|
}
|
||||||
|
if (setting != undefined ) {
|
||||||
|
var setting = setting.toLowerCase()
|
||||||
|
}
|
||||||
if (setting === 'add') {
|
if (setting === 'add') {
|
||||||
var value = value.toUpperCase()
|
var value = value.toUpperCase()
|
||||||
consoleLog('[options.alias] Adding/editing an alias for'+nick+': '+value+' ==> '+url)
|
consoleLog('[options.alias] Adding/editing an alias for'+nick+': '+value+' ==> '+url)
|
||||||
@ -222,8 +264,8 @@ async function operset(setting, value, value2, hostmask) {
|
|||||||
|
|
||||||
if (setting === 'feed') {
|
if (setting === 'feed') {
|
||||||
feed(user, setting2, value);
|
feed(user, setting2, value);
|
||||||
} else if (setting === 'list') {
|
//} else if (setting === 'list') {
|
||||||
feed(user, setting2)
|
// feed(user, setting2)
|
||||||
} else if (setting === 'get') {
|
} else if (setting === 'get') {
|
||||||
get(setting2, hostmask, user);
|
get(setting2, hostmask, user);
|
||||||
} else if(setting === 'alias') {
|
} else if(setting === 'alias') {
|
||||||
|
Loading…
Reference in New Issue
Block a user