A lightweight, terminal-based Facebook Messenger client built with Python and Textual. This mini-project allows you to chat with your Facebook contacts directly from your command line.
- Terminal UI: Built with Textual for a clean, responsive command-line interface.
- Real-time Messaging: Send and receive messages in real-time.
- Embedded API: Uses a modified, embedded version of
fbchatto handle the underlying Facebook API communication.
This project uses an embedded and modified version of the fbchat library. The original, publicly available fbchat package on PyPI is obsolete and no longer actively maintained. Our embedded version includes critical fixes necessary to interact with the modern Facebook API. Do not run pip install fbchat, as it will conflict with the local version and break the application.
- Python 3.9+
- A valid Facebook account
-
Clone this repository:
git clone <your-repo-url> cd <your-repo-directory>
-
Create and activate a virtual environment (recommended):
python3 -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
-
Install the required dependencies:
pip install -r requirements.txt
Facebook's automated login and bot-detection systems are very aggressive and often block automated login scripts (generating ReCAPTCHAs that headless scripts cannot solve). Therefore, the most reliable way to authenticate this application is by manually extracting your session cookies from your own web browser.
You only need to do this once, and the cookies usually remain valid for several months.
- Log in to Facebook: Open your preferred desktop web browser (Chrome, Edge, Safari, or Firefox) and log in to Facebook.com.
- Open Developer Tools: Press
F12on your keyboard (or right-click anywhere on the page and select "Inspect"). - Navigate to the Application/Storage Tab:
- Chrome/Edge: Click on the Application tab at the top of the Developer Tools panel.
- Firefox: Click on the Storage tab.
- Locate the Cookies list: On the left sidebar, expand the Cookies section and click on
https://www.facebook.com. - Find
c_user: Look at the table on the right. Find the row where the "Name" column is exactlyc_user. Double-click the corresponding text in the "Value" column and copy it. - Find
xs: Similarly, find the row where the "Name" column is exactlyxs. Double-click its "Value" and copy it. - Create
fb_cookies.json: In the root directory of this project, create a new file namedfb_cookies.json. - Paste the values: Paste your copied values into
fb_cookies.jsonusing the following exact JSON format:Make sure not to include any extra spaces or quotes inside the values themselves.{ "c_user": "YOUR_C_USER_VALUE_HERE", "xs": "YOUR_XS_VALUE_HERE" }
Once you have set up your fb_cookies.json file, you can start the application:
python app.pyUse your keyboard to navigate through threads, switch conversations, and send messages.
This is an unofficial, community-driven project and is not affiliated with, endorsed by, or sponsored by Meta/Facebook. Use it responsibly and at your own risk. Automated interaction with Facebook may sometimes trigger security checkpoints or account temporary suspensions.