Skip to content

Commit

Permalink
Merge pull request #1 from Lapotor/dev
Browse files Browse the repository at this point in the history
First Version
  • Loading branch information
Lapotor authored Jul 11, 2018
2 parents 7f1956d + b9782ee commit 3035ec3
Show file tree
Hide file tree
Showing 6 changed files with 295 additions and 0 deletions.
1 change: 1 addition & 0 deletions .readme-assets/.placeholder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added .readme-assets/folder-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .readme-assets/warnsys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
[![forthebadge](https://forthebadge.com/images/badges/built-by-developers.svg)]()
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)]()
[![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)]()

[![GitHub license](https://img.shields.io/github/license/Lapotor/PhantomBot-WarnSys.svg?style=for-the-badge)](https://github.com/Lapotor/PhantomBot-WarnSys/blob/master/LICENSE.md)

# PhantomBot-WarnSys
This script let you warn viewers with PhantomBot

# Installation
To install this script you simply need to download the latest release (click on the image):

[![GitHub release](https://img.shields.io/github/release/Lapotor/PhantomBot-WarnSys.svg?style=for-the-badge)](https://github.com/Lapotor/PhantomBot-WarnSys/release/latest)

[![Folder View](.readme-assets/folder-view.png)]()

and drop it in your PhantomBot folder `/path/to/phatombot`. Now restart the Bot and when you see this at the end of the startup the script is **active**:
[![Warn System Enabled](.readme-assets/warnsys.png)]()

# Usage
Its really simple!
First of all i need define two things:
```
[] => Optional for command use
() => Required for command use
```

### The warn command
```
!warn (User) [Reason]
```
With this command you increase the warn level of the given user add ban/timout the user with the given reason.

### Delete one warn
```
!delwarn (User)
```
With this command you decrease the warn level of the given user.

### Clear the warns
```
!delwarn (User) all
```
As it say it clear the warnings of the given User

# Support, Bug etc.
[![GitHub issues](https://img.shields.io/github/issues/Lapotor/PhantomBot-WarnSys.svg?style=for-the-badge)](https://github.com/Lapotor/PhantomBot-WarnSys/issues)

If you found a bug please open a issue here or tell me in the PhantomBot Community.

---
[![WTFPL](https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/WTFPL_badge.svg/320px-WTFPL_badge.svg.png)](LICENSE.md)

This work is licensed under the "Do **W**hat **T**he **F**uck You Want To **P**ublic **L**icense". To see the full License Text go to the [LICENSE File](LICENSE.md)
189 changes: 189 additions & 0 deletions scripts/custom/warnSys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/*
* Copyright © 2018 Valentin Sickert aka Lapotor.
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the LICENSE file or http://www.wtfpl.net/
* for more details.
*/
/**
* Created by: Valentin Sicket aka Lapotor
* Date: 10.07.18 05:08
* Project: PhantomBot-WarnSys
*/

/**
* warnSys.js
*
* @version 1.0.0
*/
(function () {

function initText() {
$.consoleLn("╔═══════════════════╗");
$.consoleLn("║ Warn System ║");
$.consoleLn("║ ░▒▓█ Enabled █▓▒░ ║");
$.consoleLn("╚═══════════════════╝");
}

/**
* @function userStrings
* @param {string} user
* @return {array}
*/
function userStrings(user) {
var user_mention = "";
var user_string = "";
if (user.charAt(0) === "@"){
user_mention = user;
user_string = user.substr(1);
} else {
user_mention = "@" + user;
user_string = user;
}
return [user_mention, user_string];
}

/**
* @function warn1
* @param {string} user
* @param {string} reason
* @returns {void}
*/
function warn1(user, reason) {
user = userStrings(user);
$.say(".timeout " + user[1] + " " + $.lang.get('warnsys.warn1.time') + " " + reason);
$.say($.lang.get('warnsys.warn1.twitch', user[0]));
$.consoleLn($.lang.get('warnsys.warn1.console', user[1]));
}

/**
* @function warn2
* @param {string} user
* @param {string} reason
* @returns {void}
*/
function warn2(user, reason) {
user = userStrings(user);
$.say(".timeout " + user[1] + " " + $.lang.get('warnsys.warn2.time') + " " + reason);
$.say($.lang.get('warnsys.warn2.twitch', user[0]));
$.consoleLn($.lang.get('warnsys.warn2.console', user[1]));
}

/**
* @function warn3
* @param {string} user
* @param {string} reason
* @returns {void}
*/
function warn3(user, reason) {
user = userStrings(user);
$.say(".ban " + user[1] + " " + reason);
$.say($.lang.get('warnsys.warn3.twitch', user[0]));
$.consoleLn($.lang.get('warnsys.warn3.console', user[1]));
}

/**
* @function setLang
*
*/
function setLang() {

}

/**
* @event command
*/
$.bind('command', function (event) {
var command = event.getCommand();
var sender = event.getSender();
var args = event.getArgs();
var reason = "";


if (args[0] != undefined || args[0] != null) {
if ($.isBot(args[0]) || $.isMod(args[0]) || $.isOwner(args[0]) || $.isAdmin(args[0])) {
var user = 0x349;
} else {
var user = userStrings(args[0]);
}

/**
* @commandpath warn - Warn a the given player
*/
if (command.equalsIgnoreCase('warn')) {
if (user === 0x349) {
$.say($.lang.get('warnsys.isstaff.twitch', user[1]));
$.consoleLn($.lang.get('warnsys.isstaff.console', user[1]));
} else {
for (var i = 1; i < args.length; i++) {
reason += args[i];
if (i != args.length - 1) {
reason += " ";
}
}

if (!$.inidb.exists('warnSystem', user[1])) {
warn1(args[0], reason);
$.setIniDbNumber('warnSystem', user[1], 1);
} else if ($.getIniDbNumber('warnSystem', user[1]) == 1) {
$.inidb.incr('warnSystem', user[1], 1);
warn2(args[0], reason);
} else if ($.getIniDbNumber('warnSystem', user[1]) == 2) {
$.inidb.incr('warnSystem', user[1], 1);
warn3(args[0], reason);
} else if ($.getIniDbNumber('warnSystem', user[1]) == 3) {
$.say($.lang.get('warnsys.already.twitch', sender, user[1]));
} else {
$.say($.lang.get('warnsys.noexecute.twitch', sender));
}
}
}

/**
* @commandpath delwarn - Remove the given player from the warned list.
*/
if (command.equalsIgnoreCase('delwarn')) {
if ((args[1] != undefined || args[1] != null) && args[1].equalsIgnoreCase('all')) {
if ($.inidb.exists('warnSystem', user[1])) {
$.inidb.del('warnSystem', user[1]);
$.say(".unban " + user[1]);
$.say($.lang.get('warnsys.delall.twitch', user[1]));
$.consoleLn($.lang.get('warnsys.delall.console', user[1], sender));
} else {
$.say("@" + sender + " " + user[1] + " wurde noch nicht Verwarnt.");
}
} else if ($.inidb.exists('warnSystem', user[1])) {
if ($.getIniDbNumber('warnSystem', user[1]) == 1) {
$.say(".unban " + user[1]);
$.say($.lang.get('warnsys.delwarn1.twitch', user[1]));
$.consoleLn($.lang.get('warnsys.delwarn1.console', user[1], sender));
$.inidb.del('warnSystem', user[1]);
} else if ($.getIniDbNumber('warnSystem', user[1]) == 2) {
$.say(".unban " + user[1]);
$.say($.lang.get('warnsys.delwarn2.twitch', user[1]));
$.consoleLn($.lang.get('warnsys.delwarn2.console', user[1], sender));
$.inidb.decr('warnSystem', user[1], 1);
} else if ($.getIniDbNumber('warnSystem', user[1]) == 3) {
$.say(".unban " + args[0]);
$.say($.lang.get('warnsys.delwarn2.twitch', user[1]));
$.consoleLn($.lang.get('warnsys.delwarn2.console', user[1], sender));
$.inidb.decr('warnSystem', user[1], 1);
}
} else {
$.say($.lang.get('warnsys.warn.none', sender, user[1]));
}
}
}
});

/**
* @event initReady
*/
$.bind('initReady', function () {
if ($.bot.isModuleEnabled('./custom/warnSys.js')) {
initText();
$.registerChatCommand('./custom/warnSys.js', 'warn', 2);
$.registerChatCommand('./custom/warnSys.js', 'delwarn', 2);
}
});
})();
53 changes: 53 additions & 0 deletions scripts/lang/custom/custom-warnSys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright © 2018 Valentin Sickert aka Lapotor.
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the LICENSE file or http://www.wtfpl.net/
* for more details.
*/
/**
* Created by: Valentin Sicket aka Lapotor
* Date: 10.07.18 05:08
* Project: PhantomBot-WarnSys
*/

/*
* Warning 1
*/
$.lang.register('warnsys.warn1.time', '5'); /* The time the user get timouted on the first warning. */
$.lang.register('warnsys.warn1.twitch', '$1 this is your first warning!');
$.lang.register('warnsys.warn1.console', '[WarnSyS] First warning for $1');
$.lang.register('warnsys.delwarn1.twitch', '$1 has been removed of the warning list.');
$.lang.register('warnsys.delwarn1.console', '[WarnSyS] $1 has been removed of the warning list from $2.');

/*
* Warning 2
*/
$.lang.register('warnsys.warn2.time', '600'); /* The time the user get timouted on the second warning. */
$.lang.register('warnsys.warn2.twitch', '$1 this is your last warning! Next time we have to ban you.');
$.lang.register('warnsys.warn2.console', '[WarnSyS] Second warning for $1');
$.lang.register('warnsys.delwarn2.twitch', '$1 has been downgraded to the first warning on the warning list.');
$.lang.register('warnsys.delwarn2.console', '[WarnSyS] $1 has been downgraded to the first warning on the warning list from $2.');

/*
* Warning 3
*/
$.lang.register('warnsys.warn3.twitch', 'That\'s it for you $1. Another wonderful life for you.');
$.lang.register('warnsys.warn3.console', '[WarnSyS] $1 got banned.');
$.lang.register('warnsys.delwarn3.twitch', '$1 has been downgraded to the second warning on the warning list.');
$.lang.register('warnsys.delwarn3.console', '[WarnSyS] $1 has been downgraded to the second warning on the warning list from $2.');

/*
* Delete all warnings
*/
$.lang.register('warnsys.delall.twitch', 'The warnings of $1 got removed of the list.');
$.lang.register('warnsys.delall.console', '[WarnSyS] $1 has been removed of the warning list from $2.');

/*
* Other text
*/
$.lang.register('warnsys.warn.none', '@$1 $2 has not been warned yet.');
$.lang.register('warnsys.isstaff.twitch', 'You can\'t warn $1.');
$.lang.register('warnsys.isstaff.console', '[WarnSyS] $1 couldn\'t get warned.');
$.lang.register('warnsys.already.twitch', '@$1 $2 is already banned.');
$.lang.register('warnsys.noexecute.twitch', '$1 i couldn\'t execute that command.');

0 comments on commit 3035ec3

Please sign in to comment.