Added site-wide emote support.
This commit is contained in:
parent
41d0302ded
commit
97717b525c
11 changed files with 122 additions and 22 deletions
|
|
@ -55,6 +55,7 @@ module.exports = class{
|
|||
//Make sure the client receives important client-info before userlist
|
||||
//await this.sendClientMetadata(userDB, socket);
|
||||
await userObj.sendClientMetadata();
|
||||
await userObj.sendSiteEmotes();
|
||||
|
||||
//Send out the userlist
|
||||
this.broadcastUserList(socket.chan);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
|
||||
//Local Imports
|
||||
const channelModel = require('../../schemas/channel/channelSchema');
|
||||
const emoteModel = require('../../schemas/emoteSchema');
|
||||
const {userModel} = require('../../schemas/userSchema');
|
||||
const loggerUtils = require('../../utils/loggerUtils');
|
||||
const activeChannel = require('./activeChannel');
|
||||
|
|
@ -181,4 +182,12 @@ module.exports = class{
|
|||
//crawl through connections and kick user
|
||||
this.crawlConnections(user,(foundUser)=>{foundUser.disconnect(reason)});
|
||||
}
|
||||
|
||||
async broadcastSiteEmotes(){
|
||||
//Get emote list from DB
|
||||
const emoteList = await emoteModel.getEmotes();
|
||||
|
||||
//Broadcast that sumbitch
|
||||
this.io.sockets.emit('siteEmotes', emoteList);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
|
||||
//local imports
|
||||
const flairModel = require('../../schemas/flairSchema');
|
||||
const emoteModel = require('../../schemas/emoteSchema');
|
||||
const permissionModel = require('../../schemas/permissionSchema');
|
||||
|
||||
module.exports = class{
|
||||
|
|
@ -87,6 +88,14 @@ module.exports = class{
|
|||
this.emit("clientMetadata", {user: userObj, flairList});
|
||||
}
|
||||
|
||||
async sendSiteEmotes(){
|
||||
//Get emote list from DB
|
||||
const emoteList = await emoteModel.getEmotes();
|
||||
|
||||
//Send it off to the user
|
||||
this.emit('siteEmotes', emoteList);
|
||||
}
|
||||
|
||||
updateFlair(flair){
|
||||
this.flair = flair;
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ module.exports = class tokebot{
|
|||
|
||||
tokeProcessor(commandObj){
|
||||
//Check for site-wide toke commands
|
||||
if(this.tokeCommands.indexOf(commandObj.argumentArray[0]) != -1){
|
||||
if(this.tokeCommands.indexOf(commandObj.argumentArray[0].toLowerCase()) != -1){
|
||||
//Seems lame to set a bool in an if statement but this would've made a really ugly turinary
|
||||
var foundToke = true;
|
||||
}else{
|
||||
|
|
@ -62,7 +62,7 @@ module.exports = class tokebot{
|
|||
|
||||
//Check if they're using a channel-only toke
|
||||
//This should be safe to do without a null check but someone prove me wrong lmao
|
||||
var foundToke = (activeChan.tokeCommands.indexOf(commandObj.argumentArray[0]) != -1);
|
||||
var foundToke = (activeChan.tokeCommands.indexOf(commandObj.argumentArray[0].toLowerCase()) != -1);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ module.exports = class tokebot{
|
|||
this.tokeCounter = this.tokeTime;
|
||||
|
||||
//Add the toking user to the tokers map
|
||||
this.tokers.set(commandObj.socket.user.user, commandObj.argumentArray[0]);
|
||||
this.tokers.set(commandObj.socket.user.user, commandObj.argumentArray[0].toLowerCase());
|
||||
|
||||
//kick-off the count-down
|
||||
this.tokeTimer = setTimeout(this.countdown.bind(this), 1000)
|
||||
|
|
@ -91,7 +91,7 @@ module.exports = class tokebot{
|
|||
this.chatHandler.relayTokeCallout(`${commandObj.socket.user.user} has joined the toke from #${commandObj.socket.chan}! Post !${commandObj.argumentArray[0]} to take part!`);
|
||||
|
||||
//Add the toking user to the tokers map
|
||||
this.tokers.set(commandObj.socket.user.user, commandObj.argumentArray[0]);
|
||||
this.tokers.set(commandObj.socket.user.user, commandObj.argumentArray[0].toLowerCase());
|
||||
//If the user is already in the toke
|
||||
}else{
|
||||
//Tell them to fuck off
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ const {mongoose} = require('mongoose');
|
|||
|
||||
//Local Imports
|
||||
const defaultEmote = require("../../defaultEmotes.json");
|
||||
const server = require('../server');
|
||||
|
||||
const typeEnum = ["image", "video"];
|
||||
|
||||
|
|
@ -39,6 +40,19 @@ const emoteSchema = new mongoose.Schema({
|
|||
}
|
||||
});
|
||||
|
||||
//pre-save function
|
||||
emoteSchema.post('save', async function (next){
|
||||
//broadcast updated emotes
|
||||
server.channelManager.broadcastSiteEmotes();
|
||||
});
|
||||
|
||||
//post-delete function (document not query)
|
||||
emoteSchema.post('deleteOne', {document: true}, async function (next){
|
||||
//broadcast updated emotes
|
||||
server.channelManager.broadcastSiteEmotes();
|
||||
});
|
||||
|
||||
//statics
|
||||
emoteSchema.statics.loadDefaults = async function(){
|
||||
//Make sure registerEmote function is happy
|
||||
const _this = this;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue