This commit is contained in:
Hri7566 2022-08-16 06:23:21 -04:00
parent d16afcfc6d
commit ec2d3b5929
6 changed files with 64 additions and 9 deletions

View File

@ -33,6 +33,7 @@
"mongoose": "^5.12.7", "mongoose": "^5.12.7",
"mppclone-client": "^1.0.0", "mppclone-client": "^1.0.0",
"nodemon": "^2.0.15", "nodemon": "^2.0.15",
"unique-names-generator": "^4.7.1",
"ws": "^7.2.3" "ws": "^7.2.3"
} }
} }

View File

@ -1,8 +1,7 @@
const Channel = require("./Channel.js"); const Channel = require("./Channel.js");
const Quota = require ("./Quota.js"); const Quota = require ("./Quota.js");
const quotas = require('../Quotas'); const quotas = require('../Quotas');
const RateLimit = require('./Ratelimit.js').RateLimit; const { RateLimit, RateLimitChain } = require('./Ratelimit.js');
const RateLimitChain = require('./Ratelimit.js').RateLimitChain;
const User = require("./User.js"); const User = require("./User.js");
const Database = require("./Database.js"); const Database = require("./Database.js");
const { EventEmitter } = require('events'); const { EventEmitter } = require('events');
@ -97,13 +96,13 @@ class Client extends EventEmitter {
Database.getUserData(this, this.server).then((usr) => { Database.getUserData(this, this.server).then((usr) => {
if (!this.user.hasFlag('freeze_name', true)) { if (!this.user.hasFlag('freeze_name', true)) {
Database.updateUser(this.user._id, this.user); Database.updateUser(this.user._id, this.user);
}
this.server.rooms.forEach((room) => { this.server.rooms.forEach((room) => {
room.updateParticipant(this.user._id, { room.updateParticipant(this.user._id, {
name: name name: name
}); });
}); });
}
}); });
} }
@ -180,10 +179,30 @@ class Client extends EventEmitter {
channels.push(ch.fetchChannelData()); channels.push(ch.fetchChannelData());
}); });
let users = [];
this.server.connections.forEach(cl => {
let u = {
p: {
_id: cl.user._id,
name: cl.user.name,
color: cl.user.color,
flags: cl.user.flags,
inventory: cl.user.inventory
},
id: cl.participantId,
}
users.push(u);
});
data.channelManager = { data.channelManager = {
channels channels
}; };
data.clientManager = {
users
}
this.sendArray([data]); this.sendArray([data]);
} }

21
src/Cow.js Normal file
View File

@ -0,0 +1,21 @@
const ung = requre('unique-names-generator');
const ung_config = {
dictionaries: [ung.adjectives, ung.colors],
separator: ' ',
length: 2
}
class Cow {
static generateRandomName() {
return ung.uniqueNamesGenerator(ung_config);
}
constructor() {
this['🐄'] = Cow.generateRandomName();
}
}
module.exports = {
Cow
}

View File

@ -364,6 +364,7 @@ module.exports = (cl) => {
cl.isSubscribedToAdminStream = true; cl.isSubscribedToAdminStream = true;
let interval = 8000; let interval = 8000;
if ('interval_ms' in msg) interval = msg['interval_ms']; if ('interval_ms' in msg) interval = msg['interval_ms'];
cl.sendAdminData();
cl.adminStreamInterval = setInterval(() => { cl.adminStreamInterval = setInterval(() => {
if (cl.isSubscribedToAdminStream == true) cl.sendAdminData(); if (cl.isSubscribedToAdminStream == true) cl.sendAdminData();
}, interval); }, interval);

View File

@ -19,8 +19,16 @@ class User {
this.color = data.color; this.color = data.color;
this.flags = typeof data.flags == "object" ? data.flags : { this.flags = typeof data.flags == "object" ? data.flags : {
volume: 100, volume: 100,
"no chat rate limit": false "no chat rate limit": false,
freeze_name: false
} }
this.inventory = {
'test': {
display_name: 'Test',
count: 1
}
};
} }
getPublicUser() { getPublicUser() {

View File

@ -1539,6 +1539,11 @@ undefsafe@^2.0.5:
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c" resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA== integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==
unique-names-generator@^4.7.1:
version "4.7.1"
resolved "https://registry.yarnpkg.com/unique-names-generator/-/unique-names-generator-4.7.1.tgz#966407b12ba97f618928f77322cfac8c80df5597"
integrity sha512-lMx9dX+KRmG8sq6gulYYpKWZc9RlGsgBR6aoO8Qsm3qvkSJ+3rAymr+TnV8EDMrIrwuFJ4kruzMWM/OpYzPoow==
unique-string@^2.0.0: unique-string@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-2.0.0.tgz#39c6451f81afb2749de2b233e3f7c5e8843bd89d" resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-2.0.0.tgz#39c6451f81afb2749de2b233e3f7c5e8843bd89d"