def send_notification(webhook_url, product_title, product_image, product_price, properties_list, product_url, search_term="Dunk"): proxy = proxy_generator() proxies = {'http': 'https://51.161.62.120:8080'} proxies['http'] = f"https://{proxy['https']}" webhook = DiscordWebhook(url=webhook_url) webhook.set_proxies(proxies) # create embed object for webhook embed = DiscordEmbed(title=product_title, description=f"Price: {product_price}", color=242424) # set author embed.set_author(name=search_term, url=product_url, icon_url=product_image) # set image embed.set_image(url=product_image) # set thumbnail # embed.set_thumbnail(url=product_url) # set footer embed.set_footer(text="Available 🐱🏍") # set timestamp (default is now) embed.set_timestamp() # add fields to embed try: embed.add_embed_field(name='Farbe', value=properties_list[0]) embed.add_embed_field(name='Geschlecht', value=properties_list[1]) embed.add_embed_field(name='Herren', value=properties_list[2]) except: pass # add embed object to webhook webhook.add_embed(embed) print("{:s} is available now Notification sent to Discord".format( product_title)) response = webhook.execute()
#ask for link. urlq = input("Enter the link you want to make QR as. ") nam1 = input("Enter file name. ") size = input("Enter file size. ") big_code = pyqrcode.create(urlq) big_code.png('QR.png', scale=6) big_code.show() #Image Upload to server. with open("QR.png", "rb") as f: webhook.add_file(file=f.read(), filename='QR.jpg') #str to byte converter. byte = urlq.encode("utf-8") #Base64conversion base2 = base64.urlsafe_b64encode(byte) print(base2) #byte to str conversion base3 = base2.decode("utf-8") embed = DiscordEmbed(title=nam1, description=size + '\n' + base3, color=242424) # add embed object to webhook webhook.add_embed(embed) webhook.set_proxies(proxies) webhook.execute()