Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv/
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# chat
# 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. 🌍💥
34 changes: 24 additions & 10 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<SEP>" # we will use this to separate the client name & message
SERVER_PORT = 5002 # server's port
separator_token = "<SEP>" # we will use this to separate the client name & message

# initialize TCP socket
s = socket.socket()
Expand All @@ -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
Expand All @@ -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())
Expand Down
19 changes: 11 additions & 8 deletions client1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: ")))
31 changes: 20 additions & 11 deletions index.py
Original file line number Diff line number Diff line change
@@ -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)
Empty file added requirements.txt
Empty file.
7 changes: 4 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

# server's IP address
SERVER_HOST = "0.0.0.0"
SERVER_PORT = 5002 # port we want to use
separator_token = "<SEP>" # we will use this to separate the client name & message
SERVER_PORT = 5002 # port we want to use
separator_token = "<SEP>" # we will use this to separate the client name & message

# initialize list/set of all connected client's sockets
client_sockets = set()
Expand All @@ -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
Expand All @@ -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 <SEP>
# if we received a message, replace the <SEP>
# token with ": " for nice printing
msg = msg.replace(separator_token, ": ")
# iterate over all connected sockets
Expand Down