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

View File

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

View File

@ -1,8 +1,7 @@
const Channel = require("./Channel.js");
const Quota = require ("./Quota.js");
const quotas = require('../Quotas');
const RateLimit = require('./Ratelimit.js').RateLimit;
const RateLimitChain = require('./Ratelimit.js').RateLimitChain;
const { RateLimit, RateLimitChain } = require('./Ratelimit.js');
const User = require("./User.js");
const Database = require("./Database.js");
const { EventEmitter } = require('events');
@ -97,13 +96,13 @@ class Client extends EventEmitter {
Database.getUserData(this, this.server).then((usr) => {
if (!this.user.hasFlag('freeze_name', true)) {
Database.updateUser(this.user._id, this.user);
}
this.server.rooms.forEach((room) => {
room.updateParticipant(this.user._id, {
name: name
});
});
}
});
}
@ -180,10 +179,30 @@ class Client extends EventEmitter {
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 = {
channels
};
data.clientManager = {
users
}
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;
let interval = 8000;
if ('interval_ms' in msg) interval = msg['interval_ms'];
cl.sendAdminData();
cl.adminStreamInterval = setInterval(() => {
if (cl.isSubscribedToAdminStream == true) cl.sendAdminData();
}, interval);

View File

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

View File

@ -1539,6 +1539,11 @@ undefsafe@^2.0.5:
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
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:
version "2.0.0"
resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-2.0.0.tgz#39c6451f81afb2749de2b233e3f7c5e8843bd89d"