Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 ^^
Expand Down
10 changes: 5 additions & 5 deletions src/__facebookLoginV2.py → src/facebookLoginV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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ó)
Expand Down
2 changes: 1 addition & 1 deletion src/__facebookToolsV2.py → src/facebookToolsV2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import requests, attr, json, time, random

def Headers(setCookies, dataForm=None):
headers = {}
headers["Host"] = "www.facebook.com"
Expand Down
50 changes: 25 additions & 25 deletions src/__getCommand.py → src/getCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/__getUserInformation.py → src/getUserInformation.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 4 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import facebookToolsV2
import messageListen
import sendMessage
import json, requests, datetime, time, os
24 changes: 12 additions & 12 deletions src/__messageListen.py → src/messageListen.py
Original file line number Diff line number Diff line change
@@ -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ừ
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions src/__sendMessage.py → src/sendMessage.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/__threadSettings.py → src/threadSettings.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
16 changes: 8 additions & 8 deletions src/__unsendMessage.py → src/unsendMessage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import requests, json
import __facebookToolsV2
import facebookToolsV2

def digitToChar(digit):
if digit < 10:
Expand Down Expand Up @@ -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])

Expand Down
12 changes: 6 additions & 6 deletions src/__uploadImages.py → src/uploadImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -24,17 +24,17 @@ 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]
return "file_id"

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",
Expand Down Expand Up @@ -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 {
Expand Down