Added join/leave messages a-la fore.st

This commit is contained in:
rainbow napkin 2026-10-15 01:15:36 -04:00
parent a0f680c02a
commit d0ef60dd4f
6 changed files with 119 additions and 10 deletions

View file

@ -14,6 +14,9 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
//config imports
const config = require('../../../config.json');
//local imports
const connectedUser = require('./connectedUser');
const chatBuffer = require('./chatBuffer');
@ -77,6 +80,61 @@ class activeChannel{
* Child Chat Buffer Object
*/
this.chatBuffer = new chatBuffer(server, chanDB, this);
this.userAnnouncements = {
join: [
"%UNAME% joined.",
"%UNAME% arrived.",
"%UNAME% appeared.",
"%UNAME% hopped in.",
"%UNAME% checked in.",
"%UNAME% checked in to see what condition their condition was in.",
"%UNAME% logged in.",
"%UNAME% turned on, tuned in, and dropped out.",
`%UNAME% is now using ${config.instanceName}.`,
`%UNAME% is now watching #${this.name}.`,
"%UNAME% tuned in.",
"%UNAME% is ready to sparkem.",
"%UNAME% connected.",
"%UNAME% joins the battle.",
"%UNAME% hopped on.",
"%UNAME% logged on.",
`${config.instanceName}, population: %UNAME%`,
"Welcome, %UNAME%.",
"Salutations, %UNAME%.",
"Hello, %UNAME%.",
"Greetings, %UNAME%.",
"Sup, %UNAME%.",
"I AM THE GOD OF HELLFIRE, AND I BRING YOU: %UNAME%!",
"A wild %UNAME% has appeared!"
],
leave: [
"%UNAME% left.",
"%UNAME% dropped out.",
"%UNAME% checked out.",
"%UNAME% quit.",
"%UNAME% is no longer with us.",
`%UNAME% is no longer using ${config.instanceName}.`,
"%UNAME% dipped.",
"%UNAME% booked it.",
"%UNAME% cheesed it.",
"%UNAME% vanished.",
"%UNAME% said dueces.",
"%UNAME% has left the building.",
"%UNAME% bounced.",
"%UNAME% is beyond the horizon.",
"%UNAME% has drifted into space.",
"%UNAME% is outskies.",
"%UNAME% went to the shadow realm.",
"Goodbye, %UNAME%.",
"Dueces, %UNAME%.",
"Bye, %UNAME%.",
"Farewell, %UNAME%.",
"l8r %UNAME%.",
"That'll do, %UNAME%."
]
}
}
@ -150,6 +208,9 @@ class activeChannel{
//If this is the last connection for this user, remove them from the userlist
this.userList.delete(socket.user.user);
//Broadcast the un-welcome wagon
this.welcomeWagon(socket.user.user, true);
}
//and send out the filtered list
@ -195,6 +256,20 @@ class activeChannel{
//Broadcast that sumbitch
this.server.io.in(this.name).emit('chanEmotes', emoteList);
}
/**
* Basic function to welcome/send off connecting/disconnecting users
* @param {string} user - user to welcome
* @param {boolean} leaving - true if user is leaving instead of joining
*/
async welcomeWagon(user, leaving = false){
//Grab the applicable list depending on if the user is leaving or not
const activeList = leaving ? this.userAnnouncements.leave : this.userAnnouncements.join;
//Randomly yoink the applicable message
const msg = activeList[Math.floor(Math.random() * activeList.length)];
this.server.chatHandler.relayChat(user, "", 0, msg.replace("%UNAME%", user), "serverwhisper", this.name, []);
}
}
module.exports = activeChannel;