A powerful Facebook Messenger API to interact with Facebook and Messenger.
Project description
fbchat-muqit Facebook & Messenger API
fbchat-muqit An Unofficial Asynchronous Facebook Messenger API designed to interact with Facebook and Messenger. It is an early release. Most of the feautures are not available yet. As It is an Unofficial API we are not responsible if you get banned by Facebook. We recommend to use a dummy Facebook account.
🛠️ Installation
You can install fbchat-muqit using pip:
pip install fbchat-muqit
📙 Documentation
The API is not fully documented yet Read Documentation
📖 Usage Example
• Usage Requirements:
- A Facebook account (It's safer to use new account)
- Facebook account cookies 🍪
To login in Facebook you will need Facebook account cookies. Since login via email and password is no longer supported.
To get your Facebook account cookies. First login in your Facebook account and then add C3C Chrome extension in your browser. Open a your Facebook account in a browser tab and use this extension to get your account cookies. Copy the cookies and save them in a json file. We will use the cookies to interact with Facebook server.
A basic example of How to use it.
import asyncio
from fbchat_muqit import Client, ThreadType
async def main():
cookies_path = "path to json cookies file"
# Lets login in Facebook
bot = await Client.startSession(cookies_path)
if await bot.isLoggedIn():
"""Lets send a Message to a friend when Client is logged in."""
# put a valid fb user id
await bot.sendMessage("I'm Online!", "10000072727288", ThreadType.USER)
print("Logged in as", bot.uid)
# listen to all incoming events
await bot.listen()
# Windows User uncomment below two lines
# if sys.platform.startswith("win"):
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
Save the code and now run it.
python3 test.py
If It logins successfully then It will send a message to the given Facebook User.
• Subclassing Client class.
from fbchat_muqit import Client, Message, ThreadType
import asyncio
# Create a class use Client as base Class
class Test(Client):
async def onMessage(self, mid, author_id: str, message_object: Message, thread_id, thread_type=ThreadType.USER, **kwargs):
"""you will receive all messenger messages here every time anyone sends messages in a thread (Group/User)"""
# author_id is message sender ID
if author_id != self.uid:
await message_object.reply("Hello! This is a reply")
await message_object.react("❤️")
# mid is message ID
await self.sendMessage("Hello", thread_id, thread_type, reply_to_id=mid)
async def main():
cookies_path = "path to json cookies file"
bot = await Test.startSession(cookies_path)
if await bot.isLoggedIn():
fetch_client_info = await bot.fetchUserInfo(bot.uid)
client_info = fetch_client_info[bot.uid]
print("Logged in as", client_info.name)
try:
await bot.listen()
except Exception as e:
print(e)
# Windows User uncomment below two lines
# if sys.platform.startswith("win"):
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
Save the code and now run it.
python3 test.py
Now, use another Facebook account to send message to the fbchat_muqit Client account. If everything works properly It should reply and react to the message with an emoji.
🔧 Requirements
- Python 3.9+
- aiohttp
- aiomqtt
- aenum
📄 License
This project is distributed under a dual-license model:
-
BSD-3-Clause License: Parts of the code are reused and adapted from the original fbchat library, licensed under the BSD-3-Clause License. See LICENSE-BSD for details.
-
GPL v3 License: New contributions and modifications by Muhammad MuQiT/togashigreat are licensed under the GPL v3.0 License. See LICENSE for details.
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 fbchat_muqit-1.1.31.tar.gz
.
File metadata
- Download URL: fbchat_muqit-1.1.31.tar.gz
- Upload date:
- Size: 59.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8f8c02aa43aa6b33ff73dd7228d8a102f83702d7a55c956acad7c955691a1992
|
|
MD5 |
8c0fb4ea9d92eaa53474a520753f6ae9
|
|
BLAKE2b-256 |
a08e9cd5de51d4232c667d61cdb69821b9a9fb106b7ce74be693f7fc6cc05d2a
|
Provenance
The following attestation bundles were made for fbchat_muqit-1.1.31.tar.gz
:
Publisher:
python_publish.yml
on togashigreat/fbchat-muqit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
fbchat_muqit-1.1.31.tar.gz
-
Subject digest:
8f8c02aa43aa6b33ff73dd7228d8a102f83702d7a55c956acad7c955691a1992
- Sigstore transparency entry: 273798630
- Sigstore integration time:
-
Permalink:
togashigreat/fbchat-muqit@540266d8862b1136e69b5e8d629cab6ae71e43e9
-
Branch / Tag:
refs/tags/v1.1.31
- Owner: https://github.com/togashigreat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
python_publish.yml@540266d8862b1136e69b5e8d629cab6ae71e43e9
-
Trigger Event:
release
-
Statement type:
File details
Details for the file fbchat_muqit-1.1.31-py3-none-any.whl
.
File metadata
- Download URL: fbchat_muqit-1.1.31-py3-none-any.whl
- Upload date:
- Size: 69.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
f8ef7628ba7f356c2ad765b569b90438203dacf6509333d901e6d3054011e280
|
|
MD5 |
ea07aaf52cfdc807f4ef426576bf7c39
|
|
BLAKE2b-256 |
e9787629db82cfb19a0df0071fcee42abea33492f7cf1abd6cdc20cdb996ea98
|
Provenance
The following attestation bundles were made for fbchat_muqit-1.1.31-py3-none-any.whl
:
Publisher:
python_publish.yml
on togashigreat/fbchat-muqit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
fbchat_muqit-1.1.31-py3-none-any.whl
-
Subject digest:
f8ef7628ba7f356c2ad765b569b90438203dacf6509333d901e6d3054011e280
- Sigstore transparency entry: 273798631
- Sigstore integration time:
-
Permalink:
togashigreat/fbchat-muqit@540266d8862b1136e69b5e8d629cab6ae71e43e9
-
Branch / Tag:
refs/tags/v1.1.31
- Owner: https://github.com/togashigreat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
python_publish.yml@540266d8862b1136e69b5e8d629cab6ae71e43e9
-
Trigger Event:
release
-
Statement type: