i-m-a-sirvivor's People
Forkers
kewlstatics lord-haji git-worm hawkiee snapeasy zestoflife omroom harmanpc cheesemuffin cantius 1nactive shadecession tushavi ahelpfulrayquaza zorquax arifin6686 micromorphic69 1mitsuki rainshaft audiino privatepenquin pacificmarilli-m-a-sirvivor's Issues
Add htmlbox output to .js
code stolen from Ice Kyubs which stole it from Scrappie:
const renderResult = function(text) {
if (typeof text === "object") {
text = JSON.stringify(text, null, 2);
} else {
text = text.toString();
}
text = text.split("\n");
let ret = "<details open='open'><summary>code</summary><div style='width:100%; max-height:400px; overflow:auto; white-space:nowrap'><pre><span style='float:left; margin:0 1em 0 0; padding-right:3px; border-right:1px double; text-align:right'>1";
for (let i = 2; i <= text.length; i++) {
ret += "<br>" + i;
}
ret += "</span>";
ret += require("escape-html")(text.join("\n")).replace(/\n/gi, "<br>");
ret += "</pre></div></details>";
return ret;
};
use this function to render the result of .js or .eval, allowing for more detailed output
Improve permission system
Ice Kyubs has a really clean permission system in user.can()
, written by me
can(perm, room = "battledome") {
if (!perm || perm === "talk") perm = " ";
if (room.id) room = room.id;
if (perm === "all") return ["felucia"].includes(this.id); // Just in case I'll ever need this
if (perm === "host-") perm = "host";
else if (perm === "cohost-") perm = "cohost";
else if (this.isExcepted()) return true; // Excepted users bypass normal permission checks, unless the check is host- or cohost-
if (perm === "apphost") {
let selfhost = players("apphost").get("users");
if (selfhost.indexOf(this.id) !== -1) return true;
perm = "cohost+"; // cohosts and above can use Apphost commands
}
if (perm.substring(0, 6) === "cohost") {
let cohostobj = group("host").get("cohost");
let coHoster;
for (let co in cohostobj) {
if (cohostobj[co].includes(this.id)) {
coHoster = true;
break;
}
}
if (coHoster) return true;
perm = perm.substring(2); // Hosts can use the commands cohosts can use
}
if (perm.substring(0, 4) === "host") {
let hostarray = group("host").get("array");
if (hostarray.indexOf(this.id) !== -1) return true;
perm = perm.substring(4);
}
if (perm in Config.groups) {
if (!this.hasRank(room, perm) && room === "battledome") {
if (!Users.ranks) return false;
if (!Users.ranks[this.id]) return false;
return Config.groups[Users.ranks[this.id]] >= Config.groups[perm];
}
return this.hasRank(room, perm);
}
return false;
}
It's been a while since I wrote this, and it might be due for another cleanup for readability. The gist of it is this: A permission system with a single command that handles everything. No more
!user.hasRank(room.id, '+') && (!Games.host || Games.host.id !== user.id)
instead we could have
if (!user.can('host+'))
aka "the user is not host or above".
This just makes permissions significantly less of a headache, but the tradeoff is that the system needs to be extensive and robust. Every case currently used in code needs to be usable with the new system, and there should be no way for someone without permission to pass the check.
Replace var where possible
var
is a relic of a bygone age. Ideally, all code should use let
. This is kind of nitpicky, as you could just keep the var
for "if it works it works" mentality, but I do want it gone eventually.
You can't just find-and-replace var to let because there's a functional difference.
if (true) {
var x = 1;
}
console.log(x); // > 1
if (true) {
let x = 1;
}
console.log(x); // > undefined
a "let" defined inside an indented block will not exist outside of that block. That generally makes for better and cleaner code, but it does mean that changing var to let could cause some rewriting
Refactor long unreadable commands
This one's a running project. There's a lot of long, unreadable commands. We should refactor them to be less long and/or more readable.
Commands broken after the recent update
.pointlog does not work
.adduser player list calc is correct, but other players (other than 1st/2nd) don't get points
.addspecial doesn't give the response from Sir. Vivor "x points have been added to "
some commands with Sir Vivor output responses aren't validating (such as .adduser, rpoints)
Refactor Game Types
gameTypes
is an incredibly large and hard to maintain list in commands.js
right now. I propose we mode it to its own file, import it, and change the formatting slightly to something more unified
const gameTypes = {
avoidance: {
name: 'Avoidance',
url: 'https://sites.google.com/view/survivor-ps/themes/avoidance',
description: 'The trick is to pick the number that makes you not lose.',
// other properties go here
}
}
to-do:
- move game types to its own file
commands/game-types.js
- import the new file in commands.js
- Figure out what the numbers are for in the current gameTypes variable.
- convert all game types to the new format
- find all code that uses the gameTypes variable and make sure it supports the new format
- do the same for
eventTypes
- do the same for
modTypes
Split commands into different files
I'll probably have to tackle this one myself eventually as I have quite a clear vision of how I want to do it. The goal here is to remove clutter from commands.js
which right now has a lot of sections, eg:
/**
* Help commands
*
* These commands are here to provide information about the bot.
*/
git: function (arg, user, room) {
/**
* Dev commands
*
* These commands are here for highly ranked users (or the creator) to use
* to perform arbitrary actions that can't be done through any other commands
* or to help with upkeep of the bot.
*/
encrypt: function (target, user, room) {
Each of these sections could just as well be their own file: commands/help.js
and commands/dev.js
for example
Fix .reload
Tested .reload; some commands will work but others will not. Would be convenient to have working.
Some commands I tested after using reload after making changes to commands.js:
.pq - worked
.hostban - nothing
.hostbanned - nothing
.roast - nothing
Remove old PM syntax from commands
git: function (arg, user, room) {
let prefix = user.hasRank(room, '+') ? '' : '/pm ' + user.id + ', ';
let text = !Config.fork ? "No source code link found." : "The source code for this bot can be found here: " + Config.fork;
room.say(prefix + text);
},
there's a stupid amount of commands that do this prefix
thing. We can refactor this as follows:
git: function (arg, user, room) {
let target = user.hasRank(room, '+') ? room : user;
let text = !Config.fork ? "No source code link found." : "The source code for this bot can be found here: " + Config.fork;
target.say(text);
},
- Go over commands.js and incorporate this where you can
Can't move Games.js to classes folder
When I move 'game.js' to /classes and execute .signups [theme], getFormat() assigns undefined to the format object that is used in the createGame function. I suspect it has to do with bad file pathing involving the /games folder referenced in 'games.js' but I couldn't figure it out.
.signups avoidance -> createGame('avoidance', 'survivor') -> format = getFormat('avoidance') -> Game.lastGame = format.baseId -> ERROR
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.