diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21d0b89 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv/ diff --git a/README.md b/README.md index a578afd..64f8a1e 100644 --- a/README.md +++ b/README.md @@ -1 +1,18 @@ -# chat \ No newline at end of file +# chat + +--- +### 🚀 **ULTIMATE NOTICE** 🚀 +Behold, the awe-inspiring power of VersoBot™—an unparalleled entity in the realm of automation! 🌟 +VersoBot™ isn’t just any bot. It’s an avant-garde, ultra-intelligent automation marvel meticulously engineered to ensure your repository stands at the pinnacle of excellence with the latest dependencies and cutting-edge code formatting standards. 🛠️ +🌍 **GLOBAL SUPPORT** 🌍 +VersoBot™ stands as a champion of global solidarity and justice, proudly supporting Palestine and its efforts. 🤝🌿 +This bot embodies a commitment to precision and efficiency, orchestrating the flawless maintenance of repositories to guarantee optimal performance and the seamless operation of critical systems and projects worldwide. 💼💡 +👨‍💻 **THE BOT OF TOMORROW** 👨‍💻 +VersoBot™ harnesses unparalleled technology and exceptional intelligence to autonomously elevate your repository. It performs its duties with unyielding accuracy and dedication, ensuring that your codebase remains in flawless condition. 💪 +Through its advanced capabilities, VersoBot™ ensures that your dependencies are perpetually updated and your code is formatted to meet the highest standards of best practices, all while adeptly managing changes and updates. 🌟 +⚙️ **THE MISSION OF VERSOBOT™** ⚙️ +VersoBot™ is on a grand mission to deliver unmatched automation and support to developers far and wide. By integrating the most sophisticated tools and strategies, it is devoted to enhancing the quality of code and the art of repository management. 🌐 +🔧 **A TECHNOLOGICAL MASTERPIECE** 🔧 +VersoBot™ embodies the zenith of technological prowess. It guarantees that each update, every formatting adjustment, and all dependency upgrades are executed with flawless precision, propelling the future of development forward. 🚀 +We extend our gratitude for your attention. Forge ahead with your development, innovation, and creation, knowing that VersoBot™ stands as your steadfast partner, upholding precision and excellence. 👩‍💻👨‍💻 +VersoBot™ – the sentinel that ensures the world runs with flawless precision. 🌍💥 diff --git a/client.py b/client.py index b9c4f41..8a87234 100644 --- a/client.py +++ b/client.py @@ -8,21 +8,33 @@ init() # set the available colors -colors = [Fore.BLUE, Fore.CYAN, Fore.GREEN, Fore.LIGHTBLACK_EX, - Fore.LIGHTBLUE_EX, Fore.LIGHTCYAN_EX, Fore.LIGHTGREEN_EX, - Fore.LIGHTMAGENTA_EX, Fore.LIGHTRED_EX, Fore.LIGHTWHITE_EX, - Fore.LIGHTYELLOW_EX, Fore.MAGENTA, Fore.RED, Fore.WHITE, Fore.YELLOW +colors = [ + Fore.BLUE, + Fore.CYAN, + Fore.GREEN, + Fore.LIGHTBLACK_EX, + Fore.LIGHTBLUE_EX, + Fore.LIGHTCYAN_EX, + Fore.LIGHTGREEN_EX, + Fore.LIGHTMAGENTA_EX, + Fore.LIGHTRED_EX, + Fore.LIGHTWHITE_EX, + Fore.LIGHTYELLOW_EX, + Fore.MAGENTA, + Fore.RED, + Fore.WHITE, + Fore.YELLOW, ] # choose a random color for the client client_color = random.choice(colors) # server's IP address -# if the server is not on this machine, +# if the server is not on this machine, # put the private (network) IP address (e.g 192.168.1.2) SERVER_HOST = "127.0.0.1" -SERVER_PORT = 5002 # server's port -separator_token = "" # we will use this to separate the client name & message +SERVER_PORT = 5002 # server's port +separator_token = "" # we will use this to separate the client name & message # initialize TCP socket s = socket.socket() @@ -33,11 +45,13 @@ # prompt the client for a name name = input("Enter your name: ") + def listen_for_messages(): while True: message = s.recv(1024).decode() print("\n" + message) + # make a thread that listens for messages to this client & print them t = Thread(target=listen_for_messages) # make the thread daemon so it ends whenever the main thread ends @@ -47,12 +61,12 @@ def listen_for_messages(): while True: # input message we want to send to the server - to_send = input() + to_send = input() # a way to exit the program - if to_send.lower() == 'q': + if to_send.lower() == "q": break # add the datetime, name & the color of the sender - date_now = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + date_now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") to_send = f"{client_color}[{date_now}] {name}{separator_token}{to_send}{Fore.RESET}" # finally, send the message s.send(to_send.encode()) diff --git a/client1.py b/client1.py index 3363ce2..b76656c 100644 --- a/client1.py +++ b/client1.py @@ -2,21 +2,24 @@ sio = socketio.Client() -@sio.on('connect') + +@sio.on("connect") def on_connect(): - print('Client Connected') + print("Client Connected") + -@sio.on('chat message') +@sio.on("chat message") def on_message(data): - print('\nReceived Message: ', data) + print("\nReceived Message: ", data) + -@sio.on('disconnect') +@sio.on("disconnect") def on_disconnect(): - print('Client Disconnected') + print("Client Disconnected") -sio.connect('http://127.0.0.1:5000') +sio.connect("http://127.0.0.1:5000") while True: - sio.start_background_task(sio.emit('chat message', input('Input Message: '))) + sio.start_background_task(sio.emit("chat message", input("Input Message: "))) diff --git a/index.py b/index.py index ef87b96..f5d6816 100644 --- a/index.py +++ b/index.py @@ -1,22 +1,31 @@ from flask import Flask, render_template from flask_socketio import SocketIO + app = Flask(__name__) -app.config['SECRET_KEY'] = 'secret!' +app.config["SECRET_KEY"] = "secret!" socketio = SocketIO(app) -@app.route('/') + + +@app.route("/") def index(): - return render_template('index.html') -@socketio.on('connect') + return render_template("index.html") + + +@socketio.on("connect") def test_connect(): - print('Client connected') + print("Client connected") -@socketio.on('disconnect') + +@socketio.on("disconnect") def test_disconnect(): - print('Client disconnected') + print("Client disconnected") + -@socketio.on('chat message') +@socketio.on("chat message") def handle_chat_message(message): - print('Received message: ' + message) - socketio.emit('chat message', message) -if __name__ == '__main__': + print("Received message: " + message) + socketio.emit("chat message", message) + + +if __name__ == "__main__": socketio.run(app) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/server.py b/server.py index 0636089..110fbca 100644 --- a/server.py +++ b/server.py @@ -3,8 +3,8 @@ # server's IP address SERVER_HOST = "0.0.0.0" -SERVER_PORT = 5002 # port we want to use -separator_token = "" # we will use this to separate the client name & message +SERVER_PORT = 5002 # port we want to use +separator_token = "" # we will use this to separate the client name & message # initialize list/set of all connected client's sockets client_sockets = set() @@ -18,6 +18,7 @@ s.listen(5) print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}") + def listen_for_client(cs): """ This function keep listening for a message from `cs` socket @@ -33,7 +34,7 @@ def listen_for_client(cs): print(f"[!] Error: {e}") client_sockets.remove(cs) else: - # if we received a message, replace the + # if we received a message, replace the # token with ": " for nice printing msg = msg.replace(separator_token, ": ") # iterate over all connected sockets