def send_embed(link, fields, site, image, product, webhook): ''' (str, str, list, str, str, str) -> None Sends a discord alert based on info provided. ''' embed = Webhook(webhook, color=123123) #if(alert_type == "NEW_SHOPIFY"): desc = product #elif(alert_type == "RESTOCK_SHOPIFY"): #desc = "RESTOCK: " + product embed.set_author(name='coplitshoes', icon='') embed.set_desc(desc) for field in fields: #if(alert_type == "NEW_SHOPIFY" or alert_type == "RESTOCK_SHOPIFY"): cart_link = site + "/cart/" + str(field[1]) + ":1" embed.add_field(name=str(field[0]), value=cart_link) if (image is not None): embed.set_thumbnail(image) embed.set_image(image) embed.set_footer(text='coplitshoes', icon='', ts=True) embed.post()
def send_embed(alert_type, link, fields, site, image, product): ''' (str, str, list, str, str, str) -> None Sends a discord alert based on info provided. ''' url = webhook embed = Webhook(url, color=123123) if(alert_type == "NEW_SHOPIFY"): desc = "NEW: " + product elif(alert_type == "RESTOCK_SHOPIFY"): desc = "RESTOCK: " + product embed.set_author(name='StirFry', icon='https://pbs.twimg.com/profile_images/1086659064304676865/oX8NsFC-_400x400.jpg') embed.set_desc(desc) for field in fields: if(alert_type == "NEW_SHOPIFY" or alert_type == "RESTOCK_SHOPIFY"): cart_link = site + "/cart/" + str(field[1]) + ":1" embed.add_field(name=str(field[0]), value=cart_link) if(image is not None): embed.set_thumbnail(image) embed.set_image(image) embed.set_footer(text='StirFry', icon='https://pbs.twimg.com/profile_images/1086659064304676865/oX8NsFC-_400x400.jpg', ts=True) embed.post()
def send_embed(alert_type, link, fields, site, image, product): ''' (str, str, list, str, str, str) -> None Sends a discord alert based on info provided. ''' url = webhook embed = Webhook(url, color=123123) if (alert_type == "NEW_SHOPIFY"): desc = "NEW: " + product elif (alert_type == "RESTOCK_SHOPIFY"): desc = "RESTOCK: " + product embed.set_author( name='NERYS', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg') embed.set_desc(desc) for field in fields: if (alert_type == "NEW_SHOPIFY" or alert_type == "RESTOCK_SHOPIFY"): cart_link = site + "/cart/" + str(field[1]) + ":1" embed.add_field(name=str(field[0]), value=cart_link) if (image is not None): embed.set_thumbnail(image) embed.set_image(image) embed.set_footer( text='NERYS by @snivynGOD', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg', ts=True) embed.post()
def send_embed(alert_type, product): ''' (str, str, list, str, str, str) -> None Sends a discord alert based on info provided. ''' # Set webhook url = https://discordapp.com/api/webhooks/555053278308859927/D1AsxzUajXuA3fchYuXwq_ib2OHW3S-UpNNYyYanoW7W2Eo9rBb-evVneSeRyPX_SOy7 # Create embed to send to webhook embed = Webhook(url, color=123123) # Set author info embed.set_author(name='NERYS', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg') # Set product details if(alert_type == "RESTOCK"): embed.set_desc("RESTOCK: " + product.title) elif(alert_type == "NEW"): embed.set_desc("NEW: " + product.title) embed.add_field(name="Product", value=product.title) embed.add_field(name="Link", value=product.link) embed.add_field(name="Stock", value=str(product.stock)) # Set product image embed.set_thumbnail(product.image) embed.set_image(product.image) # Set footer embed.set_footer(text='NERYS by @snivynGOD', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg', ts=True) # Send Discord alert embed.post()
def EmbedMsg(): global Author global AuthorID global Title global Banner global RankedLink global Length global BPM global GMFormat global GMFormat2 embed = Webhook(webhook, color=0x0098f9) embed.set_author(name='New {} map by {}'.format(GMFormat, Author), icon='https://a.ppy.sh/{}'.format(AuthorID), url='https://osu.ppy.sh/users/{}'.format(AuthorID)) embed.set_title(title='**__{}__**'.format(Title), url=RankedLink) embed.set_thumbnail(Banner) embed.set_desc("""**BPM:** {} **Song Length:** {} **Containing:** {} """.format(BPM, Length, GMFormat2)) embed.set_footer(text='Ranked!', ts=True, icon='https://hypercyte.s-ul.eu/W4GBjy0M') embed.post() NewRanked()
def webhook(link, currency, photo, title, description, ino): link = 'https://www.supremenewyork.com' + link.rstrip() url = "<WEBHOOK>" embed = Webhook(url, color=123123) embed.set_desc("RESTOCK: [{0}]({1})".format(title, link)) embed.add_field(name="Description", value=description) embed.add_field(name="Ino", value=ino) embed.add_field(name="Currency", value=currency) embed.add_field(name="Link", value=link) embed.set_thumbnail(photo) embed.set_footer(text='Powered by <COMPANY NAME>', ts=True, icon='<FOOTER ICON>') embed.post()
def sendWebhook(checkoutUrl, totaltime, method, productName, pictureurl, webhook): embed = Webhook(webhook, color=123123) embed.set_author(name='Checkout/Queue Bypass Link', url=checkoutUrl) embed.add_field(name='Product Name', value=productName) embed.add_field(name='Total Time', value=totaltime) embed.add_field(name='Created by', value="rycao18#3998") embed.add_field(name='Method', value=method) embed.set_thumbnail(pictureurl) embed.set_footer(text='RyZySply Bot - ' + str(time.strftime("%H:%M:%S")), icon='https://i.imgur.com/fG3Gu2Y.jpg', ts=True) embed.post()
def send_embed(alert_type, product): ''' (str, str, list, str, str, str) -> None Sends a discord alert based on info provided. ''' # Set webhook url = discord_webhook # Create embed to send to webhook # msg='@everyone' option making everyone msg method if (alert_type == "KNEW"): embed = Webhook(url, color=123123, msg='@everyone') else: embed = Webhook(url, color=123123) # Set author info embed.set_author( name='Mrporter', icon= 'https://previews.123rf.com/images/martialred/martialred1604/martialred160400080/55731598-%EB%A9%94%EC%8B%9C%EC%A7%80-%EC%95%B1%EA%B3%BC-%EC%9B%B9-%EC%82%AC%EC%9D%B4%ED%8A%B8%EC%97%90-%EB%8C%80%ED%95%9C-chatbot-%EC%B1%84%ED%8C%85-%EB%B4%87-%EB%98%90%EB%8A%94-%EC%B1%84%ED%84%B0-%EB%B4%87-%EB%9D%BC%EC%9D%B8-%EC%95%84%ED%8A%B8-%EC%95%84%EC%9D%B4%EC%BD%98.jpg' ) # Set product details if (alert_type == "RESTOCK"): embed.set_desc("RESTOCK: " + "title") elif (alert_type == "NEW"): embed.set_desc("NEW: " + product.name) elif (alert_type == "KNEW"): embed.set_desc("NEW: " + product.name) embed.add_field(name="Product", value=product.name) embed.add_field(name="Brand", value=product.brand) embed.add_field(name="Price", value=product.price) embed.add_field(name="Link", value=product.siteLik) #embed.add_field(name="ImgLink", value=product.link) # Set product image embed.set_thumbnail(product.link) embed.set_image(product.link) print(product.link) input() # Set footer embed.set_footer( text='Mrporter by @DevHong', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg', ts=True) # Send Discord alert embed.post()
def send_embed(alert_type, product): ''' (str, str, list, str, str, str) -> None Sends a discord alert based on info provided. ''' # Set webhook url = discord_webhook # Create embed to send to webhook embed = Webhook(url, color=123123) # Set author info embed.set_author( name='Nike', icon= 'https://static-breeze.nike.co.kr/kr/ko_kr/cmsstatic/theme/52/android-icon-36x36.png' ) # Set product details if (alert_type == "RESTOCK"): embed.set_desc("RESTOCK: " + "title") elif (alert_type == "NEW"): embed.set_desc("NEW: " + product.title) # Name, Code, Color, Date, Price # Early Link # Time embed.add_field(name="Name", value=product.name) embed.add_field(name="Code", value=product.code) embed.add_field(name="Color", value=product.color) embed.add_field(name="Price", value=product.price) embed.add_field(name="Link", value=product.siteLink) embed.add_field(name="Time", value=product.pTime) embed.add_field(name="ImgLink", value=product.imgLink) # Set product image embed.set_thumbnail(product.imgLink) embed.set_image(product.imgLink) # Set footer embed.set_footer( text='Nike by @DevHong', icon= 'https://static-breeze.nike.co.kr/kr/ko_kr/cmsstatic/theme/52/android-icon-36x36.png', ts=True) # Send Discord alert embed.post()
def notify(product, slack, discord): times = [] today = datetime.now() times.append(today) sizes = "" for size in product.stock_options: sizes += (size + " ") if slack: sc = slackweb.Slack(url=slack) attachments = [] attachment = { "title": product.title, "color": "#EAF4EC", "text": product.link, "fields": [{ "title": "Sizes", "value": sizes, "short": False }], "mrkdwn_in": ["text"], "thumb_url": product.image_url, "footer": "BBGR", "footer_icon": "https://platform.slack-edge.com/img/default_application_icon.png", "ts": time.time() } attachments.append(attachment) sc.notify(attachments=attachments) if discord: embed = Webhook(discord, color=0xEAF4EC) embed.set_title(title=product.title, url=product.link) embed.set_thumbnail(url=product.image_url) embed.add_field(name="Sizes", value=sizes) embed.set_footer(text='BBGR', icon='https://cdn.discordapp.com/embed/avatars/0.png', ts=True) embed.post()
def send_embed(alert_type, product): ''' (str, str, list, str, str, str) -> None Sends a discord alert based on info provided. ''' # Set webhook url = discord_webhook # Create embed to send to webhook embed = Webhook(url, color=123123) # Set author info embed.set_author( name='Premier Cooks', icon= 'https://pbs.twimg.com/profile_images/1031725580075585536/s0GlPWIB_400x400.jpg' ) # Set product details if (alert_type == "RESTOCK"): embed.set_desc("RESTOCK: " + product.title) elif (alert_type == "NEW"): embed.set_desc("NEW: " + product.title) embed.add_field(name="Product", value=product.title) embed.add_field(name="Link", value=product.link) embed.add_field(name="Stock", value=str(product.stock)) # Set product image embed.set_thumbnail(product.image) embed.set_image(product.image) # Set footer embed.set_footer( text='Supreme Monitor by @premiercooks', icon= 'https://pbs.twimg.com/profile_images/1031725580075585536/s0GlPWIB_400x400.jpg', ts=True) # Send Discord alert embed.post()
def send_embed(alert_type, product): url = discord_webhook embed = Webhook(url, color=123123) embed.set_author(name='ARB', icon='https://sun9-74.userapi.com/impf/x8e2VAfW-ao86OPcoUeSKpB7sup-dlIC3bT-2g/I3Vwk9su7D8.jpg?size=564x532&quality=96&sign=423037df9ddf5c5400c93844710086c3&type=album') if(alert_type == "RESTOCK"): embed.set_desc("RESTOCK: " + product.title) elif(alert_type == "NEW"): embed.set_desc("NEW: " + product.title) embed.add_field(name="Product", value=product.title) embed.add_field(name="Link", value=product.link) embed.add_field(name="Stock", value=str(product.stock)) # Set product image embed.set_thumbnail(product.image) embed.set_image(product.image) # Set footer embed.set_footer(text='ARB by @JaqueFresco', icon='https://sun9-11.userapi.com/impf/DagUwT61wIcd0BeLtPOI3UFtf2nV2ZK9Gh-8NQ/ehNPfNbLWGA.jpg?size=754x750&quality=96&sign=ce4bfc72ef8fdcfbbf3c11dbd8589382&type=album', ts=True) # Send Discord alert embed.post()
def send_embed(alert_type, link, fields, site, image, product): ''' (str, str, list, str, str, str) -> None Sends a discord alert based on info provided. ''' url = webhook embed = Webhook(url, color=123123) if (alert_type == "NEW_SHOPIFY"): desc = "NEW: " + product elif (alert_type == "RESTOCK_SHOPIFY"): desc = "RESTOCK: " + product embed.set_author( name='ARB', icon= 'https://sun9-74.userapi.com/impf/x8e2VAfW-ao86OPcoUeSKpB7sup-dlIC3bT-2g/I3Vwk9su7D8.jpg?size=564x532&quality=96&sign=423037df9ddf5c5400c93844710086c3&type=album' ) embed.set_desc(desc) for field in fields: if (alert_type == "NEW_SHOPIFY" or alert_type == "RESTOCK_SHOPIFY"): cart_link = site + "/cart/" + str(field[1]) + ":1" embed.add_field(name=str(field[0]), value=cart_link) if (image is not None): embed.set_thumbnail(image) embed.set_image(image) embed.set_footer( text='ARB by @JaqueFresco', icon= 'https://sun9-11.userapi.com/impf/DagUwT61wIcd0BeLtPOI3UFtf2nV2ZK9Gh-8NQ/ehNPfNbLWGA.jpg?size=754x750&quality=96&sign=ce4bfc72ef8fdcfbbf3c11dbd8589382&type=album', ts=True) embed.post()
def send_embed(alert_type, product): ''' (str, str, list, str, str, str) -> None Sends a discord alert based on info provided. ''' # Set webhook url = discord_webhook # Create embed to send to webhook embed = Webhook(url, color=123123) # Set author info embed.set_author( name='NERYS', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg') # Set product details if (alert_type == "RESTOCK"): embed.set_desc("RESTOCK: " + product.title) elif (alert_type == "NEW"): embed.set_desc("NEW: " + product.title) embed.add_field(name="Product", value=product.title) embed.add_field(name="Link", value=product.link) embed.add_field(name="Stock", value=str(product.stock)) # Set product image embed.set_thumbnail(product.image) embed.set_image(product.image) # Set footer embed.set_footer( text='NERYS by @snivynGOD', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg', ts=True) # Send Discord alert embed.post()
extract_products(url, 'products.csv', collections) copyfile("products.csv", "old_prodcuts.csv") last = "" while True: print("scraping!") extract_products(url, 'products.csv', collections) with open('old_prodcuts.csv', 'r') as t1, open('products.csv', 'r') as t2: fileone = t1.readlines() filetwo = t2.readlines() for line in filetwo: if line not in fileone: item = line.split(",") if last != item[0]: message = ("Item: " + item[0] + "\nLink: " + item[1]) embed = Webhook(DISCORD_HOOK, color=123123) embed.set_desc(message) embed.set_thumbnail(item[2]) embed.post() copyfile("products.csv", "old_prodcuts.csv") last = item[0] time.sleep(15)
#Creating a URL straight to the beatmap MapLink = "https://osu.ppy.sh/beatmapsets/{}".format(MapID) #------------------Printing the values to check it works--------------------------- print('New {} map by {}'.format(GMFormat, Mapper)) print('{}'.format(EmbedTitle)) print("""**BPM:** {} **Song Length:** {} **Containing:** {} """.format(BPM, Length, GMFormat2)) #------------------Programming and sending the embed itself------------------ embed = Webhook(webhook, color=0xFFB6C1) embed.set_author(name='New {} map by {}'.format(GMFormat, Mapper), icon='https://a.ppy.sh/{}'.format(MapperID), url='https://osu.ppy.sh/users/{}'.format(MapperID)) embed.set_title(title='**__{}__**'.format(EmbedTitle), url=MapLink) embed.set_thumbnail(Banner) embed.set_desc("""**BPM:** {} **Song Length:** {} **Containing:** {} """.format(BPM, Length, GMFormat2)) embed.set_footer(text='Ranked!', ts=True, icon='https://hypercyte.s-ul.eu/W4GBjy0M') embed.post()
class cRaidclear(): def __init__(self, date=datetime.datetime.now().strftime("%d/%m/%Y")): self.bosses = {} self.date = date self.placeholder_icon = "<:FeelsDeadMan:446396105077424138>" self.iconmap = {"Vale Guardian": "<:vale_guardian:449838205701718016>", "Gorseval": "<:gorseval:449838206179868672>", "Sabetha": "<:sabetha:449838205118971909>", "Slothasor": "<:sloth:449838206045913098>", "Matthias": "<:matthias:449838206054170645>", "Keep Construct": "<:keep_construct:449838205731340290>", "Xera": "<:xera:449838206100176896>", "Cairn": "<:cairn:449838199523639307>", "Mursaat Overseer": "<:mursaat_overseer:449838206310023168>", "Samarog":"<:samarog:449838206205296650>", "Deimos": "<:deimos:449838200295391232> ", "Soulless Horror": "<:soulless_horror:449838201943621632>", "Dhuum":"<:dhuum:449838200999903232>"} self.iconmap2 = {"Vale Guardian": "<:vale_guardian:449831911993507850>", "Gorseval": "<:gorseval:449831912190771210>", "Sabetha": "<:sabetha:449831912006221824>", "Slothasor": "<:sloth:449831912064679946>", "Matthias": "<:matthias:449831912177926144>", "Keep Construct": "<:keep_construct:449831911674740737>", "Xera": "<:xera:449831911754432513>", "Cairn": "<:cairn:449831905186283551>", "Mursaat Overseer": "<:mursaat_overseer:449831912123400204>", "Samarog":"<:samarog:449831912526315520>", "Deimos": "<:deimos:449831906188591114>", "Soulless Horror": "<:soulless_horror:449831907509796878>", "Dhuum":"<:dhuum:449831907530899476>"} #{"hook_url1":} self.hook_url1 = "" #this is the testserver self.hook_url2 = "" # this is the dps report channel self.hook_url = self.hook_url2 self.embed = Webhook(self.hook_url, color=0x483768) self.embed.set_desc("__***[Meta] Raid Run on "+self.date+"***__") self.embed.set_thumbnail("https://wiki.guildwars2.com/images/9/9d/Epidemic.png") self.embed.set_footer(text="Participants: Some people", ts=False) def set_bosses(self, bosses): """bosses is a dict that containts the bosses + links """ self.bosses = bosses def add_bossfields(self): for key in self.bosses.keys(): self.embed.add_field(name=self.iconmap.get(key, self.placeholder_icon)+key, value="[dps.report]("+self.bosses[key]+" \""+self.bosses[key]+"\")") def post_to_discord(self): #self.embed.set_desc("I am a descriptive description describing in a descriptive way.") self.embed.set_author(name="Chrononono") self.embed.post() def test_message(self): test_message = self.embed test_message.add_field(name="This is a test!", value="Nothing to see here") test_message.set_desc("A very inconspicuous message") test_message.set_author(name="Rogue AI") test_message.set_footer(text="This is the last test, I promise!", ts=False) test_message.post()
def main(): print("Script version ", VERSION, " started. The time is " + str(datetime.datetime.now())) successful_iterations = 0 articles = 0 iterations = 0 failures = 0 while (True): try: #Setup print("\nIteration: ", iterations) print("Iterations since last failure: ", successful_iterations) print("Total failures: ", failures) print("Articles posted since load: ", articles) print("") url = "https://www.minecraftforum.net" page = request.urlopen(url) soup = BeautifulSoup(page, 'html.parser') #description description_list = [] for cup in soup.find_all('div', {'class': 'post-excerpt-description'}): description_list.append(cup.text.replace("\n", "")) #url url_list = [] for cup in soup.find_all('h2', {'class': 'post-excerpt-title'}): url_list.append(cup.find('a')['href']) #image image_list = [] for cup in soup.find_all('a', {'class': 'post-excerpt-link'}): image_list.append(cup.find('img')['src']) #title title_list = [] for cup in soup.find_all('h2', {'class': 'post-excerpt-title'}): title_list.append(cup.text.replace("\n", "")) description_list.reverse() url_list.reverse() image_list.reverse() title_list.reverse() #Handle file interactions file = open(BLACKLIST_LOCATION, "r") saved_url_list = file.read() file.close() for i in range(len(url_list)): url = url_list[i] image = image_list[i] title = title_list[i].lstrip() description = description_list[i].lstrip() if url not in saved_url_list: print("New article found!") #Writing to file titles = open(BLACKLIST_LOCATION, "a") titles.write(url + "\n") titles.close() for webhook_url in WEBHOOK_URL_LIST: print("Trying: ", webhook_url) embed = Webhook(webhook_url, color=0xff0000) embed.set_author(name=title) embed.set_desc(description) embed.set_thumbnail(image) embed.add_field(name='Link:', value='[' + title + '](' + url + ')') embed.set_footer(ts=True) print("Before post") embed.post() print("After post") time.sleep(1) articles += 1 successful_iterations += 1 time.sleep(300) except Exception as e: successful_iterations = 0 failers += 1 print("Exception! Retrying in in 10 minutes...") print(e) time.sleep(600) iterations += 1
from discord_hooks import Webhook WEBHOOK_URL = 'ADD YOUR WEBHOOK URL HERE' embed = Webhook( url=WEBHOOK_URL, username='******', # Username of the 'bot' color=123123, # Colour of the side of the embed ) embed.set_author(name='Author Goes Here', icon='https://i.imgur.com/rdm3W9t.png', url='https://discordapp.com/') embed.set_title(title='title ~~(did you know you can have markdown here too?)~~', url='https://discordapp.com/') embed.set_desc("this description supports [named links](https://discordapp.com) as well. ```\nyes, even code blocks```") embed.add_field(name="Field 1 \U0001f603", value="some of these properties have certain limits...",inline=False) embed.add_field(name="Field 2 😱", value="try exceeding some of them!",inline=False) embed.add_field(name="Field 3 🙄", value="Jokes, dont do that.",inline=False) embed.add_field(name="Field 4 🙄", value="these last two") embed.add_field(name="Field 5 🙄", value="are inline fields") # Set the timestamp to either a ISO 8601 timestamp, or simply use `now=True`, which uses current time embed.set_timestamp(time='2018-04-30T05:34:26-07:00') embed.set_thumbnail('https://cdn.discordapp.com/embed/avatars/0.png') embed.set_image('https://cdn.discordapp.com/embed/avatars/0.png') embed.set_footer(text='Time Stamp is here =>',ts=True,icon='https://cdn.discordapp.com/embed/avatars/0.png') embed.post()
nextPreStartDt = utcNextPreStart.astimezone(to_zone) nextPreStartTime = nextPreStartDt.strftime("%m/%d %I:%M:%S %p %Z") if goatData["product"]["name"] == productName: print( "({}) No new product detected. No action taken (Check OOS? = {})". format(logTime, lookForSoldOut)) else: print("({}) New product detected. Sending webhooks (Check OOS? = {})". format(logTime, lookForSoldOut)) productName = goatData["product"]["name"] lookForSoldOut = True for webhook in webhookUrls: embed = Webhook(webhook, color=123123) embed.set_author(name='Goat Surprise Monitor', icon="https://i.imgur.com/GIOTCug.jpg") embed.set_thumbnail(url=goatData["product"]["pictureUrl"]) embed.set_title(title=goatData["product"]["name"], url=productUrl) embed.set_desc( "The next drop usually occurs **10 minutes** after `Next Pre Start Time`.\nNext product is announced at `Next Pre Start Time`.\nClick [this]({}) to access product from website, (**Disclaimer:** Will not work on apparel)." .format(productUrl)) embed.add_field(name='Price', value="`${:,.2f}`".format( goatData["product"]["priceCents"] / 100)) embed.add_field(name='Pre Start Time', value="`{}`".format(preStartTime)) embed.add_field(name='Start Time', value="`{}`".format(startTime)) embed.add_field(name='End Time', value="`{}`".format(endTime)) embed.add_field(name='Next Pre Start Time', value="`{}`".format(nextPreStartTime)) embed.post() if lookForSoldOut == True:
def runTestsAndUploadResultsToDb(gameReturn, EditorReturn): functionDict = {} if (not gameReturn and not EditorReturn): try: with open( "C:\\Program Files (x86)\\Jenkins\\workspace\\SSP\\thomas\\CompiledGame\\Bin\\data.json", "r") as ins: data = json.load(ins) function_data = {} for processor_id in data["SlowfilerData"]["processor"]: for function in data["SlowfilerData"]["processor"][ processor_id]["functions"]: rawData = [ int(s) for s in data["SlowfilerData"]["processor"] [processor_id]["functions"][function].split(',') ] rawData = [x / 1000000.0 for x in rawData ] # Gives an array of all samples function_data[function] = {} function_data[function]["avg"] = sum(rawData) / len( rawData) try: function_data[function]["std"] = statistics.stdev( rawData) except statistics.StatisticsError: print( "Only one entry for {}, cannot calculate varience". format(function)) function_data[function]["std"] = 0 function_data[function]["max"] = max(rawData) function_data[function]["min"] = min(rawData) array = np.array(rawData) function_data[function]["97th"] = np.percentile(array, 97) # parse all fps samples from json object fps_samples_cpu = [ x / 1000000 for x in data["SlowfilerData"]["build"]["fps"][::10] ] fps_samples_gpu = [ x / 1000000 for x in data["SlowfilerData"]["gpu"][::10] ] # fetch all jenkins data # We are going to assume that we have the data of the latest job j = jenkins.Jenkins("http://192.168.1.141:8080", "admin", "jenkinsjenkar") job = j.get_job_info("SSP") # All info from job SSP build_number = job["lastBuild"]["number"] # build_duration = j.get_build_info( "SSP", job["lastBuild"]["number"])[ "duration"] # Fetch duration of latest build # Connect to database sqlite_file = 'C:\\test.db' conn = sqlite3.connect(sqlite_file) c = conn.cursor() for sample in fps_samples_cpu: # For every function, send data to database try: table_name = 'Build_fps_gpu' column_sample = 'sample' column_build = 'build' c.execute("INSERT INTO {tn} ({cs}, {cb}) VALUES ({vs}, {vb})".\ format(tn=table_name, cs=column_sample, cb=column_build, vs=sample, vb=build_number)) except sqlite3.IntegrityError: print('ERROR: ID already exists in PRIMARY KEY column {}'. format(id_column)) for sample in fps_samples_gpu: # For every function, send data to database try: table_name = 'Build_fps_cpu' column_sample = 'sample' column_build = 'build' c.execute("INSERT INTO {tn} ({cs}, {cb}) VALUES ({vs}, {vb})".\ format(tn=table_name, cs=column_sample, cb=column_build, vs=sample, vb=build_number)) except sqlite3.IntegrityError: print('ERROR: ID already exists in PRIMARY KEY column {}'. format(id_column)) for function in function_data: # For every function, send data to database try: table_name = 'Function_build' column_name = 'function_name' column_avg = 'avg' column_std = 'std' column_max = 'max' column_min = 'min' column_build = 'build' column_97th = 'p97th' sample = function_data[function] c.execute("INSERT INTO {tn} ({cn}, {ca}, {cs}, {cm}, {cnv}, {cb}, {c97}) VALUES (\"{vn}\", {va}, {vs}, {vm}, {vnv}, {vb}, {v97})".\ format(tn=table_name, cn=column_name, ca=column_avg, cs=column_std, cm=column_max, cnv=column_min, cb=column_build, c97=column_97th, vn=function, va=(sample["avg"]), vs=sample["std"], vm=sample["max"], vnv=sample["min"], vb=build_number, v97=sample["97th"])) except sqlite3.IntegrityError: print('ERROR: ID already exists in PRIMARY KEY column {}'. format(id_column)) try: table_name = 'Build_data' column_number = "build_number" column_duration = "build_time_duration" column_ramusage = "build_ramusage" column_vramuasge = "build_vramusage" column_avgfps = "build_avgfps" column_minfps = "build_minfps" column_stdfps = "build_stdfps" c.execute("INSERT INTO {tn} ({cn}, {cd}, {cr}, {cv}, {cavgfps}, {cminfps}, {cstdfps}) VALUES ({vn}, {vd}, {vr}, {vv}, {vavgfps}, {vminfps}, {vstdfps})".\ format(tn=table_name, cn=column_number, cd=column_duration, cr=column_ramusage, cv=column_vramuasge, cavgfps=column_avgfps, cminfps=column_minfps, cstdfps=column_stdfps, vn=build_number, vd=build_duration, vr=data["SlowfilerData"]["build"]["ramUsage"], vv=data["SlowfilerData"]["build"]["vramUsage"], vavgfps=sum(fps_samples_cpu) / len(fps_samples_cpu), vminfps=min(fps_samples_cpu), vstdfps=statistics.stdev(fps_samples_cpu))) except sqlite3.IntegrityError: print( 'ERROR: ID already exists in PRIMARY KEY column {}'.format( id_column)) # Close connection conn.commit() conn.close() embed = Webhook(url, color=428644) ram_usage = data["SlowfilerData"]["build"]["ramUsage"] vram_usage = data["SlowfilerData"]["build"]["vramUsage"] avg_fps = sum(fps_samples_cpu) / len(fps_samples_cpu) embed.set_author(name='Slowfiler', icon='https://i.imgur.com/rdm3W9t.png') embed.set_desc( 'New preformance report available at http://192.168.1.141:8069/builds/ ' ) embed.add_field(name='Average frametime:', value="{} ms".format(avg_fps)) embed.add_field(name='RAM USAGE:', value="{} mb".format(ram_usage - vram_usage)) embed.add_field(name='VRAM USAGE:', value="{} mb".format(vram_usage)) if (ram_usage - vram_usage) < 256 and vram_usage < 512 and avg_fps < 32: embed.add_field(name='STATUS:', value="PASS") else: embed.add_field(name='STATUS:', value="FAIL") embed.set_thumbnail( 'https://t4.rbxcdn.com/fee318796364847e0ff53ea658490477') embed.set_footer(text='Slowfiler, copyright 3-D asset', ts=True) embed.post() return 0 except IOError: print("Could not open file") return -1 else: embed = Webhook(url, color=428644) embed.set_author(name='Slowfiler', icon='https://i.imgur.com/rdm3W9t.png') embed.set_desc('Could not run game or editor ') if (not gameReturn): embed.add_field(name='GAME STATUS:', value="FAIL") if (not EditorReturn): embed.add_field(name='EDITOR STATUS:', value="FAIL") embed.set_thumbnail( 'https://t4.rbxcdn.com/fee318796364847e0ff53ea658490477') embed.set_footer(text='Slowfiler, copyright 3-D asset', ts=True) embed.post() return -1
async def on_message(message): prefix = config['prefix'] if message.author == client.user: return if message.content.startswith(prefix + 'ping'): await client.send_message(message.channel, "Pong") if message.content.startswith(prefix + 'CreateATC'): if len(message.content.split(" ")) != 3: await client.send_message(message.channel, "Invalid number of arguments") else: site = message.content.split(" ")[1] variant = message.content.split(" ")[2] atclink = "{}/cart/{}:1".format(site, variant) await client.send_message(message.channel, atclink) if message.content.startswith(prefix + 'Choose'): if len(message.content.split(" ")) != 2: await client.send_message(message.channel, "Invalid Number Of Arguments") else: options = message.content.split(" ")[1] opl = [] optionsl = options.split(",") for op in optionsl: opl.append(op) opnum = randint(0, len(opl) - 1) option = opl[opnum] await client.send_message(message.channel, "I Choose {}".format(option)) if message.content.startswith(prefix + 'ATC'): try: if len(message.content.split(" ")) != 2: await client.send_message(message.channel, "Invalid Number Of Arguments") else: produrl = message.content.split(" ")[1] s = requests.session() prodobjr = s.get(produrl) prodobj = prodobjr.text.split("var meta = ")[1] prodobj = prodobj.split(";")[0] prodobj = json.loads(prodobj) soup = bs(prodobjr.text, "html.parser") actionheaders = { 'Authorization': 'Bot {}'.format(token), 'User-Agent': 'XO Discord Bot (https://xobots.io, v0.1)', 'Content-Type': 'application/json' } actionlink = "https://discordapp.com/api/channels/{}/webhooks".format( message.channel.id) actiondata = { "name": "CopSiteList", } createwh = s.post(actionlink, headers=actionheaders, data=json.dumps(actiondata)) webhookObject = json.loads(createwh.text) whid = webhookObject['id'] whtoken = webhookObject['token'] webhookurl = "https://discordapp.com/api/webhooks/{}/{}".format( whid, whtoken) colornum = randint(0, len(colorArray) - 1) color = colorArray[colornum] embed = Webhook(webhookurl, color=color) embed.set_author(name='XO Discord Bot | BY XO') embed.set_footer( text= 'Discord Bot By XO Dev | Twitter @ehxohd | Discord XO#0001', ts=True) prodsiteLink = produrl.split("/")[2] prodsiteLink = "https://{}".format(prodsiteLink) for pid in prodobj['product']['variants']: embed.add_field(name=str(pid['public_title']), value="{}/cart/{}:1".format( prodsiteLink, pid['id'])) embed.post() actionurl = "https://discordapp.com/api/webhooks/{}".format( whid) s.delete(actionurl, headers=actionheaders) except: await client.send_message(message.channel, "Error Executing Scraper") if message.content.startswith(prefix + "Creator"): s = requests.session() colorNum = randint(0, len(colorArray) - 1) color = colorArray[colorNum] actionheaders = { 'Authorization': 'Bot {}'.format(token), 'User-Agent': 'XO Discord Bot (https://xobots.io, v0.1)', 'Content-Type': 'application/json' } actionlink = "https://discordapp.com/api/channels/{}/webhooks".format( message.channel.id) actiondata = { "name": "CopSiteList", } createwh = s.post(actionlink, headers=actionheaders, data=json.dumps(actiondata)) webhookObject = json.loads(createwh.text) whid = webhookObject['id'] whtoken = webhookObject['token'] webhookurl = "https://discordapp.com/api/webhooks/{}/{}".format( whid, whtoken) embed = Webhook(webhookurl, color=color) embed.set_author(name='OX Discord Bot') embed.set_desc( 'This Is A Discord Bot Focused Around Sneakers Made By XO') embed.add_field(name="XO's Github URL", value='https://github.com/TCWTEAM') embed.add_field(name="This Projects Github Repo", value='https://github.com/TCWTEAM/OX-Discord-Bot') embed.set_thumbnail( 'https://i.gyazo.com/b6c555781abae4b1c6719242589c7f50.png') embed.add_field(name="XO's Twitter", value='https://twitter.com/ehxohd') embed.add_field(name="Want To Buy Me Lunch?", value="https://www.paypal.me/EHXOH") embed.set_footer(text='XO Discord Bot | 2018', ts=True) embed.post() actionurl = "https://discordapp.com/api/webhooks/{}".format(whid) s.delete(actionurl, headers=actionheaders) if message.content.startswith(prefix + "IsShopify"): if len(message.content.split(" ")) != 2: await client.send_message(message.channel, "Invalid Number Of Arguemts") elif "http" not in message.content.split(" ")[1]: await client.send_message(message.channel, "Invalid Url") else: try: s = requests.session() headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36' } sitesource = s.get(message.content.split(" ")[1], headers=headers, timeout=15) if "Shopify" not in sitesource.text: await client.send_message( message.channel, "{} Is Not Shopify".format( message.content.split(" ")[1])) else: await client.send_message( message.channel, "{} IS PROBABLY SHOPIFY".format( message.content.split(" ")[1])) except: await client.send_message( message.channel, "Error Checking Site, Probably Rejected The Request") if message.content.startswith(prefix + "getproducts"): if len(message.content.split(" ")) < 2: await client.send_message(message.author, "Invalid Number Of Arguments") elif "http" not in message.content.split(" ")[1]: await client.send_message(message.author, "The URL You Gave Isnt Valid") else: url = message.content.split(" ")[1] s = requests.session() pagesource = s.get(url, headers=globalHeaders, timeout=20) if "shopify" not in pagesource.text.lower(): await client.send_message( message.author, "The Site Requested Doesnt Seem To Be Shopify") else: testUrlr = s.get(url + "products.json", headers=globalHeaders, timeout=30) testUrlInfo = testUrlr.text productObject = json.loads(testUrlInfo) savefilenum = str(randint(111, 333)) fnamee = "{}_{}.txt".format( url.split("://")[1].split(".")[0], savefilenum) f = open(fnamee, "w+") f.close() f = open(fnamee, "a+") f.write("SCRAPED BY XOS DISCORD BOT\n") f.write( "Twitter: @ehxohd | Discord: XO#0001 | Paypal: https://paypal.me/ehxoh\n" ) f.write("=========================================\n") f.write("Info: \nSite Url:{}\nProduct Object URL:{}\n".format( url, url + "products.json")) f.write("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n") sitebaseurl = url.split("/")[2] for product in productObject['products']: f.write("=====================\n") name = product['title'] f.write("Product Name: {}\n".format(name)) f.write("Sizes And ATCS:\n") for variant in product['variants']: f.write("----------------\n") variantid = variant['id'] varname = variant['title'].replace("\/", "") atclink = "{}/cart/{}:1".format(sitebaseurl, variantid) f.write("VariantID: {}\n".format(variantid)) f.write("Size/Style: {}\n".format(varname)) f.write("ATC Link: {}\n".format(atclink)) f.write("----------------\n") f.write("=====================\n") f.write("END OF FILE\n") f.close() fc = open(fnamee, "r") fcc = fc.read() fc.close() textURL = hastebin.post(fcc) await client.send_message( message.author, "I Finished Scraping Your Sites. Heres What I Got\n{}".format( textURL)) os.remove(fnamee) if message.content.startswith(prefix + "help"): helpf = open("helpMessage.xo", "r") helpMessage = helpf.read() helpf.close() await client.send_message( message.author, "Hi Heres Some Help\nPrefix:{} (Goes Before All Commands){}". format(prefix, helpMessage)) await client.send_message( message.channel, "@{} I Sent Help To Your DM's".format(message.author)) if message.content.startswith(prefix + "randomquote"): lines = open('quotes.xo', encoding="utf8").read().splitlines() myline = random.choice(lines) await client.send_message(message.channel, myline) if message.content.startswith(prefix + "online?"): if len(message.content.split(" ")) != 2: await client.send_message(message.channel, "Invalid Amount Of Arguments") elif "http" not in message.content.split(" ")[1]: await client.send_message(message.channel, "Invalid Url") else: try: r = requests.get(message.content.split(" ")[1], timeout=30) if str(r.status_code).startswith("20"): await client.send_message( message.channel, "{} Is Online".format(message.content.split(" ")[1])) else: await client.send_message( message.channel, "{} Is Offline Or Not Found".format( message.content.split(" ")[1])) except: await client.send_message( message.channel, "{} Is Offline Or Not Found".format( message.content.split(" ")[1])) if message.content.startswith(prefix + "SupremeWeek"): pageSource = requests.get( "https://www.supremecommunity.com/season/spring-summer2018/droplists/" ) pageSource = pageSource.content soup = bs(pageSource, "html.parser") links = soup.find_all('a', {'class': 'block'})[0] link = "https://www.supremecommunity.com" + str(links).split( 'href="')[1].split('">')[0] await client.send_message( message.channel, "Hey My Supreme Features Arent Finished But I Found The Link Of The Latest Stuff {}" .format(link)) if message.content.startswith(prefix + "SupremeProducts"): url = "http://www.supremenewyork.com/mobile_stock.json" s = requests.session() supremeStock = s.get(url) print(supremeStock.text) so = supremeStock.text.encode('UTF-8') supremeObject = json.loads(so) fnameu = "supreme_{}.txt".format(str(randint(111, 999))) f = open(fnameu, "w+") f.close() f = open(fnameu, "a+") f.write("SUPREME PRODUCT SCRAPER\n") f.write("OX Discord Bot BY XO\n") f.write( "Github https://github.com/TCWTEAM/OX-Discord-Bot | Twitter: @ehxohd\n" ) f.write( "=-=-=-=--=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=--=\n" ) f.write("Release Date: {} | Release Week: {}\n".format( supremeObject['release_date'], supremeObject['release_week'])) f.write("\n") f.write("\n") f.write("==================\n") f.write("[Bags]\n") for item in supremeObject['products_and_categories']['Bags']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[Accessories]\n") for item in supremeObject['products_and_categories']['Accessories']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[Skate]\n") for item in supremeObject['products_and_categories']['Skate']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[Shirts]\n") for item in supremeObject['products_and_categories']['Shirts']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[Pants]\n") for item in supremeObject['products_and_categories']['Pants']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[Jackets]\n") for item in supremeObject['products_and_categories']['Jackets']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[Shorts]\n") for item in supremeObject['products_and_categories']['Shorts']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[Sweatshirts]\n") for item in supremeObject['products_and_categories']['Sweatshirts']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[Tops/Sweaters]\n") for item in supremeObject['products_and_categories']['Tops/Sweaters']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[Hats]\n") for item in supremeObject['products_and_categories']['Hats']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.write("\n") f.write("[new]\n") for item in supremeObject['products_and_categories']['new']: name = item['name'] id = item['id'] imageURL = item['image_url_hi'].split("//")[1] price = "${}".format(int(item['price']) / 100) f.write("------------\n") f.write("Name: {}\n".format(name)) f.write("PID: {}\n".format(id)) f.write("Price: {}\n".format(price)) f.write("Image URL: http://{}\n".format(imageURL)) f.write("-------------\n") f.close() f = open(fnameu, "r") uploadURL = hastebin.post(f.read()) f.close() await client.send_message( message.channel, "I Finished Looking At Supreme. This Season Sucks But Here Are The Products On The Site {}" .format(uploadURL))