Giter VIP home page Giter VIP logo

fbchat-v2's Introduction

FBChat-Remake: Open Source

Chào người dùng thân mến! Tôi viết cái này để thông báo rằng: Dự án hiện tại tạm thời ngưng hoạt động. FBChat-v2 sẽ không được cập nhật thêm tính năng mới và ngưng bảo trì tạm thời. Nếu bạn muốn trở thành người đóng góp cho dự án, hãy liên hệ tôi tại đây. (Tôi sẽ quay trở lại sớm thôi, có lẽ là vào tháng 06/2024)

Xin chào, tôi là MinhHuyDev. Lời nói đầu, đây là lần đầu tiên mà mình làm lại một source lớn như vậy nên sẽ không tránh được những sai sót trong quá trình code, rất mong sẽ được người dùng báo cáo lại Lỗi tại issues của GitHub này nhé:3

* Đây không phải là API chính thức; Facebook có sẵn API dành cho chatbot tại đây. Thư viện này khác ở chỗ nó sử dụng tài khoản/cookie Facebook thông thường để thay thế.

https://i.ibb.co/3TWntY6/Picsart-23-08-12-15-11-30-693.jpg

👽Bạn không thể hiểu được tiếng Việt?, bạn có thể đọc README (ENGLISH): tại đây

📢Dành cho người mới: Lướt xuống cuối trang bạn sẽ thấy TUTORIAL (Hướng dẫn) nhận tin nhắn và gửi tin nhắn nhé!

Thông tin cơ bản

Có gì mới trong phiên bản này?

NEW: Sửa lỗi một vài thứ và CLEAR CODE gọn hơn

Tutorial (Hướng dẫn cơ bản)

Đầu tiên: Người dùng cần phải cài đặt tất cả các gói tài nguyên cần thiết để có thể sử dụng. Nếu bạn chưa cài đặt, hãy dùng lệnh sau:

git clone https://github.com/MinhHuyDev/fbchat-v2

Tiếp theo: Hãy tạo thư mục trong chính folder mà mình vừa tải về từ GitHub về bằng cách sau:

Đối với Windows (Command Prompt/PowerShell):

cd fbchat-v2/src && type nul > mainBot.py

Đối với Mac/Linux:

cd fbchat-v2/src && touch mainBot.py

Sau đó: Tiếp tục vào file mainBot.py, Và copy đoạn code sau và dán vào file:

from __facebookToolsV2 import dataGetHome, fbTools
from __messageListenV2 import listeningEvent  # Import the specific class or module you need
from __sendMessage import api
import datetime, threading, os, json

class fbClient:
    def __init__(self, cookies, dataFB):
        self.cookies = cookies
        self.dataFB = dataFB
        self.messageID = None
        self.prefix = "/" # This is the command prompt; when you enter this symbol, the corresponding command will be invoked. Additionally, you can customize it as per your preference (e.g., , . * ! ? etc)
        self.pathFile = ".mqttMessage"
        self.recentReceivedMessages = []

    def setDefaultValue(self):
        self.userID, self.bodyMessage, self.replyToID, self.bodySend, self.commandPlugins = [None] * 5

    def receiveCommandAndSend(self):
        if (self.dataFB["FacebookID"] != self.userID):
             match self.commandPlugins.lower():
                 case "uptime":
                     self.bodySend = "datetime: " + str(datetime.datetime.now())
                 case "hola" | "hello" | "hi":
                     self.bodySend = "Hey,", self.userID
                 case "ping":
                     self.bodySend = "Pong!"
                 case __:
                     self.bodySend = self.bodyMessage
             mainSend = api()  # Use the specific class or module you imported
             threading.Thread(target=mainSend.send, args=(self.dataFB, self.bodySend, self.replyToID)).start()
             self.setDefaultValue()

    def prefixCheck(self):
        if self.bodyMessage[0] == self.prefix:
            self.commandPlugins = self.bodyMessage.split(',')[1]
        else:
            self.commandPlugins = self.bodyMessage


    def receiveMessage(self):
        self.fbt = fbTools(self.dataFB, 0)
        mainReceiveMessage = listeningEvent(self.fbt, self.dataFB)  # Use the specific class or module you imported
        mainReceiveMessage.get_last_seq_id()
        threading.Thread(target=mainReceiveMessage.connect_mqtt, args=()).start()
        """
        Why am I using Threading here?
        Because when calling connect_mqtt(), the programs after it won't be able to run
        as it continuously connects to the Facebook server. To overcome this, I've used threading
        to make it run concurrently with other functions!
        """
        while 1:
           if os.path.isfile(self.pathFile):
               try:
                   self.bodyMain = json.loads(open(self.pathFile, "r", encoding="utf-8").read())
                   # print(f"{self.bodyMain['messageID']} != {self.messageID} {self.bodyMain['messageID'] != self.messageID}")
                   if self.bodyMain['messageID'] != self.messageID:
                       self.userID = self.bodyMain['userID']
                       self.messageID = self.bodyMain['messageID']
                       self.bodyMessage = self.bodyMain['body']
                       self.replyToID = self.bodyMain['replyToID']
                       print(f"> userID: {self.userID}\n> messageID: {self.messageID}\n> messageContents: {self.bodyMessage}\n> From {self.bodyMain['type']}ID: {self.replyToID}\n- - - - -")
                       self.prefixCheck()
                       self.receiveCommandAndSend()
                       self.setDefaultValue()
               except:
                   pass

cookies = "this is set Cookie Facebook"
dataFB = dataGetHome(cookies)
_ = fbClient(cookies, dataFB)
_.setDefaultValue()
_.receiveMessage()
print("done!")

🖇️LƯU Ý: Đây chỉ là một bản code mẫu về nhận tin nhắn và gửi tin nhắn, Nếu xảy ra lỗi. Hãy đóng góp bằng cách sửa nó và gửi thông tin lỗi vào issue hoặc hãy liên hệ trực tiếp với tôi qua Telegram

Sau đó, quay lại Terminal/CMD và chạy file này bằng lệnh sau:

python mainBot.py

Nếu xảy ra lỗi và không chạy được, hãy thử lại bằng hai lệnh sau:

python3 mainBot.py

hoặc

py mainBot.py

💔Nếu vẫn xảy ra lỗi. Vui lòng kiểm tra xem đã tải Python về thiết bị hay chưa. Nếu chưa tải, hãy nhấp vào đây để được chuyển đến trang tải Python chính thức.

🏅Dưới đây là hình ảnh khi chạy được bot thành công:

https://i.ibb.co/pdbBTWz/nh-ch-p-m-n-h-nh-2024-01-30-130047.png


https://i.ibb.co/fvJq87Z/Screenshot-2023-08-18-20-25-51-435-com-offsec-nethunter-kex.png

🫶🏻Cảm ơn bạn đã đọc đến đây! Nếu bạn vẫn còn nhiều câu hỏi thắc mắc. Hãy lướt xuống dưới để tìm câu trả lời cho riêng mình nhé :3 Yêuuuuuu

Các câu hỏi thường gặp

Bạn có thể xem các vấn đề thường gặp hoặc Tutorial tại đây: DOCS.md

Thông báo về phiên bản mới

📢: Coming soon...

Thông tin liên hệ

fbchat-v2's People

Contributors

minhhuydev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fbchat-v2's Issues

.

Can You Make This A Python Library

Error

Exception in thread Thread-2 (send):
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/data/data/com.termux/files/usr/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/storage/emulated/0/Download/termux/fbchat-v2/src/__sendMessage.py", line 33, in send
    self.sendMessage()
  File "/storage/emulated/0/Download/termux/fbchat-v2/src/__sendMessage.py", line 113, in sendMessage
    self.sendRequests()
  File "/storage/emulated/0/Download/termux/fbchat-v2/src/__sendMessage.py", line 120, in sendRequests
    sendRequests = json.loads(sendRequests.split("for (;;);")[1])
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Script not working

Hello, i tested the script and it's not working. The response of the request to send a message is this one:
<!DOCTYPE html><html lang="en" id="facebook"><head><title>Error</title><meta charset="utf-8" /><meta http-equiv="Cache-Control" content="no-cache" /><meta name="robots" content="noindex,nofollow" /><style>...</style></head><body><div id="header"><a href="//www.facebook.com/"><img id="icon" src="//static.facebook.com/images/logos/facebook_2x.png" /></a></div><div class="core"><h1>Sorry, something went wrong.</h1><p>We&#039;re working on getting this fixed as soon as we can.</p><p><a id="back" href="//www.facebook.com/">Go Back</a></p><div class="footer"> Meta &#169; 2023 &#183; <a href="//www.facebook.com/help/?ref=href052">Help</a></div></div><script nonce="wfWasHre"> document.getElementById("back").onclick = function() { if (history.length > 1) { history.back(); return false; } }; </script></body></html>

SendMessage Error


<title>Error</title><style nonce="wfWasHre">html, body { color: #333; font-family: 'Lucida Grande', 'Tahoma', 'Verdana', 'Arial', sans-serif; margin: 0; padding: 0; text-align: center;}

#header { height: 30px; padding-bottom: 10px; padding-top: 10px; text-align: center;}
#icon { width: 30px;}
.core { margin: auto; padding: 1em 0; text-align: left; width: 904px;}
h1 { font-size: 18px;}
p { font-size: 13px;}
.footer { border-top: 1px solid #ddd; color: #777; float: left; font-size: 11px; padding: 5px 8px 6px 0; width: 904px;}</style>

Sorry, something went wrong.

We're working on getting this fixed as soon as we can.

Go back

Meta © 2024 · Help
<script nonce="wfWasHre">
document.getElementById("back").onclick = function() {
if (history.length > 1) {
history.back();
return false;
}
};
</script>
Exception in thread Thread-5 (send):
Traceback (most recent call last):
File "C:\Users\ryana\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
self.run()
File "C:\Users\ryana\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\ryana\OneDrive\Desktop\Works\fbchat-v2\src__sendMessage.py", line 33, in send
self.sendMessage()
File "C:\Users\ryana\OneDrive\Desktop\Works\fbchat-v2\src__sendMessage.py", line 113, in sendMessage
self.sendRequests()
File "C:\Users\ryana\OneDrive\Desktop\Works\fbchat-v2\src__sendMessage.py", line 121, in sendRequests
sendRequests = json.loads(sendRequests.split("for (;;);")[1])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

connect_mqtt:Connection failed, the log shows that the maximum number of links has been exceeded

resort:
After logging in, I listened to messages and the result was that my account was banned after running, with a prompt prohibiting automation

connect_mqtt:

Connection failed, the log shows that the maximum number of links has been exceeded (50)

-main.py--

cookie = 'my cookie'
i = __facebookToolsV2.dataGetHome(cookie)
fbt = __facebookToolsV2.fbTools(i, 0)
_ = listeningEvent(fbt, i)
_.get_last_seq_id()
_.connect_mqtt()

thanks!!!

TimeoutError

websockets connect TimeError
always at pycharm/cmd
never at chrome/facebook/homepage/console
alway at chome/other WebSite/console
why?????????
checked for 1000 times,F**K
by the way i use VPN
help me!!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.