RachaProFreeFire

ทสบ

Sep 4th, 2024 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.15 KB | None | 0 0
  1. from __facebookToolsV2 import dataGetHome, fbTools
  2. from __messageListenV2 import listeningEvent  # Import the specific class or module you need
  3. from __sendMessage import api
  4. import datetime, threading, os, json
  5.  
  6. class fbClient:
  7.     def __init__(self, cookies, dataFB):
  8.         self.cookies = cookies
  9.         self.dataFB = dataFB
  10.         self.messageID = None
  11.         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)
  12.         self.pathFile = ".mqttMessage"
  13.         self.recentReceivedMessages = []
  14.  
  15.     def setDefaultValue(self):
  16.         self.userID, self.bodyMessage, self.replyToID, self.bodySend, self.commandPlugins = [None] * 5
  17.  
  18.     def receiveCommandAndSend(self):
  19.         if (self.dataFB["FacebookID"] != self.userID):
  20.              match self.commandPlugins.lower():
  21.                  case "uptime":
  22.                      self.bodySend = "datetime: " + str(datetime.datetime.now())
  23.                  case "hola" | "hello" | "hi":
  24.                      self.bodySend = "Hey,", self.userID
  25.                  case "ping":
  26.                      self.bodySend = "Pong!"
  27.                  case __:
  28.                      self.bodySend = self.bodyMessage
  29.              mainSend = api()  # Use the specific class or module you imported
  30.              threading.Thread(target=mainSend.send, args=(self.dataFB, self.bodySend, self.replyToID)).start()
  31.              self.setDefaultValue()
  32.  
  33.     def prefixCheck(self):
  34.         if self.bodyMessage[0] == self.prefix:
  35.             self.commandPlugins = self.bodyMessage.split(',')[1]
  36.         else:
  37.             self.commandPlugins = self.bodyMessage
  38.  
  39.  
  40.     def receiveMessage(self):
  41.         self.fbt = fbTools(self.dataFB, 0)
  42.         mainReceiveMessage = listeningEvent(self.fbt, self.dataFB)  # Use the specific class or module you imported
  43.         mainReceiveMessage.get_last_seq_id()
  44.         threading.Thread(target=mainReceiveMessage.connect_mqtt, args=()).start()
  45.         """
  46.        Why am I using Threading here?
  47.        Because when calling connect_mqtt(), the programs after it won't be able to run
  48.        as it continuously connects to the Facebook server. To overcome this, I've used threading
  49.        to make it run concurrently with other functions!
  50.        """
  51.         while 1:
  52.            if os.path.isfile(self.pathFile):
  53.                try:
  54.                    self.bodyMain = json.loads(open(self.pathFile, "r", encoding="utf-8").read())
  55.                    # print(f"{self.bodyMain['messageID']} != {self.messageID} {self.bodyMain['messageID'] != self.messageID}")
  56.                    if self.bodyMain['messageID'] != self.messageID:
  57.                        self.userID = self.bodyMain['userID']
  58.                        self.messageID = self.bodyMain['messageID']
  59.                        self.bodyMessage = self.bodyMain['body']
  60.                        self.replyToID = self.bodyMain['replyToID']
  61.                        print(f"> userID: {self.userID}\n> messageID: {self.messageID}\n> messageContents: {self.bodyMessage}\n> From {self.bodyMain['type']}ID: {self.replyToID}\n- - - - -")
  62.                        self.prefixCheck()
  63.                        self.receiveCommandAndSend()
  64.                        self.setDefaultValue()
  65.                except:
  66.                    pass
  67.  
  68. 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"
  69. dataFB = dataGetHome(cookies)
  70. _ = fbClient(cookies, dataFB)
  71. _.setDefaultValue()
  72. _.receiveMessage()
  73. print("done!")
Advertisement
Add Comment
Please, Sign In to add comment