Added spoofed tokebot profile and nameplate, made registering as tokebot impossible.
This commit is contained in:
parent
1d3906247a
commit
58b6d18f26
|
|
@ -83,7 +83,12 @@ module.exports = class{
|
|||
}
|
||||
|
||||
broadcastUserList(){
|
||||
var userList = [];
|
||||
//Create a userlist object with the tokebot user pre-loaded
|
||||
var userList = [{
|
||||
user: "Tokebot",
|
||||
flair: "classic",
|
||||
highLevel: "∞",
|
||||
}];
|
||||
|
||||
this.userList.forEach((userObj, user) => {
|
||||
userList.push({
|
||||
|
|
|
|||
|
|
@ -97,20 +97,19 @@ module.exports = class{
|
|||
}
|
||||
|
||||
relayTokeCallout(msg){
|
||||
this.relayGlobalChat("Tokebot", "", 10, msg, "toke");
|
||||
this.relayGlobalChat("Tokebot", "", '∞', msg, "toke");
|
||||
}
|
||||
|
||||
relayTokeWhisper(socket, msg){
|
||||
this.relayServerWisper(socket, "Tokebot", "", 10, msg, "tokewhisper");
|
||||
this.relayServerWisper(socket, "Tokebot", "", '∞', msg, "tokewhisper");
|
||||
}
|
||||
|
||||
relayGlobalTokeWhisper(msg){
|
||||
this.relayGlobalChat("Tokebot", "", 10, msg, "tokewhisper");
|
||||
this.relayGlobalChat("Tokebot", "", '∞', msg, "tokewhisper");
|
||||
}
|
||||
|
||||
relayServerAnnouncement(msg){
|
||||
//This codebase is always at a 10
|
||||
this.relayGlobalChat("Server", "", 10, msg, "announcement");
|
||||
this.relayGlobalChat("Server", "", '∞', msg, "announcement");
|
||||
}
|
||||
|
||||
relayChannelAnnouncement(chan, msg){
|
||||
|
|
@ -118,8 +117,7 @@ module.exports = class{
|
|||
|
||||
//If channel isn't null
|
||||
if(activeChan != null){
|
||||
//This codebase is always at a 10
|
||||
this.relayChat("Channel", "", 10, msg, "announcement", chan);
|
||||
this.relayChat("Channel", "", '∞', msg, "announcement", chan);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,21 +27,13 @@ module.exports.get = async function(req, res){
|
|||
try{
|
||||
var profileName = req.url.slice(1) == '' ? (req.session.user ? req.session.user.user : null) : req.url.slice(1);
|
||||
|
||||
const userDB = await userModel.findOne({ user: profileName });
|
||||
const profile = await userModel.findProfile({user: profileName})
|
||||
|
||||
if(userDB){
|
||||
res.render('profile', {instance: config.instanceName,
|
||||
if(profile){
|
||||
res.render('profile', {
|
||||
instance: config.instanceName,
|
||||
user: req.session.user,
|
||||
profile: {
|
||||
id: userDB.id,
|
||||
user: userDB.user,
|
||||
date: userDB.date,
|
||||
tokes: userDB.tokes,
|
||||
tokeCount: userDB.getTokeCount(),
|
||||
img: userDB.img,
|
||||
signature: userDB.signature,
|
||||
bio: userDB.bio
|
||||
}
|
||||
profile
|
||||
});
|
||||
}else{
|
||||
res.render('profile', {instance: config.instanceName,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ const statSchema = new mongoose.Schema({
|
|||
required: true,
|
||||
default: 0
|
||||
},
|
||||
firstLaunch: {
|
||||
type: mongoose.SchemaTypes.Date,
|
||||
required: true,
|
||||
default: new Date()
|
||||
},
|
||||
tokes: [{
|
||||
toke: {
|
||||
type: mongoose.SchemaTypes.Map,
|
||||
|
|
@ -83,6 +88,7 @@ statSchema.statics.incrementLaunchCount = async function(){
|
|||
|
||||
//print bootup message to console.
|
||||
console.log(`${config.instanceName}(Powered by Canopy) initialized. This server has booted ${stats.launchCount} time${stats.launchCount == 1 ? '' : 's'}.`)
|
||||
console.log(`First booted on ${stats.firstLaunch}.`);
|
||||
}
|
||||
|
||||
statSchema.statics.incrementUserCount = async function(){
|
||||
|
|
@ -124,4 +130,40 @@ statSchema.statics.tattooToke = async function(toke){
|
|||
await stats.save();
|
||||
}
|
||||
|
||||
statSchema.statics.getTokeCount = async function(){
|
||||
//get stats doc
|
||||
const stats = await this.getStats();
|
||||
|
||||
//return toke count
|
||||
return stats.tokes.length;
|
||||
}
|
||||
|
||||
statSchema.statics.getTokeCommandCounts = async function(){
|
||||
//get stats doc
|
||||
const stats = await this.getStats()
|
||||
//Create empty map to hold toke command counts
|
||||
const count = new Map();
|
||||
|
||||
//for each toke
|
||||
stats.tokes.forEach((toke) => {
|
||||
//For each toke command called in the current toke
|
||||
toke.toke.forEach((command) => {
|
||||
//Get the current count for the current command
|
||||
var curCount = count.get(command);
|
||||
|
||||
//if the current count is null
|
||||
if(curCount == null){
|
||||
//Set it to one
|
||||
count.set(command, 1);
|
||||
}else{
|
||||
//Set it to ++curCount
|
||||
count.set(command, ++curCount);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//return the toke command count
|
||||
return count;
|
||||
}
|
||||
|
||||
module.exports = mongoose.model("statistics", statSchema);
|
||||
|
|
@ -22,6 +22,7 @@ const server = require('../server');
|
|||
const statModel = require('./statSchema');
|
||||
const flairModel = require('./flairSchema');
|
||||
const permissionModel = require('./permissionSchema');
|
||||
const statsModel = require('./statSchema');
|
||||
const hashUtil = require('../utils/hashUtils');
|
||||
|
||||
|
||||
|
|
@ -135,7 +136,8 @@ userSchema.statics.register = async function(userObj){
|
|||
if(pass == passConfirm){
|
||||
const userDB = await this.findOne({$or: email ? [{user}, {email}] : [{user}]});
|
||||
|
||||
if(userDB){
|
||||
//If the user is found or someones trying to impersonate tokeboi
|
||||
if(userDB || user.toLowerCase() == "tokebot"){
|
||||
throw new Error("User name/email already taken!");
|
||||
}else{
|
||||
const id = await statModel.incrementUserCount();
|
||||
|
|
@ -174,6 +176,38 @@ userSchema.statics.authenticate = async function(user, pass){
|
|||
}
|
||||
}
|
||||
|
||||
userSchema.statics.findProfile = async function(user){
|
||||
//If someone's looking for tokebot
|
||||
if(user.user.toLowerCase() == "tokebot"){
|
||||
//fake a profile hashtable for tokebot
|
||||
profile = {
|
||||
id: -420,
|
||||
user: "Tokebot",
|
||||
date: (await statModel.getStats()).firstLaunch,
|
||||
tokes: await statModel.getTokeCommandCounts(),
|
||||
tokeCount: await statModel.getTokeCount(),
|
||||
img: "/img/johnny.png",
|
||||
signature: "!TOKE",
|
||||
bio: "!TOKE OR DIE!"
|
||||
};
|
||||
|
||||
//return the faked profile
|
||||
return profile;
|
||||
}else{
|
||||
//find user
|
||||
const userDB = await this.findOne({user: user.user});
|
||||
|
||||
//If we don't find a user just return a null profile
|
||||
if(userDB == null){
|
||||
return null
|
||||
}
|
||||
|
||||
//return the profile
|
||||
return userDB.findProfile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
userSchema.statics.tattooToke = function(tokemap){
|
||||
//For each toke, asynchronously:
|
||||
tokemap.forEach(async (toke, user) => {
|
||||
|
|
@ -272,6 +306,23 @@ userSchema.statics.getUserList = async function(fullList = false){
|
|||
}
|
||||
|
||||
//methods
|
||||
userSchema.methods.getProfile = function(){
|
||||
//Create profile hashtable
|
||||
const profile = {
|
||||
id: this.id,
|
||||
user: this.user,
|
||||
date: this.date,
|
||||
tokes: this.tokes,
|
||||
tokeCount: this.getTokeCount(),
|
||||
img: this.img,
|
||||
signature: this.signature,
|
||||
bio: this.bio
|
||||
};
|
||||
|
||||
//return profile hashtable
|
||||
return profile;
|
||||
}
|
||||
|
||||
userSchema.methods.setFlair = async function(flair){
|
||||
//Find flair by name
|
||||
const flairDB = await flairModel.findOne({name: flair});
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.-->
|
|||
<%- include('partial/profile/image', {profile, selfProfile}); %>
|
||||
<%- include('partial/profile/tokeCount', {profile, selfProfile}); %>
|
||||
<%- include('partial/profile/signature', {profile, selfProfile}); %>
|
||||
<%- include('partial/profile/bio', {profile, selfProfile}); %>
|
||||
<%- include('partial/profile/date', {profile, selfProfile}); %>
|
||||
<%- include('partial/profile/badges', {profile, selfProfile}); %>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue