From edf61f0462339d9798288d14c45a53ef58964b9d Mon Sep 17 00:00:00 2001 From: MrMasrozYTLIVE <61359286+MrMasrozYTLIVE@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:34:50 +0300 Subject: [PATCH] Started working on proper classes for messages (files and text), user peer class, chatroom class --- chatBot/bot.js | 2 +- chatBot/includes/{chatroom.js => ChatRoom.js} | 2 -- chatBot/includes/{client.js => Client.js} | 0 chatBot/includes/FileMessage.js | 12 ++++++++++++ chatBot/includes/TextMessage.js | 10 ++++++++++ chatBot/includes/UserPeer.js | 10 ++++++++++ 6 files changed, 33 insertions(+), 3 deletions(-) rename chatBot/includes/{chatroom.js => ChatRoom.js} (98%) rename chatBot/includes/{client.js => Client.js} (100%) create mode 100644 chatBot/includes/FileMessage.js create mode 100644 chatBot/includes/TextMessage.js create mode 100644 chatBot/includes/UserPeer.js diff --git a/chatBot/bot.js b/chatBot/bot.js index c1359b9..2dcb9ba 100644 --- a/chatBot/bot.js +++ b/chatBot/bot.js @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import Client from './includes/client.js'; // Adjust the import path as necessary +import Client from './includes/Client.js'; // Adjust the import path as necessary import 'dotenv/config'; // Create a new instance of the chatBot class with a valid botName diff --git a/chatBot/includes/chatroom.js b/chatBot/includes/ChatRoom.js similarity index 98% rename from chatBot/includes/chatroom.js rename to chatBot/includes/ChatRoom.js index 89b2afe..0686013 100644 --- a/chatBot/includes/chatroom.js +++ b/chatBot/includes/ChatRoom.js @@ -3,8 +3,6 @@ class ChatRoom { this.topic = topic; this.peers = peers; } - - } export default ChatRoom; \ No newline at end of file diff --git a/chatBot/includes/client.js b/chatBot/includes/Client.js similarity index 100% rename from chatBot/includes/client.js rename to chatBot/includes/Client.js diff --git a/chatBot/includes/FileMessage.js b/chatBot/includes/FileMessage.js new file mode 100644 index 0000000..55d58b4 --- /dev/null +++ b/chatBot/includes/FileMessage.js @@ -0,0 +1,12 @@ +class FileMessage { + public FileMessage(chatRoom, userPeer, fileName, fileUrl, fileType, timestamp) { + this.chatRoom = chatRoom; + this.userPeer = userPeer; + this.fileName = fileName; + this.fileUrl = fileUrl; + this.fileType = fileType; + this.timestamp = timestamp; + } +} + +export default FileMessage; \ No newline at end of file diff --git a/chatBot/includes/TextMessage.js b/chatBot/includes/TextMessage.js new file mode 100644 index 0000000..f3a8021 --- /dev/null +++ b/chatBot/includes/TextMessage.js @@ -0,0 +1,10 @@ +class TextMessage { + public TextMessage(chatRoom, userPeer, message, timestamp) { + this.chatRoom = chatRoom; + this.userPeer = userPeer; + this.message = message; + this.timestamp = timestamp; + } +} + +export default TextMessage; \ No newline at end of file diff --git a/chatBot/includes/UserPeer.js b/chatBot/includes/UserPeer.js new file mode 100644 index 0000000..9546499 --- /dev/null +++ b/chatBot/includes/UserPeer.js @@ -0,0 +1,10 @@ +class UserPeer { + public UserPeer(peer, topics, username, avatar) { + this.peer = peer; + this.topics = topics; + this.username = username; + this.avatar = avatar; + } +} + +export default UserPeer; \ No newline at end of file