def sendHook(content): webhook = DiscordWebhook(url=webhookurl) embed = DiscordEmbed(title='Target Instore Monitor', description=content + '\nBestBuy Instore by jxn', color=int('009000')) webhook.add_embed(embed) webhook.execute()
async def send_webhook(self, sub_name_, author_, title_, link_, image_, time_, text_, footer_): webhook = DiscordWebhook(url=self.channel_urls) # create embed object for webhook embed = DiscordEmbed(title=title_, color=BaseProgram.block_color, url=link_) embed.set_author(name="r/" + sub_name_, url="https://www.reddit.com/r/AQW/", icon_url=BaseProgram.icon_dict[sub_name_]) chunks = textwrap.wrap(text_, 1024, break_long_words=False) if chunks: embed.description = chunks[0] if len(chunks) > 0: for chunk in chunks[1:]: embed.add_embed_field(name="\u200b", value=chunk, inline=False) embed.add_embed_field( name='Author:', value=f"[u/{author_}](https://www.reddit.com/user/{author_}/)", inline=True) embed.add_embed_field(name='Date Posted:', value=time_, inline=True) if image_: embed.set_image(url=image_.strip()) if footer_: embed.set_footer(text=footer_) webhook.add_embed(embed) response = webhook.execute()
def restartbot(self): # restarts the bot after 2 hours print(Style.RESET_ALL) print(Fore.RED + " [!] BOT IS RESTARTING AFTER 2 HOURS") try: self.RPC.close() except Exception: pass if self.foundwebhook == True: try: webhook = DiscordWebhook(url=self.hookline, username="******") embed = DiscordEmbed( color=0xFF0000, title="Restart Notification", description= "Bot has been running for more than 2 hours\nBot will now be restarted\nThis is to prevent crashes" ) embed.set_author( name=self.version, url="https://github.com/MrFums/Valbot", icon_url= "https://raw.githubusercontent.com/MrFums/ValbotAssets/main/jett.png", ) embed.set_footer(text=self.version.replace("Valbot", "")) embed.set_timestamp() webhook.add_embed(embed) webhook.execute() except Exception: print(Fore.RED + " [!] TRIED TO SEND A WEBHOOK BUT IT IS NOT SETUP") time.sleep(1) os.startfile("restart.py" ) # starts the restart script which reopens this script time.sleep(3) quit() # quits this runtime of the script
def send_war_nag(config, current_war, member_list): nagConfig = WarNagConfig(config, current_war, member_list) if nagConfig.abort or nagConfig.naughty_member_list == '': return logger.debug('Sending nag webhook') webhook = DiscordWebhook(url=nagConfig.webhook_url) # add list of naughty users as embed embed object to webhook embed = DiscordEmbed(title=nagConfig.nag_header, description=nagConfig.naughty_member_list, color=int('0xff5500', 16)) if nagConfig.quit_member_list: webhook.add_embed(embed) embed = DiscordEmbed( title=config['strings']['discord-header-war-quit'].format(), description=nagConfig.quit_member_list, color=int('0x660000', 16)) embed.set_footer(text='crtools v{}'.format(__version__)) embed.set_timestamp() webhook.add_embed(embed) webhook.execute()
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 testConfig(self): Main.data['minecraft_path'] = self.EntryMinecraftPathValue.get() Main.data['webhook'] = self.EntryWebhookValue.get() print(self.EntryMinecraftPathValue.get()) print(self.EntryWebhookValue.get()) print(Main.data['minecraft_path']) print(Main.data['webhook']) webhook = DiscordWebhook(url=Main.data['webhook']) embed = DiscordEmbed(title="Message de " + Main.data['playername'], description="Test de configuration.", color=484848) webhook.add_embed(embed) webhook.execute() try: with open(os.path.join(os.getenv('APPDATA'), 'Minecraft-Discord.json'), mode='w') as jsonFile: jsonData = dict() jsonData["webhook"] = Main.data['webhook'] jsonData["minecraft_path"] = Main.data['minecraft_path'] json.dump(jsonData, jsonFile) except Exception as e: print(e) self.watcher.stop() self.watcher = MinecraftWatcher() self.watcher.start()
def check_url(account, user, account_index): global monitoring global SAVE global DISCORD_URL old_url = account[1][1] try: new_url = user.entities['url']['urls'][0]['expanded_url'].lower() if old_url != new_url: monitoring[account_index][1][1] = new_url screen_name = user.screen_name user_url = "https://www.twitter.com/{}".format(screen_name) webhook = DiscordWebhook(url=DISCORD_URL) embed = DiscordEmbed(color=0xE800FF) embed.set_author( name="{} changed their BIO URL...".format(screen_name), url=user_url, icon_url=user.profile_image_url_https) embed.add_embed_field(name='**OLD BIO URL**', value="**{}**".format(old_url), inline=True) embed.add_embed_field(name='**NEW BIO URL**', value="**{}**".format(new_url), inline=True) webhook.add_embed(embed) webhook.execute() SAVE = True except: pass
def message_post(webhook_url, title, image, restricrt, method, starttime): try: webhook = DiscordWebhook(url=webhook_url, content='') embed = DiscordEmbed(title=title, color=0x00fea9, url="https://nike.com/launch") embed.add_embed_field(name='**Product Infos:**', value='Access: ' + restricrt + '\n\n' + 'Start Time: ' + starttime + '\n\n' + 'Release Type: ' + method) embed.set_thumbnail(url=image) embed.set_footer( text='@zyx898', icon_url= 'https://pbs.twimg.com/profile_images/1118878674642714624/lNXTIWNT_400x400.jpg' ) embed.set_timestamp() webhook.add_embed(embed) webhook.execute() print(gettime() + '[SUCCESS] --> Successfully sent success webhook!') except: print(gettime() + '[ERROR] --> Unable to send webhook') pass
def send_webhook(self, id_, status): if not self._log[str(id_)]['auto']: return try: if jobReturn(status).name not in self._args.job_dt_send_type.split('|') or not self._args.job_dt_wh: return from discord_webhook import DiscordWebhook, DiscordEmbed _webhook = DiscordWebhook(url=self._args.job_dt_wh_url) origin = self._log[str(id_)]['origin'] file_ = self._log[str(id_)]['file'] processtime = self._log[str(id_)].get('processingdate', None) returning = self._log[str(id_)].get('returning', '-') logger.info("Send discord status for device {} (Job: {})".format(str(origin), str(file_))) embed = DiscordEmbed(title='MAD Job Status', description='Automatic Job processed', color=242424) embed.set_author(name='MADBOT') embed.add_embed_field(name='Origin', value=origin) embed.add_embed_field(name='Jobname', value=file_) embed.add_embed_field(name='Retuning', value=returning) embed.add_embed_field(name='Status', value=jobReturn(status).name) embed.add_embed_field(name='Next run', value=str(datetime.fromtimestamp(processtime) if processtime is not None else "-")) _webhook.add_embed(embed) _webhook.execute() embed = None except Exception as e: logger.error('Cannot send discord webhook for origin {} - Job {} - Reason: {}'.format( str(origin), str(file_), str(e)))
def webhook(item, price_usd, price_gbp, upvotes, downvotes, image): try: webhook = DiscordWebhook(hook) embed = DiscordEmbed(title='', description='', color=0x2feb61) #2feb61 embed.set_title(title='Supreme Droplist') embed.set_image(url=image) embed.add_embed_field(name='Item', value=f'**{item}**', inline=False) embed.add_embed_field(name='Price', value=f'**${price_usd}** / **£{price_gbp}**', inline=False) embed.add_embed_field(name='Upvotes', value=f'**{upvotes}**', inline=True) embed.add_embed_field(name='Downvotes', value=f'**{downvotes}**', inline=True) embed.set_footer(text='CharlieAIO | Supreme Droplist') webhook.add_embed(embed) webhook.execute() except: time.sleep(3) webhook(item, price_usd, price_gbp, upvotes, downvotes, image)
def post_to_discord(prev_minutes, current_hours, tc_fname, tc_lname, tc_cid, tc_hours): # create embed object for webhook embed = DiscordEmbed( title='Weekly Statistics', description='Statustics for the week of {}.{}.{}'.format( today.year, today.month, today.day), color=242424) # set image embed.set_thumbnail( url='https://image.prntscr.com/image/mTFpZeXOR8_lGUTO8gVg-Q.png') current_hours = round(current_hours / 60 / 60, 1) embed.add_embed_field(name='This Weeks Hours', value='{}'.format(current_hours)) embed.add_embed_field(name='Last Weeks Hours', value='{}'.format(prev_minutes)) embed2 = DiscordEmbed( title='This weeks top controller:', description='{0} {1} - CID: {2} with {3} hours! Congratulations!'. format(tc_fname, tc_lname, tc_cid, tc_hours), color=242424) # Post fun stuff to Discord webhook = DiscordWebhook(url=discord_webhook) # add embed object to webhook webhook.add_embed(embed) webhook.add_embed(embed2) webhook.execute()
def post_discord(imageUrl, title, status, styleColor, publishType, exclusiveAccess, hardLaunch, price, availability, method, Name, sizes): info = ( f'Method: {method} | Type: {publishType} |\n Price: {price} | Hard Launch: {hardLaunch} |' ) webhook = DiscordWebhook(url=webhookUrl, content='') embed = DiscordEmbed( title=f'{title} [ {status} ]', url='https://www.nike.com/launch/t/' + str(title), color=0x36393F, description= f' {Name} - {styleColor}\n | Avilable: {str(availability)} | Exclusive: {exclusiveAccess}' ) embed.add_embed_field(name='Info', value=info) embed.add_embed_field(name='Stock', value='\n'.join(sizes), inline=False) embed.set_author( name='@zyx898', icon_url= 'https://pbs.twimg.com/profile_images/1118878674642714624/lNXTIWNT_400x400.jpg', url='https://twitter.com/zyx898') embed.set_thumbnail(url=imageUrl) embed.set_footer( text=Name + ' | SkrNotify', icon_url= 'https://pbs.twimg.com/profile_images/1134245182738718721/N12NVkrt_400x400.jpg' ) embed.set_timestamp() webhook.add_embed(embed) webhook.execute()
def main_function(count_num): twitter_client = TwitterClient() api = twitter_client.get_twitter_client_api() tweet_info = TweetInfo() discord_wh_url = twitterCred.DISCORD_WH_URL hook = DiscordWebhook(url=discord_wh_url, username='******') embed = DiscordEmbed(title='NEW TWEET', description='https://twitter.com/RestockWorld/with_replies?lang=en', color=242424) tweets = api.user_timeline(id='1075875489603076096', count=count_num) df = tweet_info.tweets_to_data_frame(tweets) print(df.head(count_num)) if hasattr(tweets[0], 'retweeted_status'): pass # print('\nRETWEET') else: if 'media' in tweets[0].extended_entities: for image in tweets[0].extended_entities['media']: embed.set_image(url=image['media_url']) else: embed.set_image(url='http://proxy6006.appspot.com/u?purl=MDA1eDAwNTEvMDIxMDAxMzY1MS82OTA2NzAzMDY5ODQ1Nzg1NzAxL3NyZW5uYWJfZWxpZm9ycC9t%0Ab2MuZ21pd3Quc2JwLy86c3B0dGg%3D%0A') embed.set_thumbnail(url='https://twitter.com/RestockWorld/with_replies?lang=en') embed.add_embed_field(name='Tweet: ', value=tweets[0].text) embed.set_timestamp() hook.add_embed(embed) hook.execute() id_list = ['1075875489603076096'] #'3309125130' twitter_streamer = TwitterStreamer() twitter_streamer.stream_tweets('tweets.json', id_list)
def send(chapter, discord_message): webhook = DiscordWebhook( content="<@&{role_id}> {message}".format( role_id=chapter.comic.discord_role_id, message=discord_message), url= 'https://discordapp.com/api/webhooks/595905581181698048/qfdi8ZyuuvokzcXThH4JC7iO6_0q4dEhU5MXaM2Yfl56nGiRYOYC66QukxB7gCykhEF6' ) webhook.execute() domainName = "http://firesyndicate.tk" webhook = DiscordWebhook( url= 'https://discordapp.com/api/webhooks/595905581181698048/qfdi8ZyuuvokzcXThH4JC7iO6_0q4dEhU5MXaM2Yfl56nGiRYOYC66QukxB7gCykhEF6' ) embed = DiscordEmbed( title="Chapter {num} | {name}".format(num=chapter.number, name=chapter.name), url="{domain}{chUrl}".format(domain=domainName, chUrl=chapter.get_absolute_url()), description=chapter.comic.description, color=0x4ac6df) embed.set_author(name=chapter.comic.title) embed.set_thumbnail(url=domainName + chapter.comic.cover.url) webhook.add_embed(embed) webhook.execute()
def discord_webhook(callsign, name, cid, rating_long, server, status): webhook = DiscordWebhook(url=webhookurl) if status == "online": embed = DiscordEmbed(title=callsign + " - Online", description=callsign + ' is now online on the VATSIM network.', color=65290) embed.set_footer(text='ZDC VATSIM Notify Bot ' + version, icon_url='https://vzdc.org/photos/discordbot.png') embed.set_thumbnail(url='https://vzdc.org/photos/logo.png') embed.set_timestamp() embed.add_embed_field(name='Name', value=name) embed.add_embed_field(name='Rating', value=rating_long) embed.add_embed_field(name='CID', value=cid) embed.add_embed_field(name='Callsign', value=callsign) embed.add_embed_field(name='Server', value=server) webhook.add_embed(embed) webhook.execute() webhook.remove_embed(0) else: embed = DiscordEmbed(title=callsign + " - Offline", description=callsign + ' is now offline on the VATSIM network.', color=16711683) embed.set_footer(text='ZDC VATSIM Notify Bot ' + version, icon_url='https://vzdc.org/photos/discordbot.png') embed.set_thumbnail(url='https://vzdc.org/photos/logo.png') embed.set_timestamp() #embed.add_embed_field(name='Name', value=name) #embed.add_embed_field(name='Rating', value=rating_long) #embed.add_embed_field(name='CID', value=cid) #embed.add_embed_field(name='Callsign', value=callsign) #embed.add_embed_field(name='Server', value=server) webhook.add_embed(embed) webhook.execute() webhook.remove_embed(0)
def send_status(url: str, file_path: str = None, size: int = None): """Send a status update to Discord. Parameters ---------- url : str The url of the webhook. file_path : str, optional The name of the uploaded file, if it exists, by default None size : int, optional The size of the uploaded file, if it exists, by default None """ webhook = DiscordWebhook(url=url) embed = DiscordEmbed(title="**Database Backup Status**") embed.description = "" if file_path is not None: embed.add_embed_field(name="Status", value="Success 🟢", inline=True) embed.add_embed_field(name="File Name", value=f"`{file_path}`", inline=True) size = round(size / (10**6), 3) embed.set_footer(text=f"File size: {size} Mo") embed.set_timestamp() log(logging.info, "Sending success notification.") else: embed.add_embed_field(name="Status", value="Error 🔴", inline=True) embed.add_embed_field(name="File Name", value="None", inline=True) embed.set_timestamp() log(logging.info, "Sending error notification.") webhook.add_embed(embed) webhook.execute()
def update(request): daily_question = Daily_Question.objects.all().first() for user in Leaderboard.objects.all(): response, weekly_score = fetchResponse(user.username) for ques in Questions.objects.filter(daily_question=daily_question): if ques.url in response: user.questions.add(ques) Leaderboard.objects.filter(username=user.username).update( weekly_score=str(weekly_score)) webhook = DiscordWebhook( url= 'https://discord.com/api/webhooks/835633106689851442/ep_GF8vgmC9HZvbs8Uvt6wQSVHHhvKdk6iEs4JZGLdM-aukI7G00ete4qVjSpYPHLn3z' ) # create embed object for webhook # you can set the color as a decimal (color=242424) or hex (color='03b2f8') number embed = DiscordEmbed( title='LeaderBoard Updated', description= 'Hey all LeaderBoard is Updated do check out at \n https://www.realdevils.com/gfgdaily', color='03b2f8') # add embed object to webhook webhook.add_embed(embed) response = webhook.execute() return HttpResponse("done")
def main(): if request.method == 'GET': return '機器人在綫!' elif request.method == 'POST': raw = request.get_data() print("raw=", raw) try: raw = zlib.decompress(raw) print(raw) raw = json.loads(raw.decode('utf-8')) except: print(raw) raw = json.loads(raw) challenge = raw['d'].get("challenge", None) if challenge != None: challenge = {"challenge": challenge} print(json.dumps(challenge)) return json.dumps(challenge) else: author = raw['d']['extra']['author'] if author['bot'] == False: nickname = author['nickname'] if nickname == '': nickname = author['username'] avatar = author['avatar'] content = raw['d']['content'] webhook = DiscordWebhook(url=jdata['forward_webhook']) embed = DiscordEmbed(title=content) embed.set_author(name=nickname, icon_url=avatar) webhook.add_embed(embed) response = webhook.execute() return "200" else: print(request.get_data) return "200"
def discord_webhook(path, webhook_url): print("sharing to discord") #load the json file from the pass with open(path) as f: data = json.load(f) #send a message with the discord webhook webhook = DiscordWebhook(url=webhook_url, username="******") embed = DiscordEmbed(title=data["satellite"], description="Pass over Vancouver, Canada", color=242424) embed.add_embed_field(name='Max Elevation', value=str(data["max_elevation"]) + "°") embed.add_embed_field(name='Frequency', value=str(data["frequency"]) + " Hz") embed.add_embed_field(name="Duration", value=str(round(data["duration"])) + " seconds") embed.add_embed_field(name='Pass Start', value=datetime.utcfromtimestamp(data["aos"]).strftime("%B %-d, %Y at %-H:%M:%S UTC")) embed.add_embed_field(name='Sun Elevation', value=str(data["sun_elev"]) + "°") embed.set_image(url=data["main_image"]) #add all the image links links_string = "" for link in data["links"]: links_string += "[{}]({}), ".format(link, data["links"][link]) embed.add_embed_field(name="Other Image Links", value=links_string) webhook.add_embed(embed) response = webhook.execute() print("done") return response
def save(self, domain: str, *args, **kwargs): self.date = timezone.now() self.domain = domain super(AdminRightsRequest, self).save() group = get_object_from_full_slug(self.group) try: webhook = DiscordWebhook( url=settings.DISCORD_ADMIN_MODERATION_WEBHOOK) embed = DiscordEmbed( title=f'{self.student} demande à devenir admin de {group}', description=self.reason, color=242424) embed.add_embed_field(name='Accepter', value=f"[Accepter]({self.accept_url})", inline=True) embed.add_embed_field(name='Refuser', value=f"[Refuser]({self.deny_url})", inline=True) if (self.student.picture): embed.thumbnail = {"url": self.student.picture.url} webhook.add_embed(embed) webhook.execute() except Exception as e: logger.error(e) super(AdminRightsRequest, self).save()
def send_webhook_message(application, action): message_to_send = format_message(application, action) webhook = DiscordWebhook(url=DISCORD_WEBHOOK_URL, content=message_to_send) if ATTACH_LOGS: application_logs = lookup_application_logs(application) syslogs = lookup_application_logs('Server') if application_logs is not False: with open(application_logs, "rb+") as f: filename = application + '.txt' webhook.add_file(file=f.read(), filename=filename) if syslogs is not False: with open(syslogs, "rb+") as f: filename = syslogs + '.txt' webhook.add_file(file=f.read(), filename=filename) if EMBED_LOGS: application_logs = lookup_application_logs(application) syslogs = lookup_application_logs('Server') if application_logs is not False: embed = DiscordEmbed(title=application, description=tail(application_logs, 10)) webhook.add_embed(embed) if syslogs is not False: embed = DiscordEmbed(title='/var/log/syslog', description=tail(syslogs, 10)) webhook.add_embed(embed) webhook.execute()
def accept(self): group = get_object_from_full_slug(self.group) if group.is_member(self.student.user): membership = group.members.through.objects.get( student=self.student.id, group=group) membership.admin = True membership.save() else: group.members.through.objects.create(student=self.student, group=group, admin=True) mail = render_to_string('group/mail/new_admin.html', { 'group': group, 'user': self.student.user }) self.student.user.email_user(f'Vous êtes admin de {group}', mail, from_email=None, html_message=mail) webhook = DiscordWebhook(url=settings.DISCORD_ADMIN_MODERATION_WEBHOOK) embed = DiscordEmbed( title= f'La demande de {self.student} pour rejoindre {group} a été acceptée.', description="", color=00000) webhook.add_embed(embed) webhook.execute() self.delete()
def send_alert(data): if config.send_telegram_alerts: tg_bot = Bot(token=config.tg_token) try: tg_bot.sendMessage(data['telegram'], data['msg'].encode('latin-1', 'backslashreplace').decode('unicode_escape'), parse_mode='MARKDOWN') except KeyError: tg_bot.sendMessage(config.channel, data['msg'].encode('latin-1', 'backslashreplace').decode('unicode_escape'), parse_mode='MARKDOWN') except Exception as e: print('[X] Telegram Error:\n>', e) if config.send_discord_alerts: try: webhook = DiscordWebhook(url="https://discord.com/api/webhooks/" + data['discord']) embed = DiscordEmbed(title=data['msg']) webhook.add_embed(embed) response = webhook.execute() except KeyError: webhook = DiscordWebhook(url="https://discord.com/api/webhooks/" + config.discord_webhook) embed = DiscordEmbed(title=data['msg']) webhook.add_embed(embed) response = webhook.execute() except Exception as e: print('[X] Discord Error:\n>', e) if config.send_slack_alerts: try: slack = Slack(url='https://hooks.slack.com/services/' + data['slack']) slack.post(text=data['msg']) except KeyError: slack = Slack(url='https://hooks.slack.com/services/' + config.slack_webhook) slack.post(text=data['msg']) except Exception as e: print('[X] Slack Error:\n>', e) if config.send_twitter_alerts: tw_auth = tweepy.OAuthHandler(config.tw_ckey, config.tw_csecret) tw_auth.set_access_token(config.tw_atoken, config.tw_asecret) tw_api = tweepy.API(tw_auth) try: tw_api.update_status(status=data['msg'].replace('*', '').replace('_', '').replace('`', '')) except Exception as e: print('[X] Twitter Error:\n>', e) if config.send_email_alerts: try: email_msg = MIMEText(data['msg'].replace('*', '').replace('_', '').replace('`', '')) 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() except Exception as e: print('[X] Email Error:\n>', e)
def social_webhook(img_url, raffle_name, shop_name, raffle_type, soup, raffle_url): print("I'm in social") # Отправляем вебхук webhook = DiscordWebhook(url=WEBHOOK) # create embed object for webhook embed = DiscordEmbed(title=raffle_name, description="[{0}]({1})".format( "Click here if no links", raffle_url), color=10181046) # add embed object to webhook webhook.add_embed(embed) embed.set_author( name='Quasar Cook', icon_url= 'https://sun9-66.userapi.com/c856032/v856032229/1e2b12/JTB-w2_3DzI.jpg' ) embed.set_thumbnail(url=img_url) embed.add_embed_field(name='Type', value=raffle_type, inline=True) embed.add_embed_field(name='Store', value=shop_name, inline=True) embed.set_footer(text='Powered by Quasar Cook @hisoyem') response = webhook.execute() return insert_links_into_db(raffle_url)
def notify(message: object, fileName: object = None) -> object: try: webhook_url = conf["discord_webhooks"][conf["args"].account] if webhook_url is not None: webhook = DiscordWebhook(url=webhook_url) embed = DiscordEmbed() embed.set_footer(text=message) embed.set_timestamp() webhook.add_embed(embed) response = webhook.execute() except: pass url = 'https://notify-api.line.me/api/notify' #api_key = os.environ.get('LINE_APIKEY') api_key = conf['line_apikey']['API_KEY'] if api_key is None or len(api_key) == 0: return payload = {'message': message} headers = {'Authorization': 'Bearer ' + api_key} if fileName is None: try: requests.post(url, data=payload, headers=headers) except: pass else: try: files = {"imageFile": open(fileName, "rb")} requests.post(url, data=payload, headers=headers, files=files) except: pass
def notify_discord(subreddit, title, url): webhook = DiscordWebhook(url=config['discord']['webhook']) embed = DiscordEmbed(title=title, url=url, color=242424) embed.set_author(name='/r/' + subreddit) #embed.set_image(url='your image url') webhook.add_embed(embed) webhook.execute()
def WebhookDone(): get_ip = requests.get("https://api.ipify.org/?format=json").json()['ip'] get_hostname = requests.get("https://wtfismyip.com/json").json()['YourFuckingHostname'] get_location = requests.get("https://wtfismyip.com/json").json()['YourFuckingLocation'] get_isp = requests.get("https://wtfismyip.com/json").json()['YourFuckingISP'] get_tor = requests.get("https://wtfismyip.com/json").json()['YourFuckingTorExit'] get_os = platform.platform() webhook = DiscordWebhook(url='') ifc = "https://ifconfig.co/json" city = requests.get(ifc).json()['city'] asn = requests.get(ifc).json()['asn'] asn_org = requests.get(ifc).json()['asn_org'] zip = requests.get(ifc).json()['zip_code'] lat = requests.get(ifc).json()['latitude'] long = requests.get(ifc).json()['longitude'] embed = DiscordEmbed(title="Got a catch!", description="") emb = embed.add_embed_field embed.add_embed_field(name='Hostname', value=get_hostname) embed.add_embed_field(name="Are they on TOR?", value=get_tor) embed.add_embed_field(name="City", value=city) embed.add_embed_field(name='Location', value=get_location) embed.add_embed_field(name='OS', value=get_os) embed.add_embed_field(name="ISP", value=get_isp) embed.add_embed_field(name='IP Address', value=get_ip) embed.set_footer(text="Made with Love by Raz | This skid just got pwned lmao ") embed.set_timestamp() embed.set_author(text="IPGrabber by raz v0.1") webhook.add_embed(embed) resp = webhook.execute()
def bonus_pack(request): admins = SteamUser.objects.filter(is_staff=True) player = request.user for admin in admins: new_message = PrivateMessages.objects.create( to_player_id=admin.id, from_player_name=player.personaname, from_player_name_slug=player.nickname, from_player_avatar=str(player.avatar), text='Я бы хотел попросить бонус пак .\n' ' Мой SteamID {} . '.format(player.steamid)) new_message.save() player.bonus_pack = True player.save(force_update=True) messages.add_message( request, messages.SUCCESS, 'Заявка на получение бонус-пака отправлена! ' 'Ожидай в дискорде сообщения от администрации сервера.') webhook = DiscordWebhook(url=bot_settings.SHOP_ADMIN_URL) embed = DiscordEmbed(title='ЗАЯВКА НА БОНУС ПАК', color=0xec4e00) embed.add_embed_field(name='Заказчик : ', value=player.personaname) embed.add_embed_field(name='STEAMID: ', value=player.steamid) webhook.add_embed(embed) webhook.execute() return HttpResponseRedirect('/profile/' + request.user.nickname)
class DiscordIO(ActionBase): def __init__(self, webhook): super().__init__() self.webhook = webhook def output(self, payload, **kwargs): if not kwargs.get("mode"): raise Exception("Please specify a mode parameter") else: message_mode = kwargs.get("mode") message_forger = self.message_forger.get(message_mode) message_payload = message_forger(payload) title = message_payload.get("dt") description = message_payload.get("greeting") message_content = message_payload.get("claim") self.hook = DiscordWebhook(url=self.webhook, content=message_content) embed = DiscordEmbed(title=title, description=description, color=242424) embed.set_author(name="Mars Clock", url="http://interimm.org/mars-clock/") embed.set_footer(text="by InterImm Bot") self.hook.add_embed(embed) response = self.hook.execute() logger.info(f"Posted to discord: {message_content} {title} {description}")
def ganesh(webhook_url, product_image, store, product, size, price, profile, date, time): webhook = DiscordWebhook(url=webhook_url) embed = DiscordEmbed(title='New Login!') embed.set_thumbnail(url=product_image) embed.add_embed_field(name='Date Time', value='||' + date + ' ' + time + '||', inline=True) embed.add_embed_field(name='Store', value=store, inline=True) embed.add_embed_field(name='Profile', value='||' + profile + '||', inline=True) embed.add_embed_field(name='Product', value=product, inline=True) embed.add_embed_field(name='Size', value=size, inline=True) embed.add_embed_field(name='Price', value='$' + str(price) + '.00', inline=True) embed.add_embed_field(name='Order Number', value='||V' + str(random.randint(4000000000, 5000000000)) + '||', inline=False) embed.set_footer( text='@theGaneshBot • ' + date, icon_url= "https://images-ext-2.discordapp.net/external/XnfnaHmjhY6X2sMmA_z-5DoHnj5ZzpfudyBd2ABJ9h0/https/s3.eu-west-2.amazonaws.com/ganeshbotdl/ganesh_logo_square.png" ) webhook.add_embed(embed) response = webhook.execute()