A simple Python package for terminal-based chat applications
Project description
ChatMe 1.0.0
ChatMe is a simple Python package for creating a terminal-based chat application. It allows two users to communicate through their terminals over a network. This package provides an easy-to-use API to set up both server and client for a chat application, enabling real-time text communication.
Features
- Simple to set up and use
- Real-time chat functionality
- Can be integrated into other Python applications
- Customizable IP and port settings
- Multithreaded message receiving
Installation
To install the ChatMe package
pip install chatme
Usage
Starting the Server
Create a Python script (e.g., server_script.py
) with the following content:
from chatme import start_server
def on_receive(message):
print(f"Friend: {message}")
server_socket, client_socket = start_server(on_receive=on_receive)
while True:
message = input("You: ")
client_socket.send(message.encode())
if message.lower() == "exit":
break
client_socket.close()
server_socket.close()
Run the server script:
python server_script.py
Starting the Client
Create a Python script (e.g., client_script.py
) with the following content:
from chatme import start_client
def on_receive(message):
print(f"Friend: {message}")
server_ip = 'your_server_ip_here'
client_socket = start_client(server_ip, on_receive=on_receive)
while True:
message = input("You: ")
client_socket.send(message.encode())
if message.lower() == "exit":
break
client_socket.close()
Replace 'your_server_ip_here'
with the actual IP address of the server.
Run the client script:
python client_script.py
Example
Here is an example of how to set up the server and client:
Server Script
from chatme import start_server
def on_receive(message):
print(f"Friend: {message}")
server_socket, client_socket = start_server(on_receive=on_receive)
while True:
message = input("You: ")
client_socket.send(message.encode())
if message.lower() == "exit":
break
client_socket.close()
server_socket.close()
Client Script
from chatme import start_client
def on_receive(message):
print(f"Friend: {message}")
server_ip = 'your_server_ip_here'
client_socket = start_client(server_ip, on_receive=on_receive)
while True:
message = input("You: ")
client_socket.send(message.encode())
if message.lower() == "exit":
break
client_socket.close()
Customization
- Local IP and Port: You can customize the local IP and port for the server by passing them as arguments to the
start_server
function. By default, it uses0.0.0.0
and port12345
. - Callback Function: The
on_receive
callback function can be customized to handle received messages as needed.
Contributing
We welcome contributions to enhance the ChatMe package. If you have any suggestions, bug reports, or feature requests, please create an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License.
Acknowledgements
We would like to thank all the contributors and users of ChatMe. Your feedback and support are invaluable in making this project better. Special thanks to the open-source community for providing the tools and inspiration for this project.
Contact
Thank you for using ChatMe! We hope it helps you in building your terminal-based chat applications.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file chatme-1.0.0.tar.gz
.
File metadata
- Download URL: chatme-1.0.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd064b27f6dd22cd7e07a35bf4e0ac1e008f77bd02e16468b32b74488f92475b |
|
MD5 | 6a8a2729bcfb5be217e5aa190a252e52 |
|
BLAKE2b-256 | 5b495ea8e97380687c31da509c3b8468030c8ef0c88175831bdfba03fa31df4e |
File details
Details for the file chatme-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: chatme-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc8c57075df33e0930c815193afd962bb27732bdd8c691d2375a00360854fec0 |
|
MD5 | 138a62bea971e0c57adfa958e7382926 |
|
BLAKE2b-256 | baf9638704431a8ceb87f2a0aa94ad93a74b8175d4931e2af8960d01f93c8f3d |