Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Dev (#6)
Browse files Browse the repository at this point in the history
* preparations for the redis substitute

* new functions for redis substitute

* skip timeout optimization

* skip timeout optimization...

* adding keys command

* add zrem,zadd,zrange

* add quit

* fix redis substitute

* redis is just to op to substitute it...

* fix staff protection

* add bans an a few other things

* seems like i did too much eris... (fixing some errors and resolving ide inspections)

* add duration to ban message

* kill me please...

* beta unban

* simplify some null-checks

* nvm

* add swap nolock options

* add swap to command list

* fix command list

* formatting

* fix command list

* ...

* updating dependencies

* modernize code to es6

* adding regex capabilities, update docs

* some es6 refractoring

* bump dependencies

* version bump
  • Loading branch information
Fuechschen authored Nov 27, 2016
1 parent 7b1951b commit f30a7f0
Show file tree
Hide file tree
Showing 141 changed files with 1,330 additions and 1,231 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ crashlytics-build.properties
# Created by .ignore support plugin (hsz.mobi)

config.js

sql_init.js
27 changes: 13 additions & 14 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,43 @@ var fs = require('fs');

var config = require('./lib/load_config.js');
var langfile = require('./langfile.js');
var plugged = require('./lib/client');
var redis = require('./lib/db/redis_db');
var story = storyboard.mainStory;

storyboard.config({filter: '*:' + config.options.loglevel});
storyboard.mainStory.info('Starting plugbot version ' + require('./package.json').version);
storyboard.config({filter: `*:${config.options.loglevel}`});
storyboard.addListener(require('storyboard/lib/listeners/console').default);
story.info(`Starting plugbot version ${require('./package.json').version}`);

moment.locale(langfile.moment_locale);

var plugged = require('./lib/client');
var redis = require('./lib/db/redis_db');
var db = require('./lib/db/sql_db');

//noinspection JSUnresolvedFunction
redis.del('user:roles');

redis.exists('meta:data:staff:active').then(function (ex) {
redis.exists('meta:data:staff:active').then(ex => {
if (ex === 0) redis.set('meta:data:staff:active', 1);
});

fs.readdir('./lib/eventhandlers', function (err, files) {
fs.readdir('./lib/eventhandlers', (err, files) => {
if (err) {
story.fatal('Cannot load eventhandlers.', {attach: err});
process.exit(1);
} else {
files.forEach(function (file) {
files.forEach(file => {
try {
var h = require('./lib/eventhandlers/' + file);
var h = require(`./lib/eventhandlers/${file}`);
if (Array.isArray(h.event)) {
h.event.forEach(function (event) {
h.event.forEach(event => {
plugged.on(event, h.handler);
});
} else plugged.on(h.event, h.handler);
story.debug('EventHandlers', 'Loaded Handler for Event ' + (Array.isArray(h.event) ? h.event.join() : h.event));
story.debug('EventHandlers', `Loaded Handler for Event ${Array.isArray(h.event) ? h.event.join() : h.event}`);
} catch (e) {
story.error('Failed to load eventhandler ' + file, {attach: e});
story.error(`Failed to load eventhandler ${file}`, {attach: e});
process.exit(1);
}
});
}
});

module.exports = {plugged: plugged, app: (config.web.enabled ? require('./web/index').app : null)};
module.exports = {plugged, app: (config.web.enabled ? require('./web/index').app : null)};
4 changes: 3 additions & 1 deletion config.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ module.exports = {
titleguard: {
enabled: true,
not_contain: ['big dick'],
regex_match: null,
lockskip: false
},
playlists: {
Expand Down Expand Up @@ -174,6 +175,7 @@ module.exports = {
},
userfilter: {
enabled: false,
username_disallowed: []
username_disallowed: [],
regex:null
}
};
165 changes: 83 additions & 82 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,106 @@

## User Commands

|Command|Alias|Arguments|Description|
|---|---|---|---|
|!link| | |Gives a link to the current song|
|!define| |(word)|Defines the given word|
|!songinfo|!sinfo|[format:cid / media-url]|Gives information about the song|
|!catfact|!catfacts| |Gives a catfact|
|!join| | |Joins an open roulette|
|!leave| | |Leaves an open roulette|
|!disconnected|!dc| |Places you back in the waitlist if you lost your spot|
|Command|Alias|Arguments|Flags|Description|
|---|---|---|---|---|
|!link| | | |Gives a link to the current song|
|!define| | |(word)|Defines the given word|
|!songinfo|!sinfo|[format:cid / media-url]| |Gives information about the song|
|!catfact|!catfacts| | |Gives a catfact|
|!join| | | |Joins an open roulette|
|!leave| | | |Leaves an open roulette|
|!disconnected|!dc| | |Places you back in the waitlist if you lost your spot|

## RDj Commands
RDj commands include user commands

|Command|Alias|Arguments|Description|
|---|---|---|---|
|!demote| | |Removes you as staff|
|!promote| | |Adds you back as staff|
|!ping| | |Pong!|
|!skip|!fs| |Votes for skip|
|!uptime| | |Displays uptime|
|!next| | |Gives the next song on the bot's playlist|
|Command|Alias|Arguments|Flags|Description|
|---|---|---|---|---|
|!demote| | | |Removes you as staff|
|!promote| | | |Adds you back as staff|
|!ping| | | |Pong!|
|!skip|!fs| | |Votes for skip|
|!uptime| | | |Displays uptime|
|!next| | | |Gives the next song on the bot's playlist|

## Bouncer Commands
Bouncer commands include Rdj commands

|Command|Alias|Arguments|Description|
|---|---|---|---|
|!skip|!fs|[reason]|Skips the current song and sends an optional reason.|
|!lockskip|!ls|[reason]|Skips the current songs, moves the dj back and sends an optional reason|
|!blacklist|!bl|[reason]|Skips the curent song, adds it to the blacklist and sends an optional reason|
|!idblacklist|!idbl|(format:cid)[reason]|Adds the given media to the blacklist with the given, optional reason|
|!cycleskip|!cs|[reason]|Disables the DJ-Cycle, skips the current song and sends an optional reason|
|!remove|!rm/!rem/!rmwl|(@user)|Removes the given user from the waitlist|
|!delchat| |[@user]|Deletes every chat message or removes messages from the given user|
|!kick| |(@user)|Kicks the given user|
|!mute| |(@user)|Mutes the given user|
|!joinwl| | |Let's the bot join the waitlist|
|!leavewl| | |Let's the bot leave the waitlist|
|!state| | |Gives the current settings|
|!wlban| |(@user)|Bans the given user from the waitlist|
|!shuffleplaylist|!shufflepl| |Shuffles the bot's playlist|
|Command|Alias|Arguments|Flags|Description|
|---|---|---|---|---|
|!skip|!fs|[reason]| |Skips the current song and sends an optional reason.|
|!lockskip|!ls|[reason]| |Skips the current songs, moves the dj back and sends an optional reason|
|!blacklist|!bl|[reason]| |Skips the curent song, adds it to the blacklist and sends an optional reason|
|!idblacklist|!idbl|(format:cid)[reason]| |Adds the given media to the blacklist with the given, optional reason|
|!cycleskip|!cs|[reason]| |Disables the DJ-Cycle, skips the current song and sends an optional reason|
|!remove|!rm/!rem/!rmwl|(@user)| |Removes the given user from the waitlist|
|!delchat| |[@user]| |Deletes every chat message or removes messages from the given user|
|!kick| |(@user)| |Kicks the given user|
|!mute| |(@user)| |Mutes the given user|
|!joinwl| | | |Let's the bot join the waitlist|
|!leavewl| | | |Let's the bot leave the waitlist|
|!state| | | |Gives the current settings|
|!wlban| |(@user)| |Bans the given user from the waitlist|
|!shuffleplaylist|!shufflepl| | |Shuffles the bot's playlist|

## Bouncer+ Commands

These commands are only available for bouncers when bouncer+ is enabled.

|Command|Alias|Arguments|Description|
|---|---|---|---|
|!add|!addwl|(@user)|Adds the given user to the waitlist|
|!move|!mv|(@user)(position)|Moves the given user to the given position|
|!unblacklist|!unbl/!rmbl|(format:cid / media-url)|Removes the given song from the blacklist|
|!unmute| |(@user)|Unmutes the given user|
|!wlunban| |(@user)|Unbans the given user from the waitlist|
|!cleanwl| | |Clears and rebuilds the waitlist to remove ghost users|
|!lock| | |Locks the waitlist|
|!unlock| | |Unlocks the waitlist|
|!cycle| | |Toggles the DJ cycle|
|!clear|!clearwl| |Locks and clears the waitlist|
|!historyskip| | |Toggles historyskip|
|!voteskip| | |Toggles voteskip|
|!timeguard| | |Toggles timeguard|
|!cleverbot| | |Toggles cleverbot|
|!eventmode| |[-c/-l/-u][-dc/-ec]|Toggles eventmode|
|!lockdown| | |Toggles lockdown|
|!dcmoveback| | |Toggles DCMoveback|
|!chatfilter| | |Toggles chatfilter|
|!filterreset| |(@user)|Resets all chatfilterscores for the given user|
|!clearhistory| | |Clears the songhistory|
|!removehistory|!rmh|(format:cid / media-url)|Removes the given media from the history|
|!reloadblacklist|!reloadbl| |Reloads the blacklist from the database|
|!reloadroles| | |Reloads all roles from the database|
|!reloadcustomcommands|!reloadcc| |Reloads all CustomCommands from the database|
|!lockskippos|!lspos|(position)|Sets the position for lockskip|
|!chatlevel|!chatlvl/!clvl|(level)|Sets the room chat level to the given level|
|!youtubeguard|!ytguard| |Toggles YouTubeGuard|
|!soundcloudguard|!scguard| |Toggles SoundCloudGuard|
|!titleguard| | |Toggles TitleGuard|
|!togglecustomcommands|!togglecc| |Toggles CustomCommands|
|!customcommands|!cc|add(trigger)(message)/enable(trigger)/disable(trigger)/senderenable(trigger)/senderdisable(trigger)|Edits a CustomCommand|
|!woot|!w|[-s/-d]|Let's the bot woot. Use -s to save the vote|
|!meh|!m|[-s/-d]|Let's the bot meh. Use -s to save the vote|
|!lottery| |[time]|Starts a lottery|
|!roulette| |(moves)[time]|Starts a roulette|
|!everyone| |[msg]|Mentions everyone|
|!toggleafk| | |Toggles AFKRemoval|
|!channelblacklist|!cbl|add (cid)/rem (cid)/toggle|Adds/Removes a whole youtube channel from the blacklist/toggles the channelblacklist|
|Command|Alias|Arguments|Flags|Description|
|---|---|---|---|---|
|!add|!addwl|(@user)| |Adds the given user to the waitlist|
|!move|!mv|(@user)(position)| |Moves the given user to the given position|
|!swap| |(@user)(@user)|-nl|Swap the waitlist-positions of the specified users. -nl will prevent waitlsit-locking|
|!unblacklist|!unbl/!rmbl|(format:cid / media-url)| |Removes the given song from the blacklist|
|!unmute| |(@user)| |Unmutes the given user|
|!wlunban| |(@user)| |Unbans the given user from the waitlist|
|!cleanwl| | | |Clears and rebuilds the waitlist to remove ghost users|
|!lock| | | |Locks the waitlist|
|!unlock| | | |Unlocks the waitlist|
|!cycle| | | |Toggles the DJ cycle|
|!clear|!clearwl| | |Locks and clears the waitlist|
|!historyskip| | | |Toggles historyskip|
|!voteskip| | | |Toggles voteskip|
|!timeguard| | | |Toggles timeguard|
|!cleverbot| | | |Toggles cleverbot|
|!eventmode| | |[-c/-l/-u][-dc/-ec]|Toggles eventmode|
|!lockdown| | | |Toggles lockdown|
|!dcmoveback| | | |Toggles DCMoveback|
|!chatfilter| | | |Toggles chatfilter|
|!filterreset| |(@user)| |Resets all chatfilterscores for the given user|
|!clearhistory| | | |Clears the songhistory|
|!removehistory|!rmh|(format:cid / media-url)| |Removes the given media from the history|
|!reloadblacklist|!reloadbl| | |Reloads the blacklist from the database|
|!reloadroles| | | |Reloads all roles from the database|
|!reloadcustomcommands|!reloadcc| | |Reloads all CustomCommands from the database|
|!lockskippos|!lspos|(position)| |Sets the position for lockskip|
|!chatlevel|!chatlvl/!clvl|(level)| |Sets the room chat level to the given level|
|!youtubeguard|!ytguard| | |Toggles YouTubeGuard|
|!soundcloudguard|!scguard| | |Toggles SoundCloudGuard|
|!titleguard| | | |Toggles TitleGuard|
|!togglecustomcommands|!togglecc| | |Toggles CustomCommands|
|!customcommands|!cc|add(trigger)(message)/ enable(trigger)/ disable(trigger)/ senderenable(trigger)/ senderdisable(trigger)| |Edits a CustomCommand|
|!woot|!w| |[-s/-d]|Let's the bot woot. Use -s to save the vote|
|!meh|!m| |[-s/-d]|Let's the bot meh. Use -s to save the vote|
|!lottery| |[time]| |Starts a lottery|
|!roulette| |(moves)[time]| |Starts a roulette|
|!everyone| |[msg]| |Mentions everyone|
|!toggleafk| | | |Toggles AFKRemoval|
|!channelblacklist|!cbl|add (cid)/rem (cid)/toggle| |Adds/Removes a whole youtube channel from the blacklist/toggles the channelblacklist|

## Manager Commands
Manager commands include bouncer and bouncer+ commands

|Command|Alias|Arguments|Description|
|---|---|---|---|
|!setstaff| |(role)(@user)|Sets the given user to the given role|
|!bouncer+| | |Toggles bouncer+|
|!welcomemsg| | |Sets the room welcome message|
|!roomname| | |Sets the roomname|
|!superuser|!su|(@user)|Sets the given user as superuser|
|!restart| | |Restarts the bot|
|!clearghosts| | |Clears ghost-users from the community. Use with care, may result in a ban for the bot|
|Command|Alias|Arguments|Flags|Description|
|---|---|---|---|---|
|!setstaff| |(role)(@user)| |Sets the given user to the given role|
|!bouncer+| | | |Toggles bouncer+|
|!welcomemsg| | | |Sets the room welcome message|
|!roomname| | | |Sets the roomname|
|!superuser|!su|(@user)| |Sets the given user as superuser|
|!restart| | |-n|Restarts the bot|
|!clearghosts| | | |Clears ghost-users from the community. Use with care, may result in a ratelimit-ban for the bot|


() = required argument
Expand Down
6 changes: 6 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
|titleguard|object|settings for titleguard|
|titleguard.enabled|boolean|Sets the default value for titleguard|
|titleguard.not_contain|array[string]|Words titles are forbidden to contain|
|titleguard.regex_match|RegEx|Regular expression to test against. Set to null to disable this|
|titleguard.lockskip|boolean|Enables lockskip if titleguard is triggerd|
|playlists.play|number|A playlist-id for the bot to play when in the waitlist|
|playlists.none|number|A playlist-id for the bot to activate when not in waitlist to avoid being acidentially added|
|afk|object|Settings for the afk-function|
Expand All @@ -80,4 +82,8 @@
|web.useUWS|boolean|Enable this to use a more performant websocket-library which requires a c++-compiler on you machine. Disable it, if your bot throws an error at startup concerning uWebsocket|
|web.path|string|the path the api runs under|
|defaultCC|object|Contains multiple objects with default customcommands, see config.example.js for their properties|
|userfilter|object|Settings for the userfilter|
|userfilter.enabled|boolean|Enables the userfilter|
|userfilter.username_disallowed|array[string]|array of disallowed usernames|
|userfilter.regex|RegEx|RegEx to test usernames. Triggers the filter when a match is found. Set to null to disable|

3 changes: 3 additions & 0 deletions docs/database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Database

Unfortunately, the used ORM has a little bug which prevents it from creating the database correctly. To initialize it, run install.sql if you are using mysql/mariadb on the created database and you should be good.
Loading

0 comments on commit f30a7f0

Please sign in to comment.