-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
87 lines (70 loc) · 2.22 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env node
'use strict';
/* jshint node: true */
const chalk = require('chalk');
const error = chalk.bold.red;
const success = chalk.bold.green;
const clear = require('clear');
const figlet = require('figlet');
const columnify = require('columnify');
const vorpal = require('vorpal')();
const logSymbols = require('log-symbols');
const channels = require('./lib/channels');
const channelData = require('./lib/channelData');
clear();
console.log(chalk.yellow(figlet.textSync('YTRP', {horizontalLayout: 'default'})));
console.log(chalk.yellow('\nWelcome to YouTubeRedditPoster! Enter a command.\n'));
vorpal
.command('add <channelid>', 'Adds a channel to monitor.')
.action(function (args, callback) {
channelData.getChannelName(args.channelid)
.then(channels.addChannel)
.then((res) => {
console.log(logSymbols.success, success(res));
})
.catch((err) => {
console.log(`${logSymbols.error} ${error(err)}`);
});
callback();
});
vorpal
.command('remove <channelid>', 'Removes a channel from the database')
.action(function (args, callback) {
let addIndicator = startWaitingIndicator();
channels.remove(args.channelid).then((res) => {
stopWaitingIndicator(addIndicator);
console.log(`${logSymbols.success} Removed channel: ${args.channelid}`);
})
.catch((e) => {
stopWaitingIndicator(addIndicator);
console.log(error(`${logSymbols.error} Channel not found: ${args.channelid}`));
});
callback();
});
vorpal
.command('list', 'Lists all channels in the database.')
.action(function (args, callback) {
channels.list();
callback();
});
vorpal
.command('start', 'Starts the bot')
.action(function (args, callback) {
channels.startBot();
callback();
});
vorpal
.command('stop', 'Stops the bot')
.action(function (args, callback) {
channels.stopBot();
callback();
});
vorpal
.command('clear', 'Clears the screen')
.action(function (args, callback) {
clear();
callback();
});
vorpal
.delimiter('YTRP:')
.show();