Guest User

FBTools.py

a guest
Mar 17th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 22.59 KB | None | 0 0
  1. #!/usr/bin/python3
  2. # FBTools by Ashish Chaudhary [http://github.com/yankee101]
  3.  
  4. from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  5. from selenium.common.exceptions import NoSuchElementException
  6. from selenium.webdriver.common.keys import Keys
  7. from pyfiglet import Figlet
  8. import selenium.webdriver
  9. import requests
  10. import pickle
  11. import sys
  12. import re
  13. import os
  14.  
  15.  
  16. class FBTools:
  17.  
  18.    ##Initialise Driver_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  19.  
  20.    def __init__(self):
  21.       dcap = dict(DesiredCapabilities.PHANTOMJS)
  22.       dcap["phantomjs.page.settings.userAgent"] = (
  23.           "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0"    #The xpaths used in the code are with reference to the layout of m.facebook.com on Firefox Windows.
  24.       )
  25.       serviceArgs = ['--load-images=no',]
  26.       self.driver=selenium.webdriver.PhantomJS(desired_capabilities=dcap,service_args=serviceArgs)
  27.  
  28.    ##Login Functions_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  29.  
  30.    def loginChecker(self):
  31.       if os.path.isfile("cookies.pkl") == True:
  32.          return True
  33.       else:
  34.          return False
  35.  
  36.    def login(self):
  37.       print("Provide your credentials for login.")
  38.       print("Credentials are not stored and required only once...")
  39.       email = input("Email/Username/Phone : ")
  40.       password = input("Password : ")
  41.  
  42.       print("Attempting Login...")
  43.  
  44.       self.driver.get("http://m.facebook.com/settings")
  45.       self.driver.find_element_by_name("email").send_keys(email)
  46.       self.driver.find_element_by_name("pass").send_keys(password + Keys.RETURN)
  47.  
  48.       dummy = 0
  49.  
  50.       try:
  51.          if self.driver.find_element_by_xpath('//*[@id="viewport"]/div[3]/div/table/tbody/tr/td[2]/a[3]').is_displayed() == True:
  52.             print("Successfully logged in. Dumping Cookies...")
  53.             self.cookieDumper()
  54.             print("Dumped Cookies")
  55.       except NoSuchElementException:
  56.             dummy += 1
  57.  
  58.       if dummy == 1:
  59.          print("xxxxxxx")
  60.          print("Unable to login, try again later.")
  61.  
  62.  
  63.  
  64.    def cookieDumper(self):                                                             #Dumps cookies on first login.
  65.       pickle.dump(self.driver.get_cookies() , open("cookies.pkl","wb"))
  66.  
  67.  
  68.    def cookieInjector(self):                                                           #Injects cookies on subsequent logins.
  69.       if os.path.isfile("cookies.pkl") == True:
  70.          cookies = pickle.load(open("cookies.pkl", "rb"))
  71.          self.driver.get("http://m.facebook.com")
  72.          for cookie in cookies:
  73.             self.driver.add_cookie(cookie)
  74.          self.driver.get("http://m.facebook.com/settings")
  75.  
  76.    ##Home Functions_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  77.  
  78.    def home(self,pageNumber,click):
  79.          if pageNumber == 0 and click == 0:
  80.             self.driver.get("http://m.facebook.com")
  81.          if click == 1:
  82.             try:
  83.                if pageNumber == 1:
  84.                   self.driver.find_element_by_xpath('//*[@id="m_newsfeed_stream"]/div[3]/a').click()
  85.                elif pageNumber > 1:
  86.                   self.driver.find_element_by_xpath('//*[@id="root"]/div/div[3]/a').click()
  87.             except NoSuchElementException:
  88.                print("Cannot access the next page.")
  89.                self.onPage = 0
  90.  
  91.          holder = []
  92.          like_link_holder = []
  93.          comment_link_holder = []
  94.          n = 0
  95.          while n < 10:
  96.             try:
  97.                path = '//*[@id="u_0_{}"]'.format(n)
  98.                post = self.driver.find_element_by_xpath(path)
  99.                if post.text != "":
  100.                   comment_package = self.commentLinkExtractor(path)
  101.                   if comment_package[0] != False:
  102.                      like_link_holder.append(self.likeLinkExtractor(path))
  103.                      comment_link_holder.append(comment_package[1])
  104.                      holder.append(post.text.strip())
  105.                n += 1
  106.             except NoSuchElementException:
  107.                n += 1
  108.  
  109.          n = 0
  110.          while n < 10:
  111.             try:
  112.                path = '//*[@id="u_0_{}"]'.format(chr(n + 97))
  113.                post = self.driver.find_element_by_xpath(path)
  114.                if post.text != "":
  115.                   comment_package = self.commentLinkExtractor(path)
  116.                   if comment_package[0] != False:
  117.                      like_link_holder.append(self.likeLinkExtractor(path))
  118.                      comment_link_holder.append(comment_package[1])
  119.                      holder.append(post.text.strip())
  120.                n += 1
  121.             except NoSuchElementException:
  122.                n += 1
  123.  
  124.          self.returnedList = self.homeParser(holder,like_link_holder,comment_link_holder)
  125.          for index,post in enumerate(self.returnedList[0]):
  126.             try:
  127.                print("---{}---\n{}".format(index,self.render(post)))
  128.             except (UnicodeDecodeError,UnicodeEncodeError):
  129.                pass
  130.          print("xxxxxxx")
  131.          self.onPage += 1
  132.  
  133.    def homeParser(self,posts,like_links,comment_links):
  134.       for post in posts:
  135.          dummy = -1                                                                 #Some posts get repeated while fetching, this block of code deletes them.
  136.          for y in posts:
  137.             dummy += 1
  138.             if post != y:
  139.                if y in post:
  140.                   del posts[dummy]
  141.                   del like_links[dummy]
  142.                   del comment_links[dummy]
  143.                   break
  144.       b = -1
  145.       for post in posts:                                                            #This block of code is supposed to only allow english chars. Needs rechecking.
  146.          b += 1
  147.          if self.isEnglish(post) == False:
  148.             del posts[b]
  149.             del like_links[b]
  150.             del comment_links[b]
  151.  
  152.       return [posts,like_links,comment_links]
  153.  
  154.    def isEnglish(self,s):
  155.       try:
  156.         s.encode('ascii')
  157.         return True
  158.       except UnicodeEncodeError:
  159.         return False
  160.  
  161.    def render(self,post):
  162.       post = re.sub('. Add Friend . Full Story . More','',post)                        #Replaces irrelevent text with ''
  163.       post = re.sub('Add Friend\n','',post)
  164.       post = re.sub('. Full Story . More','',post)
  165.       post = re.sub('. Like Page','',post)
  166.       post = re.sub('Like Page . More','',post)
  167.       post = re.sub('. Share','',post)
  168.       post = re.sub('More','',post)
  169.       post = re.sub('. More','',post)
  170.       post = re.sub('Share','',post)
  171.       post = re.sub('Join Page','',post)
  172.       post = re.sub('Like Page','',post)
  173.       post = re.sub('Join Event','',post)
  174.  
  175.       return post
  176.  
  177.    def likeLinkExtractor(self,path):
  178.       try:
  179.          like_link = self.driver.find_element_by_xpath('{}/div[2]/div[2]/div[2]/span[1]/a[2]'.format(path))
  180.          return like_link
  181.       except NoSuchElementException:
  182.          try:
  183.             like_link = self.driver.find_element_by_xpath('{}/div[2]/div[2]/span[1]/a[2]'.format(path))
  184.             return like_link
  185.          except NoSuchElementException:
  186.             return False
  187.  
  188.    def commentLinkExtractor(self,path):
  189.       try:
  190.          comment_link = self.driver.find_element_by_xpath('{}/div[2]/div[2]/a[1]'.format(path))
  191.          return [True,comment_link]
  192.       except NoSuchElementException:
  193.          return [False,False]
  194.  
  195.    def like(self,index):
  196.       try:
  197.          self.driver.get(self.returnedList[1][index].get_attribute("href"))
  198.          print("Liked.")
  199.       except:
  200.          print("Unable to like.")
  201.       self.onPage = 0
  202.       self.home(self.onPage,0)
  203.  
  204.    def comment(self,index):
  205.       try:
  206.          self.driver.get(self.returnedList[2][index].get_attribute("href"))
  207.          comment = input("Enter your comment:\n")
  208.          self.driver.find_element_by_xpath('//*[@id="composerInput"]').send_keys(comment + Keys.RETURN)
  209.          print("Commented.")
  210.       except:
  211.          print("Unable to comment.")
  212.       self.onPage = 0
  213.       self.home(self.onPage,0)
  214.  
  215.    def homeActionsParser(self,action):                                                 #Parses the news feed post index from the command.
  216.       operand = -1
  217.       for s in action.split():
  218.          if s.isdigit():
  219.             operand = int(s)
  220.       try:
  221.          if operand == -1:
  222.             print("Invalid command")
  223.             return -1
  224.          elif operand >= len(self.returnedList[1]):
  225.             print("Invalid command")
  226.             return -1
  227.          return operand
  228.       except AttributeError:
  229.          print("Nothing here! So can't perform that action.")
  230.          return -1
  231.  
  232.    ##Friend List Functions_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  233.  
  234.  
  235.    def friendWriter(self,friendList):
  236.       if os.path.isfile("friendList.pkl") == True:
  237.          file = open("friendList.pkl",'wb')
  238.       else:
  239.          print("Generating Friend List for the first time.")
  240.          file = open("friendList.pkl",'wb')
  241.       pickle.dump(friendList,file)
  242.  
  243.    def friendList(self):
  244.       holder = []
  245.       n = 0
  246.       dummy = 0
  247.  
  248.       print("Fetching Friend List",end='')
  249.  
  250.       while n <= 500:
  251.          print(".",end='')
  252.          sys.stdout.flush()
  253.          try:
  254.             self.driver.get("https://m.facebook.com/friends/center/friends/?ppk={}".format(n))
  255.             a = 1
  256.             while a<= 10:
  257.                element = self.driver.find_element_by_xpath('//*[@id="friends_center_main"]/div[2]/div[{}]/table/tbody/tr/td[2]/a'.format(a))
  258.                holder.append(element.text + "," + element.get_attribute("href").split('/')[6].split('&')[0].split('?uid=')[1])
  259.                a += 1
  260.             n += 1
  261.          except NoSuchElementException:
  262.             try:
  263.                elem = self.driver.find_element_by_xpath('//*[@id="friends_center_main"]/div[2]/div[1]/table/tbody/tr/td[2]/a')
  264.                n += 1
  265.             except:
  266.                break
  267.  
  268.       print("")
  269.       return holder
  270.  
  271.    def friendComparator(self,newList):
  272.       print("Finding who unfriended you! (or you unfriended them)")
  273.       kickingFriends = []
  274.  
  275.       if os.path.isfile("friendList.pkl") == True and newList != []:
  276.          oldFile = pickle.load(open("friendList.pkl", "rb"))
  277.          for line in oldFile:
  278.             if line not in newList:
  279.                kickingFriends.append(line.split(',')[0])
  280.       elif os.path.isfile("friendList.pkl") == False:
  281.          print("Failed to find the Old Friend List")
  282.          print("Writing new Friend List")
  283.       else:
  284.          print("Function Failed")
  285.  
  286.       self.friendWriter(newList)
  287.       return kickingFriends
  288.  
  289.    def notInList(self):
  290.       comparison = self.friendComparator(self.friendList())
  291.       if comparison == []:
  292.          print("xxxxxxx\nNo new Un-friends\nxxxxxxx")
  293.       else:
  294.          print("These prople are no more in your friend list: ")
  295.          print("CAUTION : If they haven't unfriended you, they may have deactivated their account temporarily.")
  296.          print("\nxxxxxxx")
  297.          for kickingFriend in comparison:
  298.             print(kickingFriend)
  299.          print("xxxxxxx")
  300.  
  301.    ##Notifications Functions_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  302.  
  303.    def notify(self):
  304.       try:
  305.          self.driver.get("https://m.facebook.com/notifications")
  306.          temp = self.dateCurator()
  307.          dates = temp[0]
  308.          xpaths = temp[1]
  309.          print("\nxxxxxxx\nNotifications\nxxxxxxx\n")
  310.          for index,date in enumerate(dates):
  311.             print(date + ":")
  312.             notifications = self.getNotifications(xpaths[index])
  313.             for notification in notifications:
  314.                print("- - - - -")
  315.                print(notification)
  316.             print("x_x_x_x_x_x_x_x_x_x")
  317.       except NoSuchElementException:
  318.          print("xxxxxxx\nCannot Print Notifications\nxxxxxxx")
  319.  
  320.    def dateCurator(self):
  321.       dates = []
  322.       xpaths = []
  323.       n = 1
  324.       while n < 10:
  325.          try:
  326.             xpath = '//*[@id="notifications_list"]/div[{}]/h5'.format(n)
  327.             date = self.driver.find_element_by_xpath(xpath).text
  328.             dates.append(date)
  329.             xpaths.append(xpath)
  330.             n += 1
  331.          except NoSuchElementException:
  332.             n += 1
  333.             break
  334.       return [dates,xpaths]
  335.  
  336.    def getNotifications(self,basepath):
  337.       notifications = []
  338.       n = 1
  339.       while n < 20:
  340.          try:
  341.             xpath = re.sub("/h5",'',basepath)+"/div[{}]/table/tbody/tr/td[2]/a/div".format(n)
  342.             notification = self.driver.find_element_by_xpath(xpath).text
  343.             notifications.append(notification)
  344.             n += 1
  345.          except NoSuchElementException:
  346.             n += 1
  347.             break
  348.       return notifications
  349.  
  350.    ##Friend's Timeline Liker Functions_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  351.  
  352.    def friendLiker(self):
  353.       print("THIS WILL LIKE EACH AND EVERY POST OF A SPECIFIED FRIEND.")
  354.       print("ENTER 'p' TO PROCEED OR ANYTHING ELSE TO QUIT.")
  355.       choice = input("")
  356.       if choice == 'p' or choice == 'P':
  357.          if os.path.isfile("friendList.pkl") == False:
  358.             print("Friend List not found.")
  359.             print("Use 'unfr' first to get the initial friend list.")
  360.             return False
  361.          else:
  362.             print("\nxxxxxxx\nIndex : Friend (alphabetical order):\nxxxxxxx")
  363.             file = pickle.load(open("friendList.pkl",'rb'))
  364.             for index,line in enumerate(sorted(file)):
  365.                print(str(index)+" : "+line.split(',')[0])
  366.             print("\nxxxxxxx\nEnter Index\nxxxxxxx")
  367.             index = input("Index: ")
  368.             if index.isdigit():
  369.                self.loadProfile(int(index))
  370.             else:
  371.                print("Invalid Index")
  372.       else:
  373.          return False
  374.  
  375.    def loadProfile(self,number):
  376.       uid = 0
  377.       for index,line in enumerate(sorted(pickle.load(open("friendList.pkl",'rb')))):
  378.          if index == number:
  379.             uid = int(line.split(',')[1])
  380.             print("Liking all posts on {}'s Timeline...".format(line.split(',')[0].split()[0]))
  381.             break
  382.       self.driver.get("http://m.facebook.com/{}".format(uid))
  383.       try:
  384.          temp = self.elementYear()
  385.          years = []
  386.          names = []
  387.          numberOfLikes = 0
  388.          alreadyLiked = 0
  389.          totalLiked = 0
  390.          totalAlreadyLiked = 0
  391.          for x in temp:
  392.             years.append(x.get_attribute("href"))
  393.             names.append(x.text)
  394.          print("*one '.' == 1 Like Administered*")
  395.          for index,year in enumerate(years):
  396.             self.driver.get(year)
  397.             if index != 0:
  398.                stories = self.allStories()
  399.             else:
  400.                stories = "dummyValue"
  401.             print("\nxxxxxxx {} xxxxxxx".format(names[index]))
  402.             if stories != None:
  403.                if stories != "dummy":
  404.                   self.driver.get(stories)
  405.                   showmorelink = self.showMore()
  406.                   while showmorelink != "dummy":
  407.                      likelinks = self.friendLikeLink()
  408.                      alreadyLiked += likelinks[0]
  409.                      totalAlreadyLiked += likelinks[0]
  410.                      likedJustNow = self.likeAllLinks(likelinks[1])
  411.                      numberOfLikes += likedJustNow
  412.                      totalLiked += likedJustNow
  413.                      self.driver.get(showmorelink)
  414.                      showmorelink = self.showMore()
  415.                   if showmorelink == "dummy":
  416.                      likelinks = self.friendLikeLink()
  417.                      alreadyLiked += likelinks[0]
  418.                      totalAlreadyLiked += likelinks[0]
  419.                      likedJustNow = self.likeAllLinks(likelinks[1])
  420.                      numberOfLikes += likedJustNow
  421.                      totalLiked += likedJustNow
  422.                   print("\nPosts liked now: {}".format(numberOfLikes))
  423.                   print("Posts already liked: {}".format(alreadyLiked))
  424.                   numberOfLikes = 0
  425.                   alreadyLiked = 0
  426.                else:
  427.                   print("Failed")
  428.             if stories == None:
  429.                likelinks = self.friendLikeLink()
  430.                alreadyLiked += likelinks[0]
  431.                totalAlreadyLiked += likelinks[0]
  432.                likedJustNow = self.likeAllLinks(likelinks[1])
  433.                numberOfLikes += likedJustNow
  434.                totalLiked += likedJustNow
  435.                print("\nPosts liked now: {}".format(numberOfLikes))
  436.                print("Posts already liked: {}".format(alreadyLiked))
  437.                numberOfLikes = 0
  438.                alreadyLiked = 0
  439.          print("\nxxxxxxx REPORT xxxxxxx\n")
  440.          print("Total Likes Administered Now: {}".format(totalLiked))
  441.          print("Number Of Already Liked Posts: {}".format(totalAlreadyLiked))
  442.          print("Total Likes on Friend's Timeline: {}".format(totalLiked + totalAlreadyLiked))
  443.       except NoSuchElementException:
  444.          print("Can't Proceed")
  445.  
  446.    def allStories(self):
  447.       link = ""
  448.       try:
  449.          showall = self.driver.find_elements_by_xpath("//*[contains(text(), 'Show all stories')]")
  450.          for show in showall:
  451.             if self.checkValidLink(show,"stories") == True:
  452.                link = show.get_attribute("href")
  453.                return link
  454.             else:
  455.                return "dummy"
  456.       except NoSuchElementException:
  457.          return "dummy"
  458.  
  459.    def showMore(self):
  460.       try:
  461.          showmore = self.driver.find_element_by_xpath("//*[contains(text(), 'Show more')]")
  462.          if self.checkValidLink(showmore,"showmore") == True:
  463.             return showmore.get_attribute("href")
  464.          else:
  465.             return "dummy"
  466.       except NoSuchElementException:
  467.          return "dummy"
  468.  
  469.  
  470.    def checkValidLink(self,temp,user):
  471.       if user == "stories":
  472.          try:
  473.             link = temp.get_attribute("href")
  474.             if link.split('/')[2] == "m.facebook.com":
  475.                return True
  476.             else:
  477.                return False
  478.          except:
  479.             return False
  480.       elif user == "likes":
  481.          try:
  482.             link = temp.get_attribute("href")
  483.             if link.split('/')[2] == "m.facebook.com":
  484.                if "like.php" in link:
  485.                   return True
  486.                else:
  487.                   return False
  488.          except:
  489.             return False
  490.       elif user == "showmore":
  491.          try:
  492.             link = temp.get_attribute("href")
  493.             if link.split('/')[2] == "m.facebook.com":
  494.                return True
  495.             else:
  496.                return False
  497.          except:
  498.             return False
  499.       else:
  500.          return False
  501.  
  502.  
  503.    def elementYear(self):
  504.       n = 1
  505.       holder = []
  506.       while n < 20:
  507.          try:
  508.             holder.append(self.driver.find_element_by_xpath('//*[@id="structured_composer_async_container"]/div[4]/div[{}]/a'.format(n)))
  509.             n += 1
  510.          except NoSuchElementException:
  511.             break
  512.       if holder == []:
  513.          n = 1
  514.          while n < 20:
  515.             try:
  516.                holder.append(self.driver.find_element_by_xpath('//*[@id="structured_composer_async_container"]/div[3]/div[{}]/a'.format(n)))
  517.                n += 1
  518.             except NoSuchElementException:
  519.                break
  520.       return holder
  521.  
  522.    def friendLikeLink(self):
  523.       holder = []
  524.       try:
  525.          likeLinks = self.driver.find_elements_by_xpath("//*[contains(text(), 'Like')]")
  526.          unlikeLinks = self.driver.find_elements_by_xpath("//*[contains(text(), 'Unlike')]")
  527.          for like in likeLinks:
  528.             if self.checkValidLink(like,"likes") == True:
  529.                holder.append(like.get_attribute("href"))
  530.          alreadyLiked = len(unlikeLinks)
  531.          return [alreadyLiked,holder]
  532.       except NoSuchElementException:
  533.          return []
  534.  
  535.    def likeAllLinks(self,links):
  536.       file = pickle.load(open("cookies.pkl",'rb'))
  537.       numberOfLikes = 0
  538.       cookies = {}
  539.       for x in file:
  540.          if 'datr' in str(x):
  541.            cookies["datr"] = x["value"]
  542.          if 'xs' in str(x):
  543.            cookies["xs"] = x["value"]
  544.          if 'c_user' in str(x):
  545.            cookies["c_user"] = x["value"]
  546.       for link in links:
  547.          r = requests.get(link,cookies = cookies)
  548.          if r.status_code == 200:
  549.             print(".",end = '')
  550.             sys.stdout.flush()
  551.             numberOfLikes += 1
  552.          else:
  553.             print("Failed")
  554.       return numberOfLikes
  555.  
  556.  
  557.    ##Flow Manager Functions_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  558.  
  559.    def greeting(self):
  560.       try:
  561.          data = self.driver.find_element_by_xpath("//*[contains(text(), 'Logout')]")
  562.          f = Figlet(font='slant')
  563.          self.name = re.search('\((.*?)\)',data.text).group(1) #Extracts username from 'Logout (username)' fetched from the page.
  564.          print(f.renderText(self.name))
  565.          self.name = self.name.lower()
  566.       except NoSuchElementException:
  567.             pass
  568.  
  569.    def manager(self,command):
  570.       if command == "help":
  571.          if os.path.isfile("commands.txt"):
  572.             file = open("commands.txt")
  573.             for line in file.readlines():
  574.                print(line)
  575.          else:
  576.             print("Commands list missing.")
  577.       elif command == "exit":
  578.          sys.exit()
  579.       elif command == "unfr":
  580.          self.onPage = 0
  581.          self.notInList()
  582.       elif command == "home":
  583.          self.onPage = 0
  584.          self.home(self.onPage,0)
  585.       elif command == "home next":
  586.          if self.onPage == 0:
  587.             self.home(0,0)
  588.          else:
  589.             self.home(self.onPage,1)
  590.       elif "like" in command != -1:
  591.          operand = self.homeActionsParser(command)
  592.          if operand != -1:
  593.             self.like(operand)
  594.       elif "comment" in command != -1:
  595.          operand = self.homeActionsParser(command)
  596.          if operand != -1:
  597.             self.comment(operand)
  598.       elif command == "notif":
  599.          self.notify()
  600.       elif command == "auli":
  601.          self.friendLiker()
  602.       else:
  603.          print("Invalid command. Use 'help' to get a list of commands.")
  604.  
  605.       self.commandInput()
  606.  
  607.    def commandInput(self):
  608.       print("")
  609.       print("Use 'help' to get the list of commands. Use 'exit' to logoff.")
  610.       command = input("Enter command : ")
  611.       self.manager(command)
  612.  
  613. def main():
  614.  
  615.    tool = FBTools()
  616.    f = Figlet(font='slant')
  617.    print(f.renderText('FBTools\n------'))
  618.  
  619.    if tool.loginChecker() == True:
  620.       print("Attempting Login...")
  621.       tool.cookieInjector()
  622.    else:
  623.       tool.login()
  624.  
  625.    if tool.loginChecker() == True:
  626.       tool.greeting()
  627.       tool.commandInput()
  628.    else:
  629.       sys.exit("Can't proceed.")
  630.  
  631. if __name__ == "__main__":main()
Add Comment
Please, Sign In to add comment