def callback(update): if type(update) is UpdateNewChannelMessage: try: logger.debug(update) if update.message.to_id.channel_id == channel_id: logger.info("Relaying Message from Channel ID: {}".format( update.message.to_id.channel_id)) if update.message.id > lastmessage: lastmessage = update.message.id logger.debug("Last message is now " + str(lastmessage)) if not update.message.message == '': if everyone: msgText = "*{}*: @everyone {}".format( channel_name, update.message.message) else: msgText = "*{}*: {}".format(channel_name, update.message.message) msg = Webhook(url, msg=msgText) msg.post() else: logger.debug('ignoring empty message: {}'.format( update.message)) else: logger.info("Ignoring Message from Channel ID: {}".format( update.message.to_id.channel_id)) except: logger.debug('no message')
def start_bot(): degree_sign = u'\N{DEGREE SIGN}' url = 'https://discordapp.com/api/webhooks/123453/12345654' link = "http://192.xxx.x.xxx:42000/getstat" r = requests.get(url=link) data = json.loads(r.text) uptime = str(datetime.datetime.now() - datetime.datetime.fromtimestamp(int(data['start_time'])))[:-7] gpuTxt = "" totalSpeed = 0 totalWatt = 0 for gpu in data['result']: gpuTxt += "\t{} : {}{}C {}W {}Sol/s\n".format( str(gpu['gpuid']), str(gpu['temperature']), degree_sign, str(gpu['gpu_power_usage']), str(gpu['speed_sps'])) totalSpeed += gpu['gpu_power_usage'] totalWatt += gpu['speed_sps'] if gpu['temperature'] >= 90: tempCheck(gpu['temperature']) msgTxt = "```css\n{}Sol/s {}W\n--------------\nServer: {}\nUptime: {}\nGPU's:\n{}\n```".format( str(totalWatt), str(totalSpeed), data['current_server'], str(uptime), gpuTxt) msg = Webhook(url, msg=msgTxt) msg.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 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, 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 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 write2file(self, text): if self.webhookurl: msg = Webhook(self.webhookurl, msg=str(text)) msg.post() with self.lock: with open(self.filename, 'a') as file: file.write(text)
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 error_hooking(base, type): url = "<WEBHOOK>" embed = Webhook(url, color=123123) embed.set_desc(type.strip(':')) embed.add_field(name="Link", value=base) embed.add_field(name="Error", value="Can't get this product. Please contact with developer") embed.set_footer(text='Powered by <COMPANY NAME>', ts=True,icon='<ICON>') embed.post()
def post_to_webhook(self, slug): post = self.get_post_from_server(slug) msg_string = (post['body'][:250] + '...') if len(post['body']) > 250 else post['body'] embed = Webhook(HOOK_URL, color=123123) embed.set_author(name=post['title'], icon='https://cdn6.aptoide.com/imgs/5/1/f/51fc6f8666c50ce7456651810d7a4439_icon.png?w=240') embed.set_desc(msg_string) embed.add_field(name='Read more', value=post['url']) embed.post()
def post_to_discord(event, webhook): msg_text = event.text # event.raw_text url_reg = r'(https?[:.]+[^\s\)]+)' msg_text = re.sub(url_reg, r'<\1>', msg_text) msg = Webhook(webhook, msg=msg_text) msg.post() #print(event.input_sender, event.document, event.text) logger.info('Delivered to webhook %s' % (webhook))
def check_system(name): reports = [] system_report = [] edsm_id = solar_system.get_by_name(name) system = solar_system.get(edsm_id) if system is None: return None factions = solar_system.get_factions(edsm_id) add_report = False for this_faction in factions: local_faction = faction.get(this_faction[1]) if local_faction[1] not in records[name].keys(): records[name][local_faction[1]] = this_faction[2] prev = records[name][local_faction[1]] current = this_faction[2] if prev is not None: # Status change. if prev < current: move = 'increased' direction = ':arrow_up_small:' else: move = 'decreased' direction = ':small_red_triangle_down:' # Is this our faction? if settings.owners[name] == local_faction[1]: home_faction = ':EliteSmile:' else: home_faction = '' prev_percent = '{:.1%}'.format(float(prev)) current_percent = '{:.1%}'.format(float(current)) if prev != current: # System we are looking at. current_system = solar_system.get(edsm_id) system_name = current_system[1] records[name][local_faction[1]] = this_faction[2] add_report = True if settings.owners[name] == local_faction[1]: system_report.insert( 0, '**' + local_faction[1] + '** influence in __' + system_name + '__ has ' + move + ' from ' + prev_percent + ' to ' + current_percent) faction_percent = '{:.1%}'.format(float(this_faction[2])) system_report.append("* " + local_faction[1] + home_faction + " (" + this_faction[3] + ") : " + faction_percent + direction) if add_report: reports.append("\n".join(system_report)) description = '' system_report = [] if len(reports) > 0: post = Webhook(settings.webhook_url_system_monitor, msg="\n\n".join(reports)) post.post() print "\n\n".join(reports) print "\n\n" reports = []
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 check_faction(name): reports = [] minor_faction_id = faction.get_by_name(name) system_ids = faction.get_systems(minor_faction_id) for edsm_id in system_ids: system_report = [] system = solar_system.get(edsm_id) if system[1] not in records[name].keys(): system_report.append('**' + name + '**d influence in ' + system[1] + ' has changed.') records[name][system[1]] = {} factions = solar_system.get_factions(edsm_id) add_report = False for this_faction in factions: local_faction = faction.get(this_faction[1]) if local_faction[1] not in records[name][system[1]].keys(): records[name][system[1]][local_faction[1]] = this_faction[2] prev = records[name][system[1]][local_faction[1]] current = this_faction[2] # Status change. if prev < current: move = 'increased' direction = ':arrow_up_small:' else: move = 'decreased' direction = ':small_red_triangle_down:' prev_percent = '{:.1%}'.format(float(prev)) current_percent = '{:.1%}'.format(float(current)) if name == local_faction[1] and prev != current: # System we are looking at. current_system = solar_system.get(edsm_id) system_name = current_system[1] system_report.insert(0, '**' + local_faction[1] + '** influence in __' + system_name + '__ has ' + move + ' from ' + prev_percent + ' to ' + current_percent) records[name][system[1]][local_faction[1]] = this_faction[2] add_report = True faction_percent = '{:.1%}'.format(float(this_faction[2])) system_report.append("* " + local_faction[1] + " (" + this_faction[3] + ") : " + faction_percent + direction) if add_report: reports.append("\n".join(system_report)) description = '' system_report = [] if len(reports) > 0: post = Webhook(settings.webhook_url,msg="\n\n".join(reports)) post.post() print "\n\n".join(reports) print "\n\n" reports = []
def push_data_to_discord_webhook(data, webhookid, webhookkey): """[summary] Pushes data to discord web-hook Arguments: data {[dictionary]} -- [data] webhookid {[string]} -- [webhook id] webhookkey {[string]} -- [key] """ if data != None: url = 'https://discordapp.com/api/webhooks/{}/{}'.format( webhookid, webhookkey) content = "Price {} \nLast Update {} \nChange {}".format( data['price'], data['lastupdate'], data['change']) msg = Webhook(url, msg=content) msg.add_field(name="Field", value='Test Text') msg.post()
async def handler(update): #prints peer ids of channels result = await client.get_dialogs() print("\n List of channels:") for p in result: print(str(utils.resolve_id(p.id)[0]) + ": " + p.name) try: if str(update.message.to_id.channel_id) in channels: m = update.message media = m.media reply_msg = await m.get_reply_message() if reply_msg is None: text = "{}\n".format(m.message) else: text = "```REPLIED_TO:\n{}```{}\n".format( reply_msg.message, m.message) if media is not None and utils.get_extension(media) == '.jpg': logger.info("Will download image") download_res = await client.download_media( media, './downloads/') logger.info("Download done: {}".format(download_res)) url = img_cli.upload_from_path(download_res, anon=True)['link'] text += url + "\n" os.remove(download_res) logger.debug("File deleted") if not text == '': date = m.date.astimezone(timezone('Asia/Ulaanbaatar')) text += "`" + date.strftime("%Y-%m-%d %H:%M:%S GMT%Z") + "`\n" text += "==================================\n" msg = Webhook(channels[str(m.to_id.channel_id)], msg=text) msg.post() logger.info("Relaying Message from Channel ID: {}".format( update.message.to_id.channel_id)) else: logger.debug('Ignoring empty message: {}'.format( update.message)) else: logger.info("Ignoring Message from Channel: {}: {}".format( update.message.to_id.channel_id, update.message.to_id.channel_name)) except: logger.debug('Exception occurred while handling:\n') logger.debug(update)
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 send_embed(product): ''' (Product) -> None Sends a discord alert based on info provided. ''' url = 'WEBHOOK HERE' embed = Webhook(url, color=42320) embed.set_author(name='MY-Monitor') embed.set_desc("Found product based on keyword " + product.keyword) embed.add_field(name="Link", value=product.link) embed.set_footer(text='by keem#0815, Notify Beta', ts=True) embed.post()
def send_embed(product): ''' (Product) -> None Sends a discord alert based on info provided. ''' url = 'INSERT YOUR WEBHOOK HERE' embed = Webhook(url, color=123123) embed.set_author(name='NERYS', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg') embed.set_desc("Found product based on keyword " + product.keyword) embed.add_field(name="Link", value=product.link) embed.set_footer(text='NERYS by @snivynGOD', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg', ts=True) embed.post()
def send_embed(product): ''' (Product) -> None Sends a discord alert based on info provided. ''' url = 'https://discordapp.com/api/webhooks/479049758254825472/kmK_bdEZ_bH_fmDoGJ_rS2AB1Xedn2CHwiviMhzGbaxZ9ES5U8nTCorV6qQnRVd12mp_' embed = Webhook(url, color=123123) embed.set_author(name='Premier Cooks', icon='https://pbs.twimg.com/profile_images/1031725580075585536/s0GlPWIB_400x400.jpg') embed.set_desc("Found product based on keyword " + product.keyword) embed.add_field(name="Link", value=product.link) embed.set_footer(text='Nike Monitor by @PremierCooks', icon='https://pbs.twimg.com/profile_images/1031725580075585536/s0GlPWIB_400x400.jpg', ts=True) embed.post()
def send_embed(product): ''' (Product) -> None Sends a discord alert based on info provided. ''' url = "https://discord.com/api/webhooks/811178312336277504/ekKQ7L_aSJSbBWRiD7xH9PrcjeibAIG6P-KhMkVCLWDggsgzRSqSljNPQKPFkFSm69Mj" embed = Webhook(url, color=123123) embed.set_author(name='NERYS', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg') embed.set_desc("Found product based on keyword " + product.keyword) embed.add_field(name="Link", value=product.link) embed.set_footer(text='NERYS by @snivynGOD', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg', ts=True) embed.post()
def send_embed(product): ''' (Product) -> None Sends a discord alert based on info provided. ''' url = 'https://discordapp.com/api/webhooks/532298624114229268/pgNC5uyKSNOzitqRbm60E7G9p-fcjzhwHsss1biNP9TuxwbqNJbdj5y9HDtISSsf4yCc' embed = Webhook(url, color=123123) embed.set_author(name='NERYS', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg') embed.set_desc("Found product based on keyword " + product.keyword) embed.add_field(name="Link", value=product.link) embed.set_footer(text='NERYS by @snivynGOD', icon='https://static.zerochan.net/Daenerys.Targaryen.full.2190849.jpg', ts=True) embed.post()
def main(argv): global changelist_icon webhook_url = P4_COMMITS_WEBHOOK_URL change = -1 discord_userid = '-1' # Retrieve input arguments try: opts, args = getopt.getopt(argv, "tc:") except getopt.GetoptError: print( "Invalid arguments! -c ChangeNumber -t (to use TEST_WEBHOOK_URL)") sys.exit(2) for opt, arg in opts: if opt == '-c': change = arg if opt == '-t': webhook_url = TEST_WEBHOOK_URL # If no change was given, simply exit if change == -1: print("No change number supplied!") sys.exit(3) # Function will get description and user info about this change and store in a dictionary change_data = get_change_data(change, P4PORT, P4LOGIN, P4PASS) # Match Perforce user from perforce change info to actual Discord user using pre-set dictionaries discord_userid = discord_userids[change_data["user"]] discord_username = discord_usernames[change_data['user']] # Set up and send the embed embed_title = u'Change %s \u2022 %s (%s) \u2022 %s' % ( change, change_data['user'], discord_username, change_data['client']) embed_description = '%s' % (change_data['desc']) message = Webhook(webhook_url, color=0x10b1df) message.set_author( name=embed_title, icon=changelist_icon ) # Author field is used for smaller/more compact font and inline icon message.set_desc(embed_description) message.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 = webhook_url #url = 'https://discordapp.com/api/webhooks/481411222118465550/8TanFM9unt2Ztf_ySUGlus9MNw9DVDaTKNXAQZpMYvtnoucHevzCYn0gjwV_ZpQmKsTQ' # Create embed to send to webhook 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) 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('https://cache.mrporter.com/images/products/1054353/1054353_mrp_fr_l.jpg') #embed.set_image(product.link) # 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 Run(): time.sleep(5) print('偵測') artdata = np.load('artdata.npy').item() for lists in data['Item']: for user in lists['Users']: try: arts = pixiv.user(user).works() Userinfo = pixiv.user(user).User() except Exception as e: loginPixiv() continue for art in arts: try: if artdata[user] == art.id: break except Exception: pass embed = Webhook(lists['WebhookURL'], color=123123) embed.set_author( name=Userinfo['name'], url='https://www.pixiv.net/member.php?id=' + user, icon=UrlReplace( Userinfo['profile_image_urls']['px_50x50'])) embed.set_image(UrlReplace(art.image)) embed.set_title(title=art.title, url=art.link) if not art.tags == None: Tag = '' for tags in art.tags: Tag = Tag + tags + '、' embed.add_field(name='標籤(Tags)', value=Tag[:-1]) Tag = '' if not art.caption == None: embed.set_desc(art.caption) embed.set_footer(text=strmd, icon="https://i.imgur.com/UNPFf1f.jpg", ts=True) embed.post() artdata[user] = arts[0].id np.save('artdata.npy', artdata)
def proccess_new_post(post): global max_post_id # check for new post if int(post['id']) <= max_post_id: return max_post_id = int(post['id']) # search for photos in attachments photos = [] for atch in post.get('attachments', []): if atch.get('type') == 'photo': photo = atch.get('photo', {}) photo_urls = [i for i in photo.keys() if i.startswith('photo_')] photo_urls.sort(key=lambda x: -int(x.split('_')[-1])) if photo_urls and photo_urls[0]: photos.append(photo[photo_urls[0]]) # generate text msg = post.get('text', '') # add all photos links from attachments. COMMENTED if False: msg += '\n' for i in photos: msg += '\n' + i # create Webhook object wh = Webhook(config['discord_webhook_url'], msg=msg) wh.set_footer(text='https://vk.com/wall-{}_{}'.format( config['vk_group_id'], post['id']), ts=time.time()) # set image if photos: wh.set_image(photos[0]) # send Webhook to discord server wh.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()