Merge pull request #111 from v0idp/develop

Develop
This commit is contained in:
void*
2020-02-16 17:37:33 +01:00
committed by GitHub
19 changed files with 146 additions and 149 deletions

View File

@@ -1 +1 @@
{"general":{"username":"mellow","password":"$2a$10$hKxfwH5lKDxogjIPKR.9mOJi664EQ298OYiRt/HuqVjSHw8BRKEya"},"bot":{"token":"","ownerid":"","commandprefix":"","channelname":"","deletecommandmessages":"false","unknowncommandresponse":"false","defaultservice":"ombi","requesttv":"","requestmovie":""},"ombi":{"host":"","port":"","baseurl":"","apikey":"","ssl":"false","username":""},"tautulli":{"host":"","port":"","baseurl":"","apikey":"","ssl":"false"},"sonarr":{"host":"","port":"","baseurl":"","apikey":"","ssl":"false","profile":"0","profileanime":"0","rootfolder":"","rootfolderanime":"","languageprofile":"0","seasonfolders":"false","v3":"false"},"radarr":{"host":"","port":"","baseurl":"","apikey":"","ssl":"false","profile":"0","rootfolder":"","minimumavailability":"Announced"}}
{"general":{"username":"mellow","password":"$2a$10$hKxfwH5lKDxogjIPKR.9mOJi664EQ298OYiRt/HuqVjSHw8BRKEya"},"bot":{"token":"","ownerid":"","commandprefix":"","channelname":"","deletecommandmessages":"false","unknowncommandresponse":"false","defaultservice":"ombi","requesttv":"","requestmovie":"","admin":"","selection":"emoji"},"ombi":{"host":"","port":"","baseurl":"","apikey":"","ssl":"false","username":""},"tautulli":{"host":"","port":"","baseurl":"","apikey":"","ssl":"false"},"sonarr":{"host":"","port":"","baseurl":"","apikey":"","ssl":"false","profile":"0","profileanime":"0","rootfolder":"","rootfolderanime":"","languageprofile":"0","seasonfolders":"false","v3":"false"},"radarr":{"host":"","port":"","baseurl":"","apikey":"","ssl":"false","profile":"0","rootfolder":"","minimumavailability":"Announced"}}

View File

@@ -7,6 +7,7 @@ module.exports = class Radarr {
"/movie" : getURL(config.host, config.port, config.ssl, config.baseurl + `/api/movie?apikey=${config.apikey}`),
"/movie/id" : getURL(config.host, config.port, config.ssl, config.baseurl + `/api/movie/%ID%?apikey=${config.apikey}`),
"/movie/lookup" : getURL(config.host, config.port, config.ssl, config.baseurl + `/api/movie/lookup?term=%NAME%&apikey=${config.apikey}`),
"/movie/lookup/tmdb" : getURL(config.host, config.port, config.ssl, config.baseurl + `/api/movie/lookup/tmdb?tmdbId=%NAME%&apikey=${config.apikey}`),
"/profile" : getURL(config.host, config.port, config.ssl, config.baseurl + `/api/profile?apikey=${config.apikey}`),
"/rootfolder" : getURL(config.host, config.port, config.ssl, config.baseurl + `/api/rootfolder?apikey=${config.apikey}`),
"/system/status" : getURL(config.host, config.port, config.ssl, config.baseurl + `/api/system/status?apikey=${config.apikey}`)
@@ -59,14 +60,22 @@ module.exports = class Radarr {
movieLookup(name) {
return new Promise((resolve, reject) => {
let endpoint = '/movie/lookup';
let search = name;
if (name.startsWith('tmdb:')) {
endpoint += '/tmdb';
search = name.replace('tmdb:', '');
}
get({
headers: {'accept' : 'application/json',
'User-Agent': `Mellow/${process.env.npm_package_version}`},
url: replacePlaceholders(this.endpoints['/movie/lookup'], { "%NAME%":encodeURI(name) })
url: replacePlaceholders(this.endpoints[endpoint], { "%NAME%":encodeURI(search) })
}).then(({response, body}) => {
if (response.statusCode === 200) {
const data = JSON.parse(body);
resolve(data);
if (data.length !== 0) resolve(data);
else reject(response);
}
else {
console.log(response);

View File

@@ -4,13 +4,13 @@ const DiscordBot = require('./discord/DiscordBot.js');
module.exports = class BotHandler {
constructor (webDatabase) {
this.db = webDatabase;
this.api = new APIHandler(webDatabase.getConfig());
this.api = new APIHandler(webDatabase.config);
this.bots = [];
}
init() {
return new Promise((resolve) => {
const bot = this.db.webConfig.bot;
const bot = this.db.config.bot;
if (bot && bot.token) {
new DiscordBot(this.db, this.api, bot.token).init(bot.token, bot.commandprefix).then((discordBot) => {
this.bots.push(discordBot);

View File

@@ -21,7 +21,7 @@ module.exports = class searchMovieCommand {
}
async run (msg, args) {
const config = this.client.db.webConfig;
const config = this.client.db.config;
const searchQuery = args.join(' ');
if (config.bot.defaultservice === 'ombi') {

View File

@@ -21,7 +21,7 @@ module.exports = class searchTVShowCommand {
}
async run (msg, args) {
const config = this.client.db.webConfig;
const config = this.client.db.config;
const searchQuery = args.join(' ');
if (config.bot.defaultservice === 'ombi') {

View File

@@ -32,15 +32,36 @@ module.exports = class DiscordBot extends Discord.Client {
awaitSelection (msg, resultMsg, length) {
return new Promise(async (resolve, reject) => {
const limit = (length <= 10) ? length : 10;
const emojis = ['0⃣', '1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣'];
for (let i = 0; i < limit; i++) await resultMsg.react(emojis[i]);
resultMsg.awaitReactions((reaction, user) => emojis.includes(reaction.emoji.name) && user.id === msg.author.id, { max: 1, time: 120000 })
.then((collected) => {
if (collected.first()) resolve(emojis.indexOf(collected.first().emoji.name));
}).catch(() => {
reject(-1);
});
if (this.config.selection === 'emoji') {
const limit = (length <= 10) ? length : 10;
const emojis = ['0⃣', '1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣'];
for (let i = 0; i < limit; i++) await resultMsg.react(emojis[i]);
resultMsg.awaitReactions((reaction, user) => emojis.includes(reaction.emoji.name) && user.id === msg.author.id, { max: 1, time: 120000 })
.then((collected) => {
resultMsg.delete();
if (collected.first()) resolve(emojis.indexOf(collected.first().emoji.name));
}).catch(() => {
resolve(-1);
});
}
else {
resultMsg.channel.awaitMessages(m => (!isNaN(parseInt(m.content)) || m.content.startsWith('cancel')) && m.author.id == msg.author.id, { max: 1, time: 120000, errors: ['time'] })
.then((collected) => {
let message = collected.first().content;
let selection = parseInt(message);
resultMsg.delete();
if (collected.first().deletable) collected.first().delete();
if (message.startsWith('cancel')) {
return this.reply(msg, 'Cancelled command.');
}
else if (selection >= 0 && selection <= length)
resolve(selection);
else
resolve(-1);
}).catch(() => {
reject(-1);
})
}
});
}
@@ -80,7 +101,7 @@ module.exports = class DiscordBot extends Discord.Client {
const commandName = file.split(".")[0];
const command = new commandFunction(this);
if (command.options.group && !groups.includes(command.options.group)) return;
if (command.options.group && (!this.db.webConfig[command.options.group].host || !this.db.webConfig[command.options.group].apikey)) return;
if (command.options.group && (!this.db.config[command.options.group].host || !this.db.config[command.options.group].apikey)) return;
if (command.options.aliases) command.options.aliases.forEach((alias) => this.commands[alias] = command);
this.commands[commandName] = command;
});
@@ -103,7 +124,7 @@ module.exports = class DiscordBot extends Discord.Client {
init () {
return new Promise((resolve, reject) => {
try {
this.config = this.db.webConfig['bot'];
this.config = this.db.config['bot'];
this.config.commandprefix = this.config.commandprefix || "-";
this.registerEvents();

View File

@@ -89,7 +89,7 @@ const buildOmbiSeriesEmbed = function(msg, series) {
return seriesEmbed;
}
const buildOmbiMovieResults = function(data) {
const buildOmbiMovieResults = function(selection, data) {
let fieldContent = '';
for (let i = 0; i < data.length; i++) {
if (fieldContent.length > 896) break;
@@ -100,13 +100,13 @@ const buildOmbiMovieResults = function(data) {
let dataEmbed = new Discord.RichEmbed()
dataEmbed.setTitle('Ombi Movie Search')
.setDescription('Please select one of the search results. **Wait for the reactions to finish!**')
.setDescription(`Please select one of the search results. ${(selection === 'emoji') ? '**Wait for the reactions to finish!**' : 'To abort answer **cancel**'}`)
.addField('__Search Results__', fieldContent);
return dataEmbed;
}
const buildOmbiSeriesResults = function(data) {
const buildOmbiSeriesResults = function(selection, data) {
let fieldContent = '';
for (let i = 0; i < data.length; i++) {
if (fieldContent.length > 896) break;
@@ -117,7 +117,7 @@ const buildOmbiSeriesResults = function(data) {
let dataEmbed = new Discord.RichEmbed();
dataEmbed.setTitle('Ombi Series Search')
.setDescription('Please select one of the search results. **Wait for the reactions to finish!**')
.setDescription(`Please select one of the search results. ${(selection === 'emoji') ? '**Wait for the reactions to finish!**' : 'To abort answer **cancel**'}`)
.addField('__Search Results__', fieldContent);
return dataEmbed;
@@ -143,7 +143,7 @@ const buildSonarrSeriesEmbed = function(msg, series) {
return seriesEmbed;
}
const buildSonarrSeriesResults = function(data) {
const buildSonarrSeriesResults = function(selection, data) {
let fieldContent = '';
const limit = (data.length <= 10) ? data.length : 10;
for (let i = 0; i < limit; i++) {
@@ -155,7 +155,7 @@ const buildSonarrSeriesResults = function(data) {
let seriesEmbed = new Discord.RichEmbed();
seriesEmbed.setTitle('Sonarr Series Search')
.setDescription('Please select one of the search results. **Wait for the reactions to finish!**')
.setDescription(`Please select one of the search results. ${(selection === 'emoji') ? '**Wait for the reactions to finish!**' : 'To abort answer **cancel**'}`)
.addField('__Search Results__', fieldContent);
return seriesEmbed;
@@ -167,7 +167,6 @@ const buildRadarrMovieEmbed = function(msg, movie) {
.setDescription(movie.overview.substr(0, 250) + '(...)')
.setFooter(msg.author.username, `https://cdn.discordapp.com/avatars/${msg.author.id}/${msg.author.avatar}.png`)
.setTimestamp(new Date())
.setImage(movie.remotePoster)
.setURL('https://www.themoviedb.org/movie/' + movie.tmdbId)
.attachFile(path.join(__dirname, '..', '..', 'resources', 'tmdb.png'))
.setThumbnail('attachment://tmdb.png')
@@ -177,10 +176,13 @@ const buildRadarrMovieEmbed = function(msg, movie) {
if (movie.doesExist) movieEmbed.addField('__Added__', '✅', true);
if (movie.remotePoster) movieEmbed.setImage(movie.remotePoster);
else if (movie.images && movie.images[0].coverType === 'poster') movieEmbed.setImage(movie.images[0].url);
return movieEmbed;
}
const buildRadarrMovieResults = function(data) {
const buildRadarrMovieResults = function(selection, data) {
let fieldContent = '';
const limit = (data.length <= 10) ? data.length : 10;
for (let i = 0; i < limit; i++) {
@@ -192,7 +194,7 @@ const buildRadarrMovieResults = function(data) {
let movieEmbed = new Discord.RichEmbed();
movieEmbed.setTitle('Radarr Movie Search')
.setDescription('Please select one of the search results. **Wait for the reactions to finish!**')
.setDescription(`Please select one of the search results. ${(selection === 'emoji') ? '**Wait for the reactions to finish!**' : 'To abort answer **cancel**'}`)
.addField('__Search Results__', fieldContent);
return movieEmbed;

View File

@@ -1,6 +1,7 @@
exports.run = async (client, msg) => {
if (msg.author.bot) return;
if (msg.channel.type !== 'dm' && client.config.channelname !== "" && msg.channel.name.toLowerCase() !== client.config.channelname.toLowerCase()) return;
if (msg.channel.type !== 'dm' && client.config.channelname !== "")
if (msg.channel.name.toLowerCase() !== client.config.channelname.toLowerCase()) return;
if (msg.channel.type !== 'dm' && !msg.content.trim().replace(/ /g, '').startsWith(client.config.commandprefix)) return;
let args = msg.content.split(/ +/);
@@ -10,7 +11,7 @@ exports.run = async (client, msg) => {
if (!client.commands[command])
if (client.config.unknowncommandresponse === 'true')
return client.reply(`Unknown command. Use ${client.config.commandprefix}help to view the commands list!`);
return client.reply(msg, `Unknown command. Use ${client.config.commandprefix}help to view the commands list!`);
else return;
if (msg.channel.type !== 'text' && client.commands[command].guildOnly) return;

View File

@@ -24,10 +24,8 @@ module.exports = class OmbiService {
return new Promise((resolve) => {
this.client.api.ombi.searchTVShow(searchQuery).then(async (data) => {
if (data.length > 1) {
const aMsg = await this.client.send(msg, this.client.builder.buildOmbiSeriesResults(data));
const aMsg = await this.client.send(msg, this.client.builder.buildOmbiSeriesResults(this.client.config.selection, data));
const selection = await this.client.awaitSelection(msg, aMsg, data.length);
aMsg.delete();
if (selection !== -1) {
resolve(data[selection].id);
} else {
@@ -92,10 +90,8 @@ module.exports = class OmbiService {
return new Promise((resolve) => {
this.client.api.ombi.searchMovie(searchQuery).then(async (data) => {
if (data.length > 1) {
const aMsg = await this.client.send(msg, this.client.builder.buildOmbiMovieResults(data));
const aMsg = await this.client.send(msg, this.client.builder.buildOmbiMovieResults(this.client.config.selection, data));
const selection = await this.client.awaitSelection(msg, aMsg, data.length);
aMsg.delete();
if (selection !== -1) {
resolve(data[selection].id);
} else {

View File

@@ -1,71 +1,5 @@
const buildRadarrMovie = require('../../api/helpers/radarr.js');
const movieLookup = async (client, msg, args) => {
return new Promise((resolve, reject) => {
client.API.radarr.movieLookup(args.name).then((data) => {
if (data.length > 1) {
let fieldContent = '';
let count = 0;
for (let i = 0; i < data.length; i++) {
if (fieldContent.length > 896) break;
fieldContent += `${i+1}) ${data[i].title} `;
fieldContent += `(${data[i].year}) `;
fieldContent += `[[TheMovieDb](https://www.themoviedb.org/movie/${data[i].tmdbId})]\n`;
count++;
}
let movieEmbed = new Discord.MessageEmbed();
movieEmbed.setTitle('Radarr Movie Search')
.setDescription('Please select one of the search results. To abort answer **cancel**')
.addField('__Search Results__', fieldContent);
const aMsg = msg.embed(movieEmbed);
msg.channel.awaitMessages(m => (!isNaN(parseInt(m.content)) || m.content.startsWith('cancel')) && m.author.id == msg.author.id, { max: 1, time: 120000, errors: ['time'] })
.then((collected) => {
let message = collected.first().content;
let selection = parseInt(message);
aMsg.then((m) => m.delete());
if (collected.first().deletable) collected.first().delete();
if (message.startsWith('cancel')) {
reject('Cancelled command.');
} else if (selection > 0 && selection <= count) {
client.API.radarr.movieLookup(`tmdb:${data[selection - 1].tmdbId}`).then((oMovie) => {
doesMovieExist(client, oMovie[0].tmdbId).then((status) => {
Object.assign(oMovie[0], { doesExist: status });
resolve(oMovie[0]);
}).catch(() => {
reject('There was an error in checking for movie availability.');
});
}).catch(() => {
reject('Something went wrong! Couldn\'t find movie.');
});
} else {
reject('Please enter a valid selection!');
}
}).catch(() => {
reject('Cancelled command.');
});
} else if (!data.length) {
reject('Something went wrong! Couldn\'t find any movie.');
} else {
client.API.radarr.movieLookup(`tmdb:${data[0].tmdbId}`).then((oMovie) => {
doesMovieExist(client, oMovie[0].tmdbId).then((status) => {
Object.assign(oMovie[0], { doesExist: status });
resolve(oMovie[0]);
}).catch(() => {
reject('There was an error in checking for movie availability.');
})
}).catch(() => {
reject('Something went wrong! Couldn\'t find movie.');
});
}
}).catch(() => {
reject('Something went wrong! Couldn\'t find any movie.');
});
});
}
module.exports = class SonarrService {
constructor (client) {
this.client = client;
@@ -89,16 +23,13 @@ module.exports = class SonarrService {
return new Promise((resolve, reject) => {
this.client.api.radarr.movieLookup(searchQuery).then(async (data) => {
if (data.length > 1) {
const aMsg = await this.client.send(msg, this.client.builder.buildRadarrMovieResults(data));
const aMsg = await this.client.send(msg, this.client.builder.buildRadarrMovieResults(this.client.config.selection, data));
const selection = await this.client.awaitSelection(msg, aMsg, data.length);
aMsg.delete();
if (selection !== -1) {
this.client.api.radarr.movieLookup(`tmdb:${data[selection].tmdbId}`).then((oMovie) => {
this.doesMovieExist(oMovie[0].tmdbId).then((status) => {
Object.assign(oMovie[0], { doesExist: status });
resolve(oMovie[0]);
this.doesMovieExist(oMovie.tmdbId).then((status) => {
Object.assign(oMovie, { doesExist: status });
resolve(oMovie);
}).catch(() => {
reject('There was an error in checking for movie availability.');
});
@@ -112,9 +43,9 @@ module.exports = class SonarrService {
reject('Something went wrong! Couldn\'t find any movie.');
} else {
this.client.api.radarr.movieLookup(`tmdb:${data[0].tmdbId}`).then((oMovie) => {
this.doesMovieExist(oMovie[0].tmdbId).then((status) => {
Object.assign(oMovie[0], { doesExist: status });
resolve(oMovie[0]);
this.doesMovieExist(oMovie.tmdbId).then((status) => {
Object.assign(oMovie, { doesExist: status });
resolve(oMovie);
}).catch(() => {
reject('There was an error in checking for movie availability.');
})
@@ -129,7 +60,7 @@ module.exports = class SonarrService {
}
addMovie(msg, msgEmbed, movie) {
const newMovie = buildRadarrMovie(movie, this.client.db.webConfig['radarr'], true);
const newMovie = buildRadarrMovie(movie, this.client.db.config['radarr'], true);
if (typeof newMovie === "string") {
return this.client.reply(msg, newMovie);
}

View File

@@ -9,10 +9,8 @@ module.exports = class SonarrService {
return new Promise((resolve, reject) => {
this.client.api.sonarr.seriesLookup(searchQuery).then(async (data) => {
if (data.length > 1) {
const aMsg = await this.client.send(msg, this.client.builder.buildSonarrSeriesResults(data));
const aMsg = await this.client.send(msg, this.client.builder.buildSonarrSeriesResults(this.client.config.selection, data));
const selection = await this.client.awaitSelection(msg, aMsg, data.length);
aMsg.delete();
if (selection !== -1) {
resolve(data[selection]);
} else {
@@ -30,7 +28,7 @@ module.exports = class SonarrService {
}
addSeries(msg, msgEmbed, series) {
const newSeries = buildSonarrSeries(series, this.client.db.webConfig['sonarr']);
const newSeries = buildSonarrSeries(series, this.client.db.config['sonarr']);
if (typeof newSeries === "string") {
return this.client.reply(msg, newSeries);
}

View File

@@ -13,7 +13,7 @@ const storeData = (data) => {
module.exports = class Database {
constructor() {
this.webConfig = require(path.join(__dirname, '..', '..', 'data', 'settings.json'));
this.config = require(path.join(__dirname, '..', '..', 'data', 'settings.json'));
}
getConfig() {
@@ -21,7 +21,7 @@ module.exports = class Database {
}
resetConfigTable(table) {
let newWebConfig = this.getConfig();
let newWebConfig = this.config;
for (const key in template[table]) {
newWebConfig[table][key] = template[table][key];
}
@@ -29,7 +29,7 @@ module.exports = class Database {
}
async saveConfig(request) {
let newWebConfig = this.getConfig();
let newWebConfig = this.config;
if (request.originalUrl == '/general') {
const salt = await bcrypt.genSalt(10);
const pwHash = await bcrypt.hash(request.body.password, salt);
@@ -45,6 +45,8 @@ module.exports = class Database {
newWebConfig.bot.defaultservice = request.body.defaultservice;
newWebConfig.bot.requesttv = request.body.requestTV.toLowerCase();
newWebConfig.bot.requestmovie = request.body.requestMovie.toLowerCase();
newWebConfig.bot.admin = request.body.admin.toLowerCase();
newWebConfig.bot.selection = request.body.selection;
} else if (request.originalUrl == '/ombi' && request.body.apiKey != '' && request.body.host != '') {
newWebConfig.ombi.host = request.body.host;
newWebConfig.ombi.port = request.body.port;
@@ -81,6 +83,7 @@ module.exports = class Database {
newWebConfig.radarr.rootfolder = request.body.rootfolder;
newWebConfig.radarr.minimumavailability = request.body.minimumavailability;
}
storeData(newWebConfig);
if (request.body)
storeData(newWebConfig);
}
}

View File

@@ -12,7 +12,9 @@
"unknowncommandresponse": "false",
"defaultservice": "ombi",
"requesttv": "",
"requestmovie": ""
"requestmovie": "",
"admin": "",
"selection": "emoji"
},
"ombi": {
"host": "",

View File

@@ -10,7 +10,7 @@ passport.use('userJwt', new JwtStrategy({
try {
const Database = require('../../database/Database.js');
const webDatabase = new Database();
const { username } = webDatabase.webConfig.general;
const { username } = webDatabase.config.general;
if (username !== payload.user)
return done(null, false, { message: 'username does not exist!'});
done(null, true);

View File

@@ -3,7 +3,7 @@ const Sonarr = require('../../api/sonarr.js');
const Radarr = require('../../api/radarr.js');
const render = async (req, res) => {
const config = req.webserver.WebDatabase.webConfig;
const config = req.webserver.WebDatabase.config;
sonarr = new Sonarr(config['sonarr']);
radarr = new Radarr(config['radarr']);

View File

@@ -19,7 +19,7 @@ const render = async (req, res) => {
const login = async (req, res) => {
const { username, password, rememberme } = req.body;
const general = req.webserver.WebDatabase.getConfig()['general'];
const general = req.webserver.WebDatabase.config['general'];
if (username === general.username && await bcrypt.compare(password, general.password)) {
const token = signToken(username, rememberme);
const dMaxAge = new Date();

View File

@@ -35,16 +35,6 @@
</div>
</div>
<div class="form-group row">
<label for="defaultservice" class=" col-sm-3 col-form-label">Default Service</label>
<div class="col-md-8">
<select name="defaultservice" id="defaultservice" class="form-control defaultservice">
<option value="ombi" <% if (botSettings && botSettings.defaultservice == "ombi") { %>selected<% }%>>Ombi</option>
<option value="sonarradar" <% if (botSettings && botSettings.defaultservice == "sonarradar") { %>selected<% }%>>Sonarr / Radarr</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="deleteCommandMessages" class="col-sm-3 form-check-label">Delete Command Messages</label>
<div class="col-sm-6">
@@ -63,7 +53,7 @@
<div class="form-group row">
<div class="col-md-12 col-form-label">
<small class="form-text text-muted">
Enter the Discord role names. Leave blank if anyone can request.
Enter the Discord role names. Leave blank if anyone can request.
</small>
</div>
</div>
@@ -81,6 +71,50 @@
<input type="text" class="form-control requestmovie" name="requestMovie" value="<% if (botSettings && botSettings.requestmovie) { %><%=botSettings.requestmovie %><% } %>">
</div>
</div>
<div class="form-group row">
<label for="admin" class="col-md-4 col-form-label">Admin</label>
<div class="col-md-8">
<input type="text" class="form-control admin" name="admin" value="<% if (botSettings && botSettings.admin) { %><%=botSettings.admin %><% } %>">
<small class="form-text text-muted">
The name of the admin role for admin commands.
</small>
</div>
</div>
<div class="form-group row">
<div class="col-md-12 col-form-label">
<small class="form-text text-muted">
Bot Behaviors
</small>
</div>
</div>
<div class="form-group row">
<label for="defaultservice" class=" col-sm-4 col-form-label">Default Service</label>
<div class="col-md-8">
<select name="defaultservice" id="defaultservice" class="form-control defaultservice">
<option value="ombi" <% if (botSettings && botSettings.defaultservice === "ombi") { %>selected<% }%>>Ombi</option>
<option value="sonarradar" <% if (botSettings && botSettings.defaultservice === "sonarradar") { %>selected<% }%>>Sonarr / Radarr</option>
</select>
<small class="form-text text-muted">
Which Service should be used as default for movie and tv commands.
</small>
</div>
</div>
<div class="form-group row">
<label for="selection" class=" col-sm-4 col-form-label">Default Selection</label>
<div class="col-md-8">
<select name="selection" id="selection" class="form-control selection">
<option value="emoji" <% if (botSettings && botSettings.selection === "emoji") { %>selected<% }%>>Emoji Reaction</option>
<option value="text" <% if (botSettings && botSettings.selection === "text") { %>selected<% }%>>Text Response</option>
</select>
<small class="form-text text-muted">
Which selection should be used if multiple results are returned.
</small>
</div>
</div>
</div>
</div>

View File

@@ -52,10 +52,10 @@
<label for="profile" class="col-md-4 col-form-label">Quality Profiles</label>
<div class="col-md-8">
<select name="profile" id="profile-radarr" class="form-control profile">
<option value=0>Please select</option>
<option value="0">Please select</option>
<% if (radarrOptions.profiles) { %>
<% for (let i = 0; i < radarrOptions.profiles.length; i++) { %>
<option value=<%= radarrOptions.profiles[i].id %> <% if (radarrSettings && parseInt(radarrSettings.profile) == parseInt(radarrOptions.profiles[i].id)) { %>selected<% }%>><%= radarrOptions.profiles[i].name %></option>
<option value="<%= radarrOptions.profiles[i].id %>" <% if (radarrSettings && parseInt(radarrSettings.profile) == parseInt(radarrOptions.profiles[i].id)) { %>selected<% }%>><%= radarrOptions.profiles[i].name %></option>
<% } %>
<% } %>
</select>
@@ -66,10 +66,10 @@
<label for="rootfolder" class="col-md-4 col-form-label">Default Root folders</label>
<div class="col-md-8">
<select name="rootfolder" id="rootfolder-radarr" class="form-control rootfolder">
<option value=0>Please select</option>
<option value="0">Please select</option>
<% if (radarrOptions.rootfolders) { %>
<% for (let i = 0; i < radarrOptions.rootfolders.length; i++) { %>
<option value=<%= radarrOptions.rootfolders[i].path %> <% if (radarrSettings && radarrSettings.rootfolder == radarrOptions.rootfolders[i].path) { %>selected<% }%>><%= radarrOptions.rootfolders[i].path %></option>
<option value="<%= radarrOptions.rootfolders[i].path %>" <% if (radarrSettings && radarrSettings.rootfolder == radarrOptions.rootfolders[i].path) { %>selected<% }%>><%= radarrOptions.rootfolders[i].path %></option>
<% } %>
<% } %>
</select>

View File

@@ -59,10 +59,10 @@
<label for="profile" class="col-md-4 col-form-label">Quality Profiles</label>
<div class="col-md-8">
<select name="profile" id="profile-sonarr" class="form-control profile">
<option value=0>Please select</option>
<option value="0">Please select</option>
<% if (sonarrOptions.profiles) { %>
<% for (let i = 0; i < sonarrOptions.profiles.length; i++) { %>
<option value=<%= sonarrOptions.profiles[i].id %> <% if (sonarrSettings && parseInt(sonarrSettings.profile) == parseInt(sonarrOptions.profiles[i].id)) { %>selected<% }%>><%= sonarrOptions.profiles[i].name %></option>
<option value="<%= sonarrOptions.profiles[i].id %>" <% if (sonarrSettings && parseInt(sonarrSettings.profile) == parseInt(sonarrOptions.profiles[i].id)) { %>selected<% }%>><%= sonarrOptions.profiles[i].name %></option>
<% } %>
<% } %>
</select>
@@ -73,10 +73,10 @@
<label for="profileanime" class="col-md-4 col-form-label">Quality Profiles (Anime)</label>
<div class="col-md-8">
<select name="profileanime" id="profileanime" class="form-control profileanime">
<option value=0>Please select</option>
<option value="0">Please select</option>
<% if (sonarrOptions.profiles) { %>
<% for (let i = 0; i < sonarrOptions.profiles.length; i++) { %>
<option value=<%= sonarrOptions.profiles[i].id %> <% if (sonarrSettings && parseInt(sonarrSettings.profileanime) == parseInt(sonarrOptions.profiles[i].id)) { %>selected<% }%>><%= sonarrOptions.profiles[i].name %></option>
<option value="<%= sonarrOptions.profiles[i].id %>" <% if (sonarrSettings && parseInt(sonarrSettings.profileanime) == parseInt(sonarrOptions.profiles[i].id)) { %>selected<% }%>><%= sonarrOptions.profiles[i].name %></option>
<% } %>
<% } %>
</select>
@@ -87,10 +87,10 @@
<label for="rootfolder" class="col-md-4 col-form-label">Default Root folders</label>
<div class="col-md-8">
<select name="rootfolder" id="rootfolder-sonarr" class="form-control rootfolder">
<option value=0>Please select</option>
<option value="0">Please select</option>
<% if (sonarrOptions.rootfolders) { %>
<% for (let i = 0; i < sonarrOptions.rootfolders.length; i++) { %>
<option value=<%= sonarrOptions.rootfolders[i].path %> <% if (sonarrSettings && sonarrSettings.rootfolder == sonarrOptions.rootfolders[i].path) { %>selected<% }%>><%= sonarrOptions.rootfolders[i].path %></option>
<option value="<%= sonarrOptions.rootfolders[i].path %>" <% if (sonarrSettings && sonarrSettings.rootfolder == sonarrOptions.rootfolders[i].path) { %>selected<% }%>><%= sonarrOptions.rootfolders[i].path %></option>
<% } %>
<% } %>
</select>
@@ -101,10 +101,10 @@
<label for="rootfolderanime" class="col-md-4 col-form-label">Default Root folders (Anime)</label>
<div class="col-md-8">
<select name="rootfolderanime" id="rootfolderanime" class="form-control rootfolderanime">
<option value=0>Please select</option>
<option value="0">Please select</option>
<% if (sonarrOptions.rootfolders) { %>
<% for (let i = 0; i < sonarrOptions.rootfolders.length; i++) { %>
<option value=<%= sonarrOptions.rootfolders[i].path %> <% if (sonarrSettings && sonarrSettings.rootfolderanime == sonarrOptions.rootfolders[i].path) { %>selected<% }%>><%= sonarrOptions.rootfolders[i].path %></option>
<option value="<%= sonarrOptions.rootfolders[i].path %>" <% if (sonarrSettings && sonarrSettings.rootfolderanime == sonarrOptions.rootfolders[i].path) { %>selected<% }%>><%= sonarrOptions.rootfolders[i].path %></option>
<% } %>
<% } %>
</select>
@@ -115,10 +115,10 @@
<label for="languageprofile" class="col-md-4 col-form-label">Language Profiles</label>
<div class="col-md-8">
<select name="languageprofile" id="languageprofile" class="form-control languageprofile">
<option value=0>Please select</option>
<option value="0">Please select</option>
<% if (sonarrOptions.languageprofiles) { %>
<% for (let i = 0; i < sonarrOptions.languageprofiles.length; i++) { %>
<option value=<%= sonarrOptions.languageprofiles[i].id %> <% if (sonarrSettings && parseInt(sonarrSettings.languageprofile) == parseInt(sonarrOptions.languageprofiles[i].id)) { %>selected<% }%>><%= sonarrOptions.languageprofiles[i].name %></option>
<option value="<%= sonarrOptions.languageprofiles[i].id %>" <% if (sonarrSettings && parseInt(sonarrSettings.languageprofile) == parseInt(sonarrOptions.languageprofiles[i].id)) { %>selected<% }%>><%= sonarrOptions.languageprofiles[i].name %></option>
<% } %>
<% } %>
</select>