def action(): for item in actionItems: print(colorize("[" + str(actionItems.index(item)) + "] ", 'teal') + list(item)[0]) while True: choice = input(">> ") try: if int(choice) < 0 or int(choice) >= len(actionItems): raise ValueError if str(actionItems[int(choice)][1]) == "main": return main() elif str(actionItems[int(choice)][1]) == "reset": OnlySnarf.remove_local() elif str(actionItems[int(choice)][1]) == "message": actionChoice = list(actionItems[int(choice)])[1] return finalizeMessage(actionChoice) elif str(actionItems[int(choice)][1]) == "discount": actionChoice = list(actionItems[int(choice)])[1] return finalizeDiscount(actionChoice) elif str(actionItems[int(choice)][1]) == "promotion": actionChoice = list(actionItems[int(choice)])[1] return finalizePromotion(actionChoice) elif str(actionItems[int(choice)][1]) == "post": actionChoice = list(actionItems[int(choice)])[1] return finalizePost(actionChoice) elif str(actionItems[int(choice)][1]) == "cron": actionChoice = list(actionItems[int(choice)])[1] return finalizeCron(actionChoice) else: actionChoice = list(actionItems[int(choice)])[1] return finalizeAction(actionChoice) except (ValueError, IndexError): print("Error: Incorrect Index") except Exception as e: settings.maybePrint(e) print("Error: Missing Method")
def post(text, expires=None, schedule=False, poll=False): try: if not auth(): return False global BROWSER goToHome() print("Posting:") print("- Text: {}".format(text)) if expires: expiration(expires) if schedule: scheduling(schedule) if poll: polling(poll) BROWSER.find_element_by_id(ONLYFANS_POST_TEXT_CLASS).send_keys(str(text)) sends = BROWSER.find_elements_by_class_name(SEND_BUTTON_CLASS) for i in range(len(sends)): if sends[i].is_enabled(): sends = sends[i] if str(settings.DEBUG) == "True" and str(settings.DEBUG_DELAY) == "True": time.sleep(int(settings.DEBUG_DELAY_AMOUNT)) if str(settings.DEBUG) == "True": print('Skipped: OnlyFans Post (debug)') return True sends.click() # send[1].click() # the 0th one is disabled print('OnlyFans Post Complete') return True except Exception as e: settings.maybePrint(e) print("Error: OnlyFans Post Failure") return False
def performPromotion(actionChoice, promotionChoice): def promote(username): if username == None: print("Warning: No user found") else: OnlySnarf.give_trial(username) mainMenu() try: username = None if str(promotionChoice) == "email": # prompt choice = input("Email: ") username = str(choice) return promote(username) elif str(promotionChoice) == "select": users = displayUsers() while True: choice = input(">> ") try: if int(choice) < 0 or int(choice) > len(users): raise ValueError if int(choice) == 0: return finalizePromotion(actionChoice) return promote(str(users[int(choice)-1].username)) except (ValueError, IndexError): settings.maybePrint(sys.exc_info()[0]) print("Error: Incorrect Index") except (ValueError, IndexError): print("Error: Incorrect Index") except Exception as e: settings.maybePrint(e) print("Error: Missing Method") mainMenu()
def skipUserCheck(user): if str(settings.SKIP_USERS) == "None": settings.SKIP_USERS = [] if str(user.id).lower() in settings.SKIP_USERS or str( user.username).lower() in settings.SKIP_USERS: settings.maybePrint("skipping: {}".format(user.username)) return None return user
def goToHome(): global BROWSER if BROWSER == None: return False if str(BROWSER.current_url) == str(ONLYFANS_HOME_URL): settings.maybePrint("at -> onlyfans.com") else: settings.maybePrint("goto -> onlyfans.com") BROWSER.get(ONLYFANS_HOME_URL) WebDriverWait(BROWSER, 60, poll_frequency=6).until(EC.visibility_of_element_located((By.XPATH, SEND_BUTTON_XPATH)))
def readChat(self): print("Reading Chat: {} - {}".format(self.username, self.id)) messages = OnlySnarf.read_user_messages(self.id) self.messages = messages[0] # self.messages_and_timestamps = messages[1] self.messages_to = messages[2] self.messages_from = messages[3] settings.maybePrint("Chat Read: {} - {}".format( self.username, self.id))
def polling(poll): period = poll.get("period") questions = poll.get("questions") if isinstance(questions, str): questions = questions.split(",\"*\"") questions = [n.strip() for n in questions] if not auth(): return False if int(period) != 1 and int(period) != 3 and int(period) != 7 and int(period) != 30 and int(period) != 99 and str(period) != "No limit": print("Error: Missing Duration") return False if not questions or len(questions) == 0: print("Error: Missing Questions") return False global BROWSER try: print("Poll:") print("- Duration: {}".format(period)) print("- Questions:\n> {}".format("\n> ".join(questions))) try: BROWSER.find_element_by_class_name(ONLYFANS_MORE).click() except Exception as e: pass BROWSER.find_element_by_class_name(POLL).click() BROWSER.find_element_by_class_name(POLL_DURATION).click() nums = BROWSER.find_elements_by_class_name(EXPIRATION_PERIODS) for num in nums: inner = num.get_attribute("innerHTML") if str(inner) == "1 day" and int(period) == 1: num.click() if str(inner) == "3 days" and int(period) == 3: num.click() if str(inner) == "7 days" and int(period) == 7: num.click() if str(inner) == "30 days" and int(period) == 30: num.click() if "No limit" in str(inner) and int(period) == 99: num.click() save = BROWSER.find_element_by_class_name(POLL_SAVE).click() time.sleep(1) if len(questions) > 2: for question in questions[2:]: BROWSER.find_element_by_class_name(POLL_ADD_QUESTION).click() questions_ = BROWSER.find_elements_by_xpath(POLL_INPUT_XPATH) i = 0 # print("questions: {}".format(questions)) for question in list(questions): questions_[i].send_keys(str(question)) time.sleep(1) i+=1 if str(settings.DEBUG) == "True" and str(settings.DEBUG_DELAY) == "True": time.sleep(int(settings.DEBUG_DELAY_AMOUNT)) if str(settings.DEBUG) == "True": print("Skipping Poll (debug)") cancel = BROWSER.find_element_by_class_name(POLL_CANCEL) cancel.click() # its the second cancel button else: print("Poll Entered") return True except Exception as e: settings.maybePrint(e) print("Error: Failed to enter Poll") return False
def get_favorite_users(): settings.maybePrint("Getting Fav Users") users = User.get_all_users() favUsers = [] favorites = ",".join(str(settings.USERS_FAVORITE)) for user in users: if user in favorites: settings.maybePrint("Fav User: {}".format(user.username)) user = skipUserCheck(user) if user is None: continue favUsers.append(user) return favUsers
def get_never_messaged_users(): settings.maybePrint("Getting New Users") update_chat_logs() users = User.get_all_users() newUsers = [] for user in users: if len(user.messages_to) == 0: settings.maybePrint("Never Messaged User: {}".format( user.username)) user = skipUserCheck(user) if user is None: continue newUsers.append(user) return newUsers
def performAction(actionChoice, fileChoice, methodChoice, file=None, folderName=None, parent=None): try: method = getattr(OnlySnarf, str(actionChoice)) response = method(fileChoice, methodChoice=methodChoice, file=file, folderName=folderName, parent=parent) if response: if str(actionChoice) == "download": settings.update_value("input",response.get("path")) except (ValueError, IndexError): print("Error: Incorrect Index") except Exception as e: settings.maybePrint(e) print("Error: Missing Method") mainMenu()
def reset(): global BROWSER if not BROWSER or BROWSER == None: print('OnlyFans Not Open, Skipping Reset') return True try: BROWSER.get(ONLYFANS_HOME_URL) print('OnlyFans Reset') return True except Exception as e: settings.maybePrint(e) print('Error: Failure Resetting OnlyFans') return False
def get_new_users(): settings.maybePrint("Getting New Users") users = User.get_all_users() newUsers = [] date_ = datetime.today() - timedelta(days=10) for user in users: started = datetime.strptime(user.started, "%b %d, %Y") # settings.maybePrint("date: "+str(date_)+" - "+str(started)) if started < date_: continue settings.maybePrint("New User: {}".format(user.username)) user = skipUserCheck(user) if user is None: continue newUsers.append(user) return newUsers
def get_recent_users(): settings.maybePrint("Getting Recent Users") users = User.get_all_users() i = 0 users_ = [] for user in users: settings.maybePrint("Recent User: {}".format(user.username)) user = skipUserCheck(user) if user is None: continue users_.append(user) i += 1 if i == settings.RECENT_USER_COUNT: return users_ return users_
def finalizePromotion(actionChoice): for item in promotionItems: print(colorize("[" + str(promotionItems.index(item)) + "] ", 'teal') + list(item)[0]) while True: choice = input(">> ") try: choice = int(choice) if int(choice) < 0 or int(choice) > len(promotionItems): raise ValueError if str(promotionItems[int(choice)][1]) == "main": return action() choice = list(promotionItems[int(choice)])[1] return performPromotion(actionChoice, choice) except (ValueError, IndexError): settings.maybePrint(sys.exc_info()[0]) print("Error: Incorrect Index")
def message_text(text): try: if not text or text == None or str(text) == "None": print("Error: Missing Text") return False print("Enter text: {}".format(text)) global BROWSER message = BROWSER.find_element_by_css_selector(MESSAGE_INPUT_CLASS) message.send_keys(str(text)) settings.maybePrint("Text Entered") return True except Exception as e: settings.maybePrint(e) print("Error: Failure to Enter Message") return False
def message_confirm(): try: global BROWSER send = WebDriverWait(BROWSER, 60, poll_frequency=10).until(EC.element_to_be_clickable((By.CLASS_NAME, MESSAGE_CONFIRM))) if str(settings.DEBUG) == "True": if str(settings.DEBUG_DELAY) == "True": time.sleep(int(settings.DEBUG_DELAY_AMOUNT)) print('OnlyFans Message: Skipped (debug)') return True send.click() print('OnlyFans Message: Sent') return True except Exception as e: settings.maybePrint(e) print("Error: Failure to Confirm Message") return False
def finalizeCron(actionChoice): for item in cronItems: print(colorize("[" + str(cronItems.index(item)) + "] ", 'teal') + list(item)[0]) while True: cronChoice = input(">> ") try: if int(cronChoice) < 0 or int(cronChoice) >= len(cronItems): raise ValueError if str(cronItems[int(cronChoice)][1]) == "main": return action() cronChoice = list(cronItems[int(cronChoice)])[1] return performCron(actionChoice, cronChoice) except (ValueError, IndexError): print("Error: Incorrect Index") except Exception as e: settings.maybePrint(e) print("Error: Missing Method")
def finalizeAction(actionChoice): for item in fileItems: print(colorize("[" + str(fileItems.index(item)) + "] ", 'teal') + list(item)[0]) while True: fileChoice = input(">> ") try: if int(fileChoice) < 0 or int(fileChoice) >= len(fileItems): raise ValueError if str(fileItems[int(fileChoice)][1]) == "main": return action() # Call the matching function fileChoice = list(fileItems[int(fileChoice)])[1] return selectMethod(actionChoice, fileChoice) except (ValueError, IndexError): print("Error: Incorrect Index") except Exception as e: settings.maybePrint(e) print("Error: Missing Method")
def message_image(image): try: if not image or image == None or str(image) == "None": print("Error: Missing Image(s)") return False print("Enter image(s): {}".format(image)) global BROWSER files = [] if str(settings.SKIP_DOWNLOAD) == "True": print("Warning: Unable to upload, skipped download") return True if os.path.isfile(str(image)): files = [str(image)] elif os.path.isdir(str(image)): for file in os.listdir(str(image)): files.append(os.path.join(os.path.abspath(str(image)),file)) else: print("Error: Missing Image File(s)") return False if str(settings.SKIP_UPLOAD) == "True": print("Skipping Upload") return True files = files[:int(settings.IMAGE_UPLOAD_MAX_MESSAGES)] for file in files: print('Uploading: '+str(file)) BROWSER.find_element_by_id(ONLYFANS_UPLOAD_MESSAGE_PHOTO).send_keys(str(file)) try: buttons = BROWSER.find_elements_by_class_name(ONLYFANS_UPLOAD_BUTTON) if len(buttons) > 0: settings.maybePrint("Warning: Upload Error Message, Closing") for butt in buttons: if butt.get_attribute("innerHTML").strip() == "Close": butt.click() settings.maybePrint("Success: Upload Error Message Closed") time.sleep(1) except Exception as e: print("Error: Unable to Upload Images") settings.maybePrint(e) return False settings.maybePrint("Image(s) Entered") if str(settings.DEBUG) == "True" and str(settings.DEBUG_DELAY) == "True": time.sleep(int(settings.DEBUG_DELAY_AMOUNT)) return True except Exception as e: settings.maybePrint(e) print("Error: Failure to Enter Image(s)") return False
def write_users_local(users=None): if users is None: users = User.get_all_users() print("Saving Users Locally") settings.maybePrint("local data path: " + str(settings.USERS_PATH)) data = {} data['users'] = [] for user in users: settings.maybePrint("Saving: " + str(user.username)) data['users'].append(user.toJSON()) try: with open(settings.USERS_PATH, 'w') as outfile: json.dump(data, outfile, indent=4, sort_keys=True) except FileNotFoundError: print("Error: Missing Local Users") except OSError: print("Error: Missing Local Path")
def message_price(price): try: if not price or price == None or str(price) == "None": print("Error: Missing Price") return False print("Enter price: {}" .format(price)) global BROWSER WAIT = WebDriverWait(BROWSER, 600, poll_frequency=10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, ONLYFANS_PRICE))).click() # BROWSER.find_element_by_css_selector(ONLYFANS_PRICE) BROWSER.find_elements_by_css_selector(ONLYFANS_PRICE_INPUT)[1].send_keys(str(price)) BROWSER.find_elements_by_css_selector(ONLYFANS_PRICE_CLICK)[4].click() settings.maybePrint("Price Entered") if str(settings.DEBUG) == "True" and str(settings.DEBUG_DELAY) == "True": time.sleep(int(settings.DEBUG_DELAY_AMOUNT)) return True except Exception as e: settings.maybePrint(e) print("Error: Failure to Enter Price") return False
def performMessage(actionChoice, messageChoice): username = None if str(messageChoice) == "select": messageChoice = "user" users = displayUsers() seeking = True while seeking: choice = input(">> ") try: if int(choice) < 0 or int(choice) > len(users): raise ValueError if int(choice) == 0: return finalizeMessage(actionChoice) username = users[int(choice)-1].username seeking = False except (ValueError, IndexError): print(sys.exc_info()[0]) print("Error: Incorrect Index") return mainMenu() elif str(messageChoice) == "user": print("Username:"******">> ") images = selectImage(messageChoice) # [folder , image_file] # print("len: " + str(len(images))) while True: choice = input(">> ") try: if int(choice) < 0 or int(choice) > len(images): raise ValueError if int(choice) == 0: return finalizeMessage(actionChoice) try: image = images[int(choice)-1] message(messageChoice, [image[1],image[0]], username) return mainMenu() # except (ValueError, IndexError): # print("Error: Incorrect Index") except Exception as e: settings.maybePrint(e) print("Error: Missing Method") except (ValueError, IndexError): print("Error: Incorrect Index")
def __init__(self, data): data = json.loads(json.dumps(data)) # print(data) self.name = data.get('name') self.username = data.get('username') self.id = data.get('id') self.messages_from = data.get('messages_from') or [] self.messages_to = data.get('messages_to') or [] self.messages = data.get('messages') or [] self.preferences = data.get('preferences') or [] self.last_messaged_on = data.get('last_messaged_on') self.sent_images = data.get('sent_images') or [] self.subscribed_on = data.get('subscribed_on') self.isFavorite = data.get('isFavorite') or False self.statement_history = data.get('statement_history') or [] self.started = data.get('started') ###### f*****g json ##### self.messages_from = ",".join(self.messages_from).split(",") self.messages_to = ",".join(self.messages_from).split(",") self.messages = ",".join(self.messages_from).split(",") self.preferences = ",".join(self.messages_from).split(",") self.sent_images = ",".join(self.messages_from).split(",") self.statement_history = ",".join(self.messages_from).split(",") ######################### try: settings.maybePrint("User: {} - {} - {}".format( self.name, self.username, self.id)) except Exception as e: settings.maybePrint(e) settings.maybePrint("User: {}".format(self.id))
def sendMessage(self, message="", image=None, price=None): try: print("Sending Message: {} <- {} - {} - ${}".format( self.id, message, image, price)) OnlySnarf.message_user(self) success = OnlySnarf.message_text(message) if not success: return if image: image_name = os.path.basename(image) if str(image_name) in self.sent_images: print("Error: Image Already Sent: {} -> {}".format( image, self.id)) return False success = OnlySnarf.message_image(image) if not success: return False if price: global PRICE_MINIMUM if image != None and Decimal(sub(r'[^\d.]', '', price)) < PRICE_MINIMUM: print("Warning: Price Too Low, Free Image") print("Price Minimum: ${}".format(PRICE_MINIMUM)) else: success = OnlySnarf.message_price(price) if not success: return False if str(settings.DEBUG) == "True": self.sent_images.append("DEBUG") else: self.sent_images.append(str(image_name)) if str(settings.DEBUG) == "True" and str( settings.DEBUG_DELAY) == "True": time.sleep(int(settings.DEBUG_DELAY_AMOUNT)) success = OnlySnarf.message_confirm() if not success: return False if str(settings.DEBUG) == "False": self.last_messaged_on = datetime.now() return True except Exception as e: settings.maybePrint(e) return False
def message_user(user): try: if not auth(): return False userid = user.id if not userid or userid == None or str(userid) == "None": print("Warning: Missing User ID") if not user.username or user.username == None: print("Error: Missing User ID & Username") return False userid = str(user.username).replace("@u","").replace("@","") if len(re.findall("[A-Za-z]", userid)) > 0: print("Warning: Invalid User ID") if str(settings.DEBUG) == "False": return False settings.maybePrint("goto -> /my/chats/chat/%s" % userid) global BROWSER BROWSER.get(str(ONLYFANS_CHAT_URL)+str(userid)) return True except Exception as e: settings.maybePrint(e) print("Error: Failure to Goto User - {}/{}".format(user.id, user.username)) return False
def expiration(period): if not auth(): return False if int(period) != 1 and int(period) != 3 and int(period) != 7 and int(period) != 30 and int(period) != 99 and str(period) != "No limit": print("Error: Missing Expiration") return False global BROWSER try: # goToHome() if isinstance(period,str) and str(period) == "No limit": period = 99 print("Expiration:") print("- Period: {}".format(period)) try: BROWSER.find_element_by_class_name(ONLYFANS_MORE).click() except Exception as e: pass BROWSER.find_element_by_class_name(EXPIRATION).click() nums = BROWSER.find_elements_by_class_name(EXPIRATION_PERIODS) for num in nums: inner = num.get_attribute("innerHTML") if str(inner) == "1 day" and int(period) == 1: num.click() if str(inner) == "3 days" and int(period) == 3: num.click() if str(inner) == "7 days" and int(period) == 7: num.click() if str(inner) == "30 days" and int(period) == 30: num.click() if "No limit" in str(inner) and int(period) == 99: num.click() if str(settings.DEBUG) == "True" and str(settings.DEBUG_DELAY) == "True": time.sleep(int(settings.DEBUG_DELAY_AMOUNT)) save = BROWSER.find_element_by_class_name(EXPIRATION_SAVE) if str(settings.DEBUG) == "True": print("Skipping Expiration (debug)") cancels = BROWSER.find_elements_by_class_name(EXPIRATION_CANCEL) cancels[1].click() # its the second cancel button else: save.click() print("Expiration Entered") return True except Exception as e: settings.maybePrint(e) print("Error: Failed to enter Expiration") return False
def get_new_trial_link(): if not auth(): return False global BROWSER # go to onlyfans.com/my/subscribers/active try: settings.maybePrint("goto -> /my/promotions") BROWSER.get(('https://onlyfans.com/my/promotions')) trial = BROWSER.find_elements_by_class_name("g-btn.m-rounded.m-sm")[0].click() create = BROWSER.find_elements_by_class_name("g-btn.m-rounded") for i in range(len(create)): if create[i].get_attribute("innerHTML").strip() == "Create": create[i].click() break # copy to clipboard? email to user by email? # count number of links # div class="b-users__item.m-fans" trials = BROWSER.find_elements_by_class_name("b-users__item.m-fans") # print("trials") # find last one in list of trial link buttons # button class="g-btn m-sm m-rounded" Copy trial link # trials = BROWSER.find_elements_by_class_name("g-btn.m-sm.m-rounded") # print("trials: "+str(len(trials))) # trials[len(trials)-1].click() # for i in range(len(create)): # print(create[i].get_attribute("innerHTML")) # find the css for the email / user # which there isn't, so, create a 1 person limited 7 day trial and send it to their email # add a f*****g emailing capacity # send it link = "https://onlyfans.com/action/trial/$number" return link except Exception as e: settings.maybePrint(e) print("Error: Failed to Apply Promotion") return None
def read_users_local(): settings.maybePrint("Getting Local Users") users = [] users_ = [] try: with open(settings.USERS_PATH) as json_file: users = json.load(json_file)['users'] settings.maybePrint("Loaded:") for user in users: try: users_.append(User(json.loads(user))) except Exception as e: settings.maybePrint(e) return users_ except Exception as e: settings.maybePrint(e) return users_
def get_active_users(): if str(settings.PREFER_LOCAL) == "True": return read_users_local() active_users = [] users = OnlySnarf.get_users() for user in users: try: user = User(user) user = skipUserCheck(user) if user is None: continue active_users.append(user) except Exception as e: settings.maybePrint(e) settings.maybePrint("pruning memberlist") settings.maybePrint("users: {}".format(len(active_users))) write_users_local(users=active_users) settings.PREFER_LOCAL = True return active_users
def main_other(): settings.initialize() initialize() main()