Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 = "dpr=1.337499976158142; locale=th_TH; m_pixel_ratio=1.337499976158142; x-referer=eyJyIjoiL2NoZWNrcG9pbnQvMTUwMTA5MjgyMzUyNTI4Mi9sb2dvdXQvP25leHQ9aHR0cHMlM0ElMkYlMkZtLmZhY2Vib29rLmNvbSUyRiZwYWlwdj0wJmVhdj1BZmJkMG5GS0Q5QldKZElGVWtSV183UGlDOFN0T3Ffc043OWludUdfX1RXcnVadFQzMG1tdjkyV1RfS0JraC1RSzVNIiwiaCI6Ii9jaGVja3BvaW50LzE1MDEwOTI4MjM1MjUyODIvbG9nb3V0Lz9uZXh0PWh0dHBzJTNBJTJGJTJGbS5mYWNlYm9vay5jb20lMkYmcGFpcHY9MCZlYXY9QWZiZDBuRktEOUJXSmRJRlVrUldfN1BpQzhTdE9xX3NONzlpbnVHX19UV3J1WnRUMzBtbXY5MldUX0tCa2gtUUs1TSIsInMiOiJtIn0=; wd=600x831; c_user=100083555561423; fbl_st=100430557;T:28757381; vpd=v1;830x599x1.337499976158142; wl_cbv=v2;client_version:2611;timestamp:1725442863;CRCM:-2106710455"
- dataFB = dataGetHome(cookies)
- _ = fbClient(cookies, dataFB)
- _.setDefaultValue()
- _.receiveMessage()
- print("done!")
Advertisement
Add Comment
Please, Sign In to add comment