def send_webhook( url: str, content: Optional[Union[str, DiscordEmbed]] = None, images: List[str] = None, ): """Send a Discord webhook. :param url: :type url: str :param content: :type content: Optional[Union[str, DiscordEmbed]] :param images: :type images: List[str] """ if TEST is True: logger.debug("Testing mode. Not sending webhook: %s", content) return None images = images or [] profile = random.choice(WEBHOOK_PROFILES) webhook = DiscordWebhook(url, **profile) if isinstance(content, str): webhook.set_content(content[:1900]) elif isinstance(content, DiscordEmbed): webhook.add_embed(content) for image in images: with open(image, "rb") as f: webhook.add_file(file=f.read(), filename=os.path.basename(image)) webhook.execute() return None
class Discord: def __init__(self): DISCORD_WEBHOOK_URL = os.environ['DISCORD_WEBHOOK_URL'] self.webhook = DiscordWebhook(url=DISCORD_WEBHOOK_URL) def send_embedded_message(self, title='', description='', color='03b2f8'): embed = DiscordEmbed(title=title, description=description, color=color) # add embed object to webhook self.webhook.add_embed(embed) response = "" try: response = self.webhook.execute() except Exception as e: return False, e, response return True def send_message(self, message=""): self.webhook.set_content(message) response = "" try: response = self.webhook.execute() except Exception as e: return False, e, response return True
def send_webhook( url: str, content: Optional[Union[str, DiscordEmbed]] = None, images: List[str] = None, ): """Send a Discord webhook. :param url: :type url: str :param content: :type content: Optional[Union[str, DiscordEmbed]] :param images: :type images: List[str] """ images = images or [] webhook = DiscordWebhook(url) if isinstance(content, str): webhook.set_content(content[:1900]) elif isinstance(content, DiscordEmbed): webhook.add_embed(content) for image in images: with open(image, "rb") as f: webhook.add_file(file=f.read(), filename=os.path.basename(image)) webhook.execute()
def furybot(): print("GNOMES ARE REAL :D") under_over = True try: count = 0 while True: print("Checking Tables") mouse.position = (763, 878) mouse.press(Button.left) mouse.release(Button.left) sleep(0.5) last_bet_path = browser.find_element_by_xpath( '//*[@id="app"]/div[3]/div[2]/div[1]/div/div/div[2]/div[2]/div[2]/div[1]/div[5]/div/div/span' ) sleep(0.15) last_bet_text = last_bet_path.text last_bet = Decimal(last_bet_text) last_bet_path2 = browser.find_element_by_xpath( '//*[@id="app"]/div[3]/div[2]/div[1]/div/div/div[2]/div[2]/div[2]/div[2]/div[5]/div/div/span' ) sleep(0.15) last_bet_text2 = last_bet_path2.text last_bet2 = Decimal(last_bet_text2) last_bet_path3 = browser.find_element_by_xpath( '//*[@id="app"]/div[3]/div[2]/div[1]/div/div/div[2]/div[2]/div[2]/div[3]/div[5]/div/div/span' ) sleep(0.15) last_bet_text3 = last_bet_path3.text last_bet3 = Decimal(last_bet_text3) last_bet_path4 = browser.find_element_by_xpath( '//*[@id="app"]/div[3]/div[2]/div[1]/div/div/div[2]/div[2]/div[2]/div[4]/div[5]/div/div/span' ) sleep(0.15) last_bet_text4 = last_bet_path4.text last_bet4 = Decimal(last_bet_text4) last_bet_path5 = browser.find_element_by_xpath( '//*[@id="app"]/div[3]/div[2]/div[1]/div/div/div[2]/div[2]/div[2]/div[5]/div[5]/div/div/span' ) sleep(0.15) last_bet_text5 = last_bet_path5.text last_bet5 = Decimal(last_bet_text5) balance_check = browser.find_element_by_xpath( '//*[@id="app"]/div[2]/div/div/nav/div[2]/div[1]/div/div[1]/div/span/span' ) balance_text = balance_check.text balance2 = balance_text.replace(" ", "") balance = Decimal(balance2) if last_bet > 0: bet_1 = True else: bet_1 = False if last_bet2 > 0: bet_2 = True else: bet_2 = False if last_bet3 > 0: bet_3 = True else: bet_3 = False if last_bet4 > 0: bet_4 = True else: bet_4 = False if last_bet5 > 0: bet_5 = True else: bet_5 = False if balance < 0.0000005: WEBHOOK_URL = discordwebhook webhook = DiscordWebhook(WEBHOOK_URL) webhook.set_content(content='***BOT BUSTED STOPPING BOT***', description=str(balance)) webhook.send() exit() if bet_1 == False and bet_2 == False and bet_3 == False and bet_4 == True: print("Three Bets Lost") increase_bet() bet() elif bet_1 == False and bet_2 == False and bet_3 == False and bet_4 == False and bet_5 == True: print("Four Bets Lost, Increasing Bet size 2x.") bet_value_path = browser.find_element_by_xpath( '//*[@id="app"]/div[3]/div[2]/div[1]/div/div/div[2]/div[2]/div[2]/div[1]/div[3]/div/div' ) bet_value_text = bet_value_path.text bet_value = float(bet_value_text) switcher = True if switcher == True: if bet_value > 0.000001: print("Changing Under/Over") if under_over == True: print("Switching to Roll Over") mouse.position = (1049, 552) mouse.press(Button.left) mouse.release(Button.left) sleep(0.25) mouse.position = (902, 615) mouse.press(Button.left) mouse.release(Button.left) under_over = False elif under_over == False: mouse.position = (619, 552) mouse.press(Button.left) mouse.release(Button.left) sleep(0.25) mouse.position = (836, 627) mouse.press(Button.left) mouse.release(Button.left) under_over = True else: pass increase_bet() increase_bet() bet() elif bet_1 == False and bet_2 == False and bet_3 == False and bet_4 == False and bet_5 == False: print("Five Bets Lost, Increasing Bet size 1x.") bet_value_path = browser.find_element_by_xpath( '//*[@id="app"]/div[3]/div[2]/div[1]/div/div/div[2]/div[2]/div[2]/div[1]/div[3]/div/div' ) bet_value_text = bet_value_path.text bet_value = float(bet_value_text) switcher = True if switcher == True: if bet_value > 0.000001: print("Changing Under/Over") if under_over == True: print("Switching to Roll Over") mouse.position = (1049, 552) mouse.press(Button.left) mouse.release(Button.left) sleep(0.25) mouse.position = (902, 615) mouse.press(Button.left) mouse.release(Button.left) under_over = False elif under_over == False: mouse.position = (619, 552) mouse.press(Button.left) mouse.release(Button.left) sleep(0.25) mouse.position = (836, 627) mouse.press(Button.left) mouse.release(Button.left) under_over = True else: pass increase_bet() bet() else: if count < 50: print("Loop Number", count) count += 1 else: count = refresh() check_balance() reset_bet() # amunt of times to increas base bet for _ in range(double_times): increase_bet() bet() except ValueError as value_error: print(value_error) sleep(5) furybot() except NoSuchElementException as no_element: print(no_element) sleep(5) furybot() except StaleElementReferenceException as stale_element: print(stale_element) sleep(5) furybot() except AttributeError as attribute_error: print(attribute_error) sleep(5) furybot() except TypeError as type_error: print(type_error) sleep(5) furybot() except Exception as e: sleep() refresh() furybot()
def send_webhook_message( retailer, product, item_name, product_image, quantity, is_combo, discord_role_id, discord_channel, in_stock_bot_chat, ): webhook = DiscordWebhook(discord_channel) # create embed object for webhook embed = DiscordEmbed(description=item_name, color=0x10AC00) product_url = product["url"] # set description if is_combo: embed.set_description("{} is available IN A COMBO.".format(item_name)) embed.set_title("COMBO IN STOCK!!") else: embed.set_description("{} is now in stock.".format(item_name)) embed.set_title("{} IN STOCK!!".format(item_name)) # set author embed.set_author(name=retailer, url=product_url, icon_url=RETAILER_ICONS[retailer]) # set thumbnail if product_image: embed.set_thumbnail(url=product_image) # set footer embed.set_footer( text= "Please report any issues by sending the @programmer role a message.") # set timestamp (default is now) embed.set_timestamp() # add fields to embed if product["brand"]: embed.add_embed_field(name="Brand", value=product["brand"]) if product["model"]: embed.add_embed_field(name="Model", value=product["model"]) if product["series"]: embed.add_embed_field(name="Series", value=product["series"]) embed.add_embed_field(name="URL", value=product_url) # add embed object to webhook webhook.add_embed(embed) # ping discord roles if not in stock-bot if not in_stock_bot_chat: time_since_last_ping = datetime.now( ) - sent_role_pings[discord_role_id] time_since_last_ping_in_sec = round( time_since_last_ping.total_seconds(), 2) if time_since_last_ping_in_sec > 600: webhook.set_content("<@&{}>".format(discord_role_id)) sent_role_pings[discord_role_id] = datetime.now() sent_webhook = webhook.execute() # add not-in-stock edited webhook message and save it for later webhook.remove_embed(0) embed.set_color(0xC90000) if is_combo: embed.set_title("Combo is no longer in stock.") embed.set_description( "{} is no longer available in a combo.".format(item_name)) else: embed.set_title("Item is no longer in stock.") embed.set_description("{} is not in stock.\n Quantity sold: {}".format( item_name, quantity)) webhook.add_embed(embed) return (webhook, sent_webhook)