diff --git a/README.rst b/README.rst index 48b0ed1..a0d8001 100644 --- a/README.rst +++ b/README.rst @@ -36,7 +36,7 @@ Tutorial (Hướng dẫn) cd fbchat-v2/src && type nul > mainBot.py -*Đối với* **Mac/Lunix:** +*Đối với* **Mac/Linux:** .. code-block:: bash @@ -45,10 +45,10 @@ Tutorial (Hướng dẫn) .. code-block:: python - import __facebooKTolsV2 # BẮT BUỘC - import __messageListen # BẮT BUỘC - import __sendMessage # BẮT BUỘC - import __uploadImages # KHÔNG BẮT BUỘC (Tùy thuộc vào b có muốn dùng ảnh hay không) + import facebookToolsV2 # BẮT BUỘC + import messageListen # BẮT BUỘC + import sendMessage # BẮT BUỘC + import uploadImages # KHÔNG BẮT BUỘC (Tùy thuộc vào b có muốn dùng ảnh hay không) import json, requests, datetime, time # Đợi thêm nhé, lười viết nữa òi ^^ diff --git a/src/__facebookLoginV2.py b/src/facebookLoginV2.py similarity index 97% rename from src/__facebookLoginV2.py rename to src/facebookLoginV2.py index bf26b20..db9ab3d 100644 --- a/src/__facebookLoginV2.py +++ b/src/facebookLoginV2.py @@ -14,11 +14,11 @@ """ def randStr(length): - return "".join(random.choices(string.ascii_lowercase + string.digits, k=length)) + return "".join(random.choices(string.ascii_lowercase + string.digits, k=length)) def GetToken2FA(key2Fa): - twoFARequests = json.loads(requests.get("https://2fa.live/tok/" + key2Fa.replace(" ","")).text) - return twoFARequests["token"] + twoFARequests = json.loads(requests.get("https://2fa.live/tok/" + key2Fa.replace(" ","")).text) + return twoFARequests["token"] def Headers(cookiesFB=None): @@ -85,7 +85,7 @@ def loginFacebook(userFB=None, passFB=None, authenticationGG=None): "api_key": "882a8490361da98702bf97a021ddc14d", "access_token": "350685531728|62f8ce9f74b12f84c123cc23437a4a32" } - + dataJson = json.loads(requests.post("https://b-graph.facebook.com/auth/login",data=dataForm, headers=headers).text) if (dataJson.get("error") != None): if (dataJson["error"]["error_subcode"] == 1348162): @@ -189,7 +189,7 @@ def loginFacebook(userFB=None, passFB=None, authenticationGG=None): """ Hướng dẫn sử dụng (Tutorial) * Dữ liệu yêu cầu (args): - + - userFB: username/phone/gmail Facebook - passFB: Mật khẩu Facebook - authenticationGG: mã 2fa (nếu có) diff --git a/src/__facebookToolsV2.py b/src/facebookToolsV2.py similarity index 99% rename from src/__facebookToolsV2.py rename to src/facebookToolsV2.py index 65a4d6d..4368e6d 100644 --- a/src/__facebookToolsV2.py +++ b/src/facebookToolsV2.py @@ -1,5 +1,5 @@ import requests, attr, json, time, random - + def Headers(setCookies, dataForm=None): headers = {} headers["Host"] = "www.facebook.com" diff --git a/src/__getCommand.py b/src/getCommand.py similarity index 53% rename from src/__getCommand.py rename to src/getCommand.py index ac0038b..e2478a1 100644 --- a/src/__getCommand.py +++ b/src/getCommand.py @@ -17,35 +17,35 @@ def Main(contents): }, ensure_ascii=False) if len(ContentsArgs) >= 5: - Args1 = ContentsArgs[1] - Args2 = ContentsArgs[2] - Args3 = ContentsArgs[3] - Args4 = " ".join([ContentsArgs[i] for i in range(4, len(ContentsArgs))]) - ArgsFull = f"{Args1} {Args2} {Args3} {Args4}" + Args1 = ContentsArgs[1] + Args2 = ContentsArgs[2] + Args3 = ContentsArgs[3] + Args4 = " ".join([ContentsArgs[i] for i in range(4, len(ContentsArgs))]) + ArgsFull = f"{Args1} {Args2} {Args3} {Args4}" elif len(ContentsArgs) == 4: - Args1 = ContentsArgs[1] - Args2 = ContentsArgs[2] - Args3 = ContentsArgs[3] - Args4 = None - ArgsFull = f"{Args1} {Args2} {Args3}" + Args1 = ContentsArgs[1] + Args2 = ContentsArgs[2] + Args3 = ContentsArgs[3] + Args4 = None + ArgsFull = f"{Args1} {Args2} {Args3}" elif len(ContentsArgs) == 3: - Args1 = ContentsArgs[1] - Args2 = ContentsArgs[2] - Args3 = None - Args4 = "" - ArgsFull = f"{Args1} {Args2}" + Args1 = ContentsArgs[1] + Args2 = ContentsArgs[2] + Args3 = None + Args4 = "" + ArgsFull = f"{Args1} {Args2}" elif len(ContentsArgs) == 2: - Args1 = ContentsArgs[1] - Args2 = None - Args3 = None - Args4 = None - ArgsFull = Args1 + Args1 = ContentsArgs[1] + Args2 = None + Args3 = None + Args4 = None + ArgsFull = Args1 else: - Args1 = None - Args2 = None - Args3 = None - Args4 = None - ArgsFull = None + Args1 = None + Args2 = None + Args3 = None + Args4 = None + ArgsFull = None return json.dumps({ "results": { diff --git a/src/__getUserInformation.py b/src/getUserInformation.py similarity index 99% rename from src/__getUserInformation.py rename to src/getUserInformation.py index e63b986..06860a5 100644 --- a/src/__getUserInformation.py +++ b/src/getUserInformation.py @@ -1,7 +1,7 @@ import json, requests, time, json, attr, random # from LorenBot.plugins import __facebookToolsV2 import datetime -import __facebookToolsV2 +import facebookToolsV2 def digitToChar(digit): if digit < 10: diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..b8cce4c --- /dev/null +++ b/src/main.py @@ -0,0 +1,4 @@ +import facebookToolsV2 +import messageListen +import sendMessage +import json, requests, datetime, time, os \ No newline at end of file diff --git a/src/__messageListen.py b/src/messageListen.py similarity index 87% rename from src/__messageListen.py rename to src/messageListen.py index c347743..08c64b8 100644 --- a/src/__messageListen.py +++ b/src/messageListen.py @@ -1,6 +1,6 @@ import json, requests, re, json from bs4 import BeautifulSoup -import __facebookToolsV2 +import facebookToolsV2 import datetime """ Lời nói đầu, Xin NHẮC là đây là lấy tin nhắn từ m.facebook.com, chứ không phải từ @@ -47,15 +47,15 @@ def jsonFormat(senderID, messageContents, messageID, overviewRequests): def Listen(dataFB, threadID, Url="https://m.facebook.com"): mainRequests = { "headers": { - "Host": "m.facebook.com", - "Connection": "keep-alive", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", - "Sec-Fetch-Site": "none", - "Sec-Fetch-Mode": "navigate", - "Sec-Fetch-User": "?1", - "Sec-Fetch-Dest": "document", - "Accept-Language": "vi-VN,vi;q=0.9,en-US;q=0.8,en;q=0.7" + "Host": "m.facebook.com", + "Connection": "keep-alive", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", + "Sec-Fetch-Site": "none", + "Sec-Fetch-Mode": "navigate", + "Sec-Fetch-User": "?1", + "Sec-Fetch-Dest": "document", + "Accept-Language": "vi-VN,vi;q=0.9,en-US;q=0.8,en;q=0.7" }, "timeout": 5, "url": "{}/messages/t/{}".format(Url, threadID), @@ -85,7 +85,7 @@ def Listen(dataFB, threadID, Url="https://m.facebook.com"): messageContents = "Ký tự đặc biệt hoặc file được gửi" else: messageContents = "Unknown" - + mainJsonFormat = { "senderID": senderID, "messageContents": messageContents, @@ -102,7 +102,7 @@ def Listen(dataFB, threadID, Url="https://m.facebook.com"): """ Hướng dẫn sử dụng (Tutorial): * Dữ liệu yêu cầu (args): - + - dataFB: lấy từ __facebookToolsV2.dataGetHome - setCookies: cookie tài khoản FB (dùng cho __facebookToolsV2) - threadID: ID Nhóm (Thread) diff --git a/src/__sendMessage.py b/src/sendMessage.py similarity index 95% rename from src/__sendMessage.py rename to src/sendMessage.py index d54afda..6f5ade5 100644 --- a/src/__sendMessage.py +++ b/src/sendMessage.py @@ -1,18 +1,18 @@ try: - from re import search as regex - from time import sleep - from datetime import datetime - import json,os, random - try: import __facebookToolsV2 - except: from LorenBot.plugins import __facebookToolsV2 - import requests - import attr - import time, json - from threading import Thread,local - from threading import Thread + from re import search as regex + from time import sleep + from datetime import datetime + import json,os, random + try: import facebookToolsV2 + except: from LorenBot.plugins import facebookToolsV2 + import requests + import attr + import time, json + from threading import Thread,local + from threading import Thread except Exception as errLOg: - print("err: " + str(errLOg)) - pass + print("err: " + str(errLOg)) +pass USER_AGENTS = ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/601.1.10 (KHTML, like Gecko) Version/8.0.5 Safari/601.1.10", "Mozilla/5.0 (Windows NT 6.3; WOW64; ; NCT50_AAP285C84A1328) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1", "Mozilla/5.0 (X11; CrOS i686 2268.111.0) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6"] def Headers(setCookies, dataForm): diff --git a/src/__threadSettings.py b/src/threadSettings.py similarity index 99% rename from src/__threadSettings.py rename to src/threadSettings.py index 9e27ebd..96b93c0 100644 --- a/src/__threadSettings.py +++ b/src/threadSettings.py @@ -1,7 +1,7 @@ import json, requests, time, json, attr, random # from LorenBot.plugins import __facebookToolsV2 import datetime -import __facebookToolsV2 +import facebookToolsV2 def digitToChar(digit): if digit < 10: diff --git a/src/__unsendMessage.py b/src/unsendMessage.py similarity index 91% rename from src/__unsendMessage.py rename to src/unsendMessage.py index b11318b..a5088f5 100644 --- a/src/__unsendMessage.py +++ b/src/unsendMessage.py @@ -1,5 +1,5 @@ import requests, json -import __facebookToolsV2 +import facebookToolsV2 def digitToChar(digit): if digit < 10: @@ -61,13 +61,13 @@ def Main(messageID, dataFB): dataForm["message_id"] = messageID mainRequests = { - "headers": Headers(dataFB["cookieFacebook"], dataForm), - "timeout": 5, - "url": "https://www.facebook.com/messaging/unsend_message/", - "data": dataForm, - "cookies": parse_cookie_string(dataFB["cookieFacebook"]), - "verify": True - } + "headers": Headers(dataFB["cookieFacebook"], dataForm), + "timeout": 5, + "url": "https://www.facebook.com/messaging/unsend_message/", + "data": dataForm, + "cookies": parse_cookie_string(dataFB["cookieFacebook"]), + "verify": True +} sendRequests = json.loads(requests.post(**mainRequests).text.split("for (;;);")[1]) diff --git a/src/__uploadImages.py b/src/uploadImages.py similarity index 92% rename from src/__uploadImages.py rename to src/uploadImages.py index 7916ab1..a725b33 100644 --- a/src/__uploadImages.py +++ b/src/uploadImages.py @@ -7,7 +7,7 @@ from os.path import basename from mimetypes import guess_type import requests, json -import __facebookToolsV2 +import facebookToolsV2 def Main(filenames, setCookies): def digitToChar(digit): if digit < 10: @@ -24,9 +24,9 @@ def str_base(number, base): return digitToChar(m) def mimetype_to_key(mimetype): if not mimetype: - return "file_id" + return "file_id" if mimetype == "image/gif": - return "gif_id" + return "gif_id" checkData = mimetype.split("/") if checkData[0] in ["video", "image", "audio"]: return "%s_id" % checkData[0] @@ -34,7 +34,7 @@ def mimetype_to_key(mimetype): USER_AGENTS = ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/601.1.10 (KHTML, like Gecko) Version/8.0.5 Safari/601.1.10", "Mozilla/5.0 (Windows NT 6.3; WOW64; ; NCT50_AAP285C84A1328) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1", "Mozilla/5.0 (X11; CrOS i686 2268.111.0) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6"] - getData = __facebookToolsV2.dataGetHome(setCookies) + getData = facebookToolsV2.dataGetHome(setCookies) headers = { "Referer": "https://www.facebook.com", "Accept": "text/html", @@ -65,8 +65,8 @@ def get_files_from_paths(filenames): resultRequests = json.loads(requests.post("https://upload.facebook.com/ajax/mercury/upload.php", headers=headers, data=dataForm, files=file_dict).text.replace("for (;;);", ""))["payload"] resultData = [ - (data[mimetype_to_key(data["filetype"])], data["filetype"]) - for data in resultRequests["metadata"] + (data[mimetype_to_key(data["filetype"])], data["filetype"]) + for data in resultRequests["metadata"] ] return {