Added spoofed tokebot profile and nameplate, made registering as tokebot impossible.

This commit is contained in:
rainbow napkin 2024-12-15 18:20:29 -05:00
parent 1d3906247a
commit 58b6d18f26
6 changed files with 111 additions and 22 deletions

View file

@ -83,7 +83,12 @@ module.exports = class{
} }
broadcastUserList(){ 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) => { this.userList.forEach((userObj, user) => {
userList.push({ userList.push({

View file

@ -97,20 +97,19 @@ module.exports = class{
} }
relayTokeCallout(msg){ relayTokeCallout(msg){
this.relayGlobalChat("Tokebot", "", 10, msg, "toke"); this.relayGlobalChat("Tokebot", "", '∞', msg, "toke");
} }
relayTokeWhisper(socket, msg){ relayTokeWhisper(socket, msg){
this.relayServerWisper(socket, "Tokebot", "", 10, msg, "tokewhisper"); this.relayServerWisper(socket, "Tokebot", "", '∞', msg, "tokewhisper");
} }
relayGlobalTokeWhisper(msg){ relayGlobalTokeWhisper(msg){
this.relayGlobalChat("Tokebot", "", 10, msg, "tokewhisper"); this.relayGlobalChat("Tokebot", "", '∞', msg, "tokewhisper");
} }
relayServerAnnouncement(msg){ relayServerAnnouncement(msg){
//This codebase is always at a 10 this.relayGlobalChat("Server", "", '∞', msg, "announcement");
this.relayGlobalChat("Server", "", 10, msg, "announcement");
} }
relayChannelAnnouncement(chan, msg){ relayChannelAnnouncement(chan, msg){
@ -118,8 +117,7 @@ module.exports = class{
//If channel isn't null //If channel isn't null
if(activeChan != null){ if(activeChan != null){
//This codebase is always at a 10 this.relayChat("Channel", "", '∞', msg, "announcement", chan);
this.relayChat("Channel", "", 10, msg, "announcement", chan);
} }
} }

View file

@ -27,21 +27,13 @@ module.exports.get = async function(req, res){
try{ try{
var profileName = req.url.slice(1) == '' ? (req.session.user ? req.session.user.user : null) : req.url.slice(1); 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){ if(profile){
res.render('profile', {instance: config.instanceName, res.render('profile', {
instance: config.instanceName,
user: req.session.user, user: req.session.user,
profile: { 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
}
}); });
}else{ }else{
res.render('profile', {instance: config.instanceName, res.render('profile', {instance: config.instanceName,

View file

@ -37,6 +37,11 @@ const statSchema = new mongoose.Schema({
required: true, required: true,
default: 0 default: 0
}, },
firstLaunch: {
type: mongoose.SchemaTypes.Date,
required: true,
default: new Date()
},
tokes: [{ tokes: [{
toke: { toke: {
type: mongoose.SchemaTypes.Map, type: mongoose.SchemaTypes.Map,
@ -83,6 +88,7 @@ statSchema.statics.incrementLaunchCount = async function(){
//print bootup message to console. //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(`${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(){ statSchema.statics.incrementUserCount = async function(){
@ -124,4 +130,40 @@ statSchema.statics.tattooToke = async function(toke){
await stats.save(); 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); module.exports = mongoose.model("statistics", statSchema);

View file

@ -22,6 +22,7 @@ const server = require('../server');
const statModel = require('./statSchema'); const statModel = require('./statSchema');
const flairModel = require('./flairSchema'); const flairModel = require('./flairSchema');
const permissionModel = require('./permissionSchema'); const permissionModel = require('./permissionSchema');
const statsModel = require('./statSchema');
const hashUtil = require('../utils/hashUtils'); const hashUtil = require('../utils/hashUtils');
@ -135,7 +136,8 @@ userSchema.statics.register = async function(userObj){
if(pass == passConfirm){ if(pass == passConfirm){
const userDB = await this.findOne({$or: email ? [{user}, {email}] : [{user}]}); 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!"); throw new Error("User name/email already taken!");
}else{ }else{
const id = await statModel.incrementUserCount(); 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){ userSchema.statics.tattooToke = function(tokemap){
//For each toke, asynchronously: //For each toke, asynchronously:
tokemap.forEach(async (toke, user) => { tokemap.forEach(async (toke, user) => {
@ -272,6 +306,23 @@ userSchema.statics.getUserList = async function(fullList = false){
} }
//methods //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){ userSchema.methods.setFlair = async function(flair){
//Find flair by name //Find flair by name
const flairDB = await flairModel.findOne({name: flair}); const flairDB = await flairModel.findOne({name: flair});

View file

@ -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/image', {profile, selfProfile}); %>
<%- include('partial/profile/tokeCount', {profile, selfProfile}); %> <%- include('partial/profile/tokeCount', {profile, selfProfile}); %>
<%- include('partial/profile/signature', {profile, selfProfile}); %> <%- include('partial/profile/signature', {profile, selfProfile}); %>
<%- include('partial/profile/bio', {profile, selfProfile}); %>
<%- include('partial/profile/date', {profile, selfProfile}); %> <%- include('partial/profile/date', {profile, selfProfile}); %>
<%- include('partial/profile/badges', {profile, selfProfile}); %> <%- include('partial/profile/badges', {profile, selfProfile}); %>
</div> </div>