Added !serverannounce command.
This commit is contained in:
parent
375cdfb3d8
commit
df18b4d783
|
|
@ -84,6 +84,11 @@ module.exports = class{
|
||||||
this.server.io.in(socket.chan).emit("chatMessage", {user: user.user, flair: user.flair, highLevel: user.highLevel, msg, type});
|
this.server.io.in(socket.chan).emit("chatMessage", {user: user.user, flair: user.flair, highLevel: user.highLevel, msg, type});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
relayServerAnnouncement(msg){
|
||||||
|
//This codebase is always at a 10
|
||||||
|
this.server.io.emit("chatMessage", {user: "Server", flair: "", highLevel: 10, msg, type: "announcement"});
|
||||||
|
}
|
||||||
|
|
||||||
relayChannelAnnouncement(socket, msg){
|
relayChannelAnnouncement(socket, msg){
|
||||||
//This codebase is always at a 10
|
//This codebase is always at a 10
|
||||||
this.server.io.in(socket.chan).emit("chatMessage", {user: "Channel", flair: "", highLevel: 10, msg, type: "announcement"});
|
this.server.io.in(socket.chan).emit("chatMessage", {user: "Channel", flair: "", highLevel: 10, msg, type: "announcement"});
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||||
const validator = require('validator');//No express here, so regular validator it is!
|
const validator = require('validator');//No express here, so regular validator it is!
|
||||||
|
|
||||||
//Local Imports
|
//Local Imports
|
||||||
|
const permissionModel = require('../../schemas/permissionSchema');
|
||||||
const channelModel = require('../../schemas/channel/channelSchema');
|
const channelModel = require('../../schemas/channel/channelSchema');
|
||||||
|
|
||||||
module.exports = class commandPreprocessor{
|
module.exports = class commandPreprocessor{
|
||||||
|
|
@ -112,4 +113,14 @@ class commandProcessor{
|
||||||
this.server.chatHandler.relayChannelAnnouncement(this.preprocessor.socket, this.preprocessor.commandArray.join(''));
|
this.server.chatHandler.relayChannelAnnouncement(this.preprocessor.socket, this.preprocessor.commandArray.join(''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async serverannounce(){
|
||||||
|
//Check if the user has permission, and publicly shame them if they don't (lmao)
|
||||||
|
if(!(this.preprocessor.sendFlag = !(await permissionModel.permCheck(this.preprocessor.socket.user, 'announce')))){
|
||||||
|
//splice out our whisper
|
||||||
|
this.preprocessor.commandArray.splice(0,2);
|
||||||
|
//send it
|
||||||
|
this.server.chatHandler.relayServerAnnouncement(this.preprocessor.commandArray.join(''));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,6 +18,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||||
const {mongoose} = require('mongoose');
|
const {mongoose} = require('mongoose');
|
||||||
|
|
||||||
//Local Imports
|
//Local Imports
|
||||||
|
//const {userModel} = require('./userSchema');
|
||||||
|
const userSchema = require('./userSchema');
|
||||||
const channelPermissionSchema = require('./channel/channelPermissionSchema');
|
const channelPermissionSchema = require('./channel/channelPermissionSchema');
|
||||||
|
|
||||||
//This originally belonged to the permissionSchema, but this avoids circular dependencies.
|
//This originally belonged to the permissionSchema, but this avoids circular dependencies.
|
||||||
|
|
@ -43,6 +45,12 @@ const permissionSchema = new mongoose.Schema({
|
||||||
default: "admin",
|
default: "admin",
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
announce: {
|
||||||
|
type: mongoose.SchemaTypes.String,
|
||||||
|
enum: rankEnum,
|
||||||
|
default: "admin",
|
||||||
|
required: true
|
||||||
|
},
|
||||||
banUser: {
|
banUser: {
|
||||||
type: mongoose.SchemaTypes.String,
|
type: mongoose.SchemaTypes.String,
|
||||||
enum: rankEnum,
|
enum: rankEnum,
|
||||||
|
|
@ -105,6 +113,11 @@ permissionSchema.statics.rankToNum = function(rank){
|
||||||
}
|
}
|
||||||
|
|
||||||
permissionSchema.statics.permCheck = async function(user, perm){
|
permissionSchema.statics.permCheck = async function(user, perm){
|
||||||
|
const userDB = await userSchema.userModel.findOne({user: user.user});
|
||||||
|
return await this.permCheckByUserDoc(userDB, perm);
|
||||||
|
}
|
||||||
|
|
||||||
|
permissionSchema.statics.permCheckByUserDoc = async function(user, perm){
|
||||||
//Get permission list
|
//Get permission list
|
||||||
const perms = await this.getPerms();
|
const perms = await this.getPerms();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,12 @@ module.exports.permissionsValidator = {
|
||||||
options: module.exports.isRank
|
options: module.exports.isRank
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'permissionsMap.announce': {
|
||||||
|
optional: true,
|
||||||
|
custom: {
|
||||||
|
options: module.exports.isRank
|
||||||
|
},
|
||||||
|
},
|
||||||
'permissionsMap.banUser': {
|
'permissionsMap.banUser': {
|
||||||
optional: true,
|
optional: true,
|
||||||
custom: {
|
custom: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue