def raid_alert(self, d): legend = json.loads(open('config/raid.json').read()) rmtitle = re.sub('<MON>', d['mon_name'], legend['raid']) rlfield = legend['time'] adreu = d.get('street', '') + d.get('street_num', '') adrus = d.get('street_num', '') + d.get('street', '') address = legend.get('address', '') gyminfo = legend['gyminfo'] moves = legend['moves'] boost = legend['weather'] rmlinkfield = legend.get('RM', '') description = rlfield if d['geo_enabled']: description += address if d['iv_enabled']: description += gyminfo if d['moves_enabled']: description += moves if 'boost' in d and d['weather_enabled']: description += boost if args.mapurl: description += rmlinkfield description = re.sub('<DESPAWN>', d.get('time', ''), description) description = re.sub('<TTH>', d.get('tth', ''), description) description = re.sub('<CITY>', d.get('city', ''), description) description = re.sub('<SUB>', d.get('suburb', ''), description) description = re.sub('<STR>', d.get('street', ''), description) description = re.sub('<STR_NUM>', d.get('street_num', ''), description) description = re.sub('<ADDR_EU>', adreu, description) description = re.sub('<ADDR_US>', adrus, description) description = re.sub('<GYM>', d.get('gym_name', ''), description) description = re.sub('<INFO>', d.get('description', ''), description) description = re.sub('<MOVE1>', d.get('move1', ''), description) description = re.sub('<MOVE2>', d.get('move2', ''), description) description = re.sub('<WEA>', d.get('boost', ''), description) description = re.sub('<RM>', d.get('mapurl', ''), description) embed = MessageEmbed(color=d['color'], description=description) embed.url = (d['gmapurl']) embed.thumbnail = MessageEmbedThumbnail(url=d['img']) embed.author = MessageEmbedAuthor(icon_url=d['thumb'].lower(), name=rmtitle) embed.title = '{}'.format(d['mon_name']) embed.url = d['gmapurl'] if d['map_enabled']: embed.image = MessageEmbedImage(url=d['static']) self.channels_messages_create(d['channel'], embed=embed)
def on_songinfo(self, event, content): pad = self.pad_reader.find_pad(content) if not pad: event.msg.reply('Dude weed lmao cannot find shit') return embed = MessageEmbed() embed.title = pad.title embed.color = cfg.color embed.set_footer(text=pad.id) embed.url = pad.url if len(pad.needs) > 0: embed.add_field(name='needs', value=', '.join(str(x) for x in pad.needs), inline=True) embed.set_image( url= "https://cdn.discordapp.com/attachments/142137354084155393/437387811663118336/loadingu.gif" ) message = event.msg.reply('', embed=embed) try: text = ps.get_pad_text(self.session, pad.id) text = text[:text.find("~~~~~~~~")] img = self.t2i.create_img(wrap_lines(text), False) embed.set_image(url=img) message.edit(embed=embed) except ImageUploadError as e: logging.getLogger(self).error(e)
def on_gelbooru(self, event, tags): r = requests.get("https://gelbooru.com/index.php", params={ "page": "dapi", "s": "post", "q": "index", "tags": tags, "limit": 200, "json": 1 }) if len(r.content) > 0 and len(r.json()) > 0: n = random.randint(0, len(r.json()) - 1) embed = MessageEmbed() embed.color = cfg.color embed.title = tags embed.url = "https://gelbooru.com/index.php?page=post&s=view&id={}".format( r.json()[n]["id"]) embed.set_image(url=r.json()[n]["file_url"]) event.msg.reply("", embed=embed) else: event.msg.reply("nothing found")
def TagEmbed(tag_data, variables): embed = MessageEmbed() embed.title = tag_data["title"] embed.description = tag_data["response"].format(**variables) embed.color = tag_data["colour"] embed.set_footer(text=tag_data["footer"]) embed.url = tag_data["url"] return embed
def on_mywaifu(self, event): if event.message.content.lower( ) == "mywaifu" or event.message.content.lower() == "mywaifux": key = str(event.author.id) if key in self.waifus: count = requests.get( "https://danbooru.donmai.us/counts/posts.json", params={ "tags": self.waifus[key] + (" rating:safe" if event.message.content.lower() == "mywaifu" else ""), }) if len(count.content) > 0 and len( count.json()) > 0 and "counts" in count.json( ) and "posts" in count.json()["counts"]: count = count.json()["counts"]["posts"] r = requests.get( "https://danbooru.donmai.us/posts.json", params={ "tags": self.waifus[key] + (" rating:safe" if event.message.content.lower() == "mywaifu" else ""), "limit": 200, "random": "true" if count > 200 else "false" }) if len(r.content) > 0 and len(r.json()) > 0: if "success" in r.json() and not r.json()["success"]: event.message.reply(r.json()["message"]) return n = random.randint(0, len(r.json()) - 1) embed = MessageEmbed() embed.color = cfg.color embed.url = "https://danbooru.donmai.us/posts/{}".format( r.json()[n]["id"]) if "large_file_url" in r.json()[n]: embed.set_image(url=r.json()[n]["large_file_url"]) else: embed.set_image(url=r.json()[n]["file_url"]) embed.set_footer(text=r.json()[n]["id"]) event.message.reply('', embed=embed) else: event.message.reply("nothing found") else: event.message.reply( "waifu not set. use !setwaifu danbooru_tag")
def on_about_command(self, event): embed = MessageEmbed() embed.set_author(name='MacDeth#0420', url='https://github.com/MacDeth/discobot-py', icon_url='https://macdeth.keybase.pub/avatar.png') embed.title = 'About' embed.url = 'https://github.com/MacDeth/discobot-py' event.msg.reply(embed=embed)
def get_base_embed(result): """Creates an embed and sets some common properties.""" embed = MessageEmbed() embed.set_author( name='Yahoo! Weather', url='https://www.yahoo.com/news/weather', icon_url='https://s.yimg.com/dh/ap/default/130909/y_200_a.png') embed.url = result.print_obj['link'].split('*')[-1] # Removes RSS URL. embed.color = 4194448 # Yahoo! logo's purple. return embed
def send_post(self, config, channel, data): if config.mode is FormatMode.PLAIN: channel.send_message('**{}**\n{}'.format( data['title'], 'https://reddit.com{}'.format(data['permalink']) )) else: embed = MessageEmbed() if 'nsfw' in data and data['nsfw']: if not config.nsfw: return embed.color = 0xff6961 else: embed.color = 0xaecfc8 # Limit title to 256 characters nicely if len(data['title']) > 256: embed.title = data['title'][:253] + '...' else: embed.title = data['title'] embed.url = u'https://reddit.com{}'.format(data['permalink']) embed.set_author( name=data['author'], url=u'https://reddit.com/u/{}'.format(data['author']) ) image = None if data.get('media'): if 'oembed' in data['media']: image = data['media']['oembed']['thumbnail_url'] elif data.get('preview'): if 'images' in data['preview']: image = data['preview']['images'][0]['source']['url'] if 'selftext' in data and data['selftext']: # TODO better place for validation sz = min(64, max(config.text_length, 1900)) embed.description = data['selftext'][:sz] if len(data['selftext']) > sz: embed.description += u'...' if image: embed.set_thumbnail(url=image) elif image: embed.set_image(url=image) if config.include_stats: embed.set_footer(text=emoji.emojize('{} upvotes | {} downvotes | {} comments'.format( data['ups'], data['downs'], data['num_comments'] ))) channel.send_message('', embed=embed)
def update_hint(self, hint): HintsConsumer.send_to_all( json.dumps({ 'id': hint.id, 'content': render_to_string('hint_list_entry.html', { 'hint': hint, 'now': timezone.localtime() }) })) embed = MessageEmbed() embed.author.url = hint.full_url() if hint.claimed_datetime: embed.color = 0xdddddd embed.timestamp = hint.claimed_datetime.isoformat() embed.author.name = 'Claimed by {}'.format(hint.claimer) if hint.claimer in self.get_avatars(): embed.author.icon_url = self.get_avatars()[hint.claimer] debug = 'claimed by {}'.format(hint.claimer) else: embed.color = 0xff00ff embed.author.name = 'U N C L A I M E D' claim_url = hint.full_url(claim=True) embed.title = 'Claim: ' + claim_url embed.url = claim_url debug = 'unclaimed' if self.client is None: message = hint.long_discord_message() logger.info('Hint, {}: {}\n{}'.format(debug, hint, message)) logger.info('Embed: {}'.format(embed.to_dict())) elif hint.discord_id: try: self.client.channels_messages_modify(self.HINT_CHANNEL, hint.discord_id, embed=embed) except Exception: dispatch_general_alert( 'Discord API failure: modify\n{}'.format( traceback.format_exc())) else: message = hint.long_discord_message() try: discord_id = self.client.channels_messages_create( self.HINT_CHANNEL, message, embed=embed).id except Exception: dispatch_general_alert( 'Discord API failure: create\n{}'.format( traceback.format_exc())) return hint.discord_id = discord_id hint.save(update_fields=('discord_id', ))
def on_parts_command(self, event, content): pad = self.pad_reader.find_pad(content) if not pad: event.msg.reply('Dude weed lmao cannot find shit') return embed = MessageEmbed() embed.title = pad.title embed.url = pad.url embed.color = cfg.color embed.description = ", ".join(str(x) for x in pad.needs) event.msg.reply('', embed=embed)
def create_embed(event_name: str, event_link: str, user: User, *args, **kwargs): embed = MessageEmbed() embed.title = event_name embed.url = event_link embed.thumbnail = MessageEmbedThumbnail(url=user.avatar_url) args_desc = "\n\n".join(args) kwargs_desc = "\n\n".join("**{0}:\n{1}**".format(name, value) for name, value in kwargs.items()) embed.description = "\n\n".join((args_desc, kwargs_desc)) embed.color = 0x00FFFF return embed
def create_log_embed(event_type, event, custom=False, data={}): guilds = load() embed = MessageEmbed() if not custom: log_message = response_to_class("rich", event_type) content = log_message[0] if log_message[0] != None: content = log_message[0].format(e=event) embed.title = log_message[1] if log_message != None: embed.title = log_message[1].format(e=event) embed.description = log_message[2] if log_message[2] != None: embed.description = log_message[2].format(e=event) embed.footer.text = log_message[3] if log_message[3] != None: embed.footer.text = log_message[3].format(e=event) embed.url = log_message[4] if log_message[4] != None: embed.url = log_message[4].format(e=event) embed.color = log_message[5] """else: #IGNORE FOR NOW if "content" in data: content = data["content"] if "title" in data: title = data["title"] if "desciption" in data: desciption = data["response"]""" return [content, embed]
def on_reddit(self, event): random_post = self.reddit.random_post(self.memes) # permissions check bot_perms = event.channel.get_permissions(self.state.me.id) if bot_perms.administrator or bot_perms.embed_links: embed = MessageEmbed() embed.title = random_post.title embed.url = random_post.permalink embed.image = MessageEmbedImage(url=random_post.url) event.msg.reply(embed=embed) else: # Send a normal message. event.msg.reply(random_post.url)
def create_embed(event_name: str, event_link: str, title: str, *args, **kwargs): embed = MessageEmbed() embed.title = title embed.url = event_link embed.author = MessageEmbedAuthor( name=event_name, url="https://github.com/noita-player/noitadocs", icon_url= "https://cdn.discordapp.com/avatars/380885338916388876/68c463572e12c8f9209789fd8ca29ff0.webp?size=128" ) args_desc = "\n\n".join(args) kwargs_desc = "\n\n".join("**{0}:\n{1}**".format(name, value) for name, value in kwargs.items()) embed.description = "\n\n".join((args_desc, kwargs_desc)) embed.color = 0x00FFFF return embed
def on_info_command(self, event): """Displays some info about the bot, or me!""" infoEmbed = MessageEmbed() github = "https://github.com/One-Nub/Who-Am-I" myPfpImg = "https://i.lensdump.com/i/WDsOXb.png" botPfpImg = "https://i.lensdump.com/i/WDs4G5.png" botInvite = ("https://discordapp.com/api/oauth2/authorize?client_id=" + "592796597209792542&permissions=380096&scope=bot") infoEmbed.title = "Welcome to **Who Am I**!" infoEmbed.url = github infoEmbed.color = 0x8DD0E1 infoEmbed.description = ( "Hey there! This bot was created for the June 2019 " + "Discord Hackathon!") infoEmbed.set_thumbnail(url=botPfpImg) infoEmbed.set_author(name="Nub#8399", icon_url=myPfpImg) infoEmbed.timestamp = datetime.utcnow().isoformat() infoEmbed.add_field( name="What is/was this Hackathon?", value= "This was a week where developers, such as myself, would create" " either a bot of some sort, " "or something creative (art, music, etc...), " "and we would then submit our creations by the end of the week!", inline=False) infoEmbed.add_field( name="So what does this bot do?", value= "This bot is meant to make it easier to learn about people and share" "info about yourself!" "\nThis is done by letting users give info to the bot" "& then displaying that info with a simple command!", inline=False) infoEmbed.add_field(name="View my github here!", value=github, inline=False) infoEmbed.add_field(name="Invite me here!", value="[Invite me!]({})".format(botInvite), inline=False) event.msg.reply(embed=infoEmbed)
def get_embed(self, info): flair = info.flair.lower().replace(MAORITANGA.decode('utf8'), 'a') colour = int(self.flair_colours.get(flair, self.default_flair_colour), 16) embed = MessageEmbed() embed.title = textwrap.shorten(u"[{}] {}".format( info.flair, info.title), width=256, placeholder="...") embed.url = "https://reddit.com{}".format(info.url) embed.color = colour embed.set_thumbnail(url=info.thumbnail) embed.set_author(name=info.author, url="https://reddit.com/u/{}".format(info.author)) embed.timestamp = datetime.fromtimestamp(info.time, timezone.utc).isoformat() return embed
def generate_message(self, twitch, new_state): embed = MessageEmbed() embed.title = u'{}'.format(new_state['status']) embed.url = 'https://twitch.tv/{}'.format(new_state['name']) embed.color = 0x6441A4 embed.set_image(url=new_state['preview']) embed.add_field(name='Game', value=new_state['game'], inline=True) embed.add_field(name='Viewers', value=new_state['viewers'], inline=True) if twitch.notification_type == NotificationType.HERE: msg = u'@here {} is now live!'.format(new_state['name']) elif twitch.notification_type == NotificationType.EVERYONE: msg = u'@everyone {} is now live!'.format(new_state['name']) elif twitch.notification_type == NotificationType.ROLE: msg = u'<@&{}> {} is now live!'.format(twitch.notification_target, new_state['name']) else: msg = u'{} is now live!'.format(new_state['name']) return msg, embed
def on_message(self, event): if not event.member.user.bot: m = re.search( r"https*:\/\/w*\.*amiami\.[a-zA-Z]+\/[a-zA-Z\/]+\?gcode=([^\&]+)", event.message.content) if m: results = amiami.search(m.group(1)) if len(results.items) > 0: item = results.items[0] embed = MessageEmbed() embed.color = cfg.color embed.title = item.productName embed.url = item.productURL embed.set_footer(text=f"{item.price:,} JPY") embed.thumbnail = MessageEmbedThumbnail() embed.thumbnail.url = item.imageURL event.reply("", embed=embed)
def embed(self): e = MessageEmbed() e.color = self.color e.title = self.stream_title e.url = self.stream_url author = MessageEmbedAuthor() author.name = self.display_name author.url = self.stream_url author.icon_url = self.avatar e.author = author thumbnail = MessageEmbedThumbnail() thumbnail.url = self.avatar thumbnail.proxy_url = self.avatar thumbnail.width, thumbnail.height = 100, 100 e.thumbnail = thumbnail image = MessageEmbedImage() image.url = self.stream_preview + '?rand={}'.format(randint(0, 999999)) e.image = image footer = MessageEmbedFooter() footer.text = self.platform_name e.footer = footer if self.stream_game: game_field = MessageEmbedField() game_field.name = 'Played Game' game_field.value = self.stream_game game_field.inline = True e.fields.append(game_field) if self.stream_viewers_count or self.stream_viewers_count == 0: viewers_field = MessageEmbedField() viewers_field.name = 'Viewers' viewers_field.value = str(self.stream_viewers_count) viewers_field.inline = True e.fields.append(viewers_field) return e
def embed(self): e = MessageEmbed() e.color = self.color e.title = self.stream_title e.url = self.stream_url author = MessageEmbedAuthor() author.name = self.display_name author.url = self.stream_url author.icon_url = self.avatar e.author = author thumbnail = MessageEmbedThumbnail() thumbnail.url = self.avatar thumbnail.proxy_url = self.avatar thumbnail.width, thumbnail.height = 100, 100 e.thumbnail = thumbnail image = MessageEmbedImage() image.url = self.stream_preview + '?rand={}'.format(randint(0, 999999)) e.image = image footer = MessageEmbedFooter() footer.text = self.platform_name e.footer = footer if self.stream_game: game_field = MessageEmbedField() game_field.name = 'Played Game' game_field.value = self.stream_game game_field.inline = True e.fields.append(game_field) if self.stream_viewers_count or self.stream_viewers_count == 0: viewers_field = MessageEmbedField() viewers_field.name = 'Viewers' viewers_field.value = str(self.stream_viewers_count) viewers_field.inline = True e.fields.append(viewers_field) return e
def on_danbooru(self, event, tags): count = requests.get("https://danbooru.donmai.us/counts/posts.json", params={"tags": tags}) if len(count.content) > 0 and len( count.json()) > 0 and "counts" in count.json( ) and "posts" in count.json()["counts"]: count = count.json()["counts"]["posts"] r = requests.get("https://danbooru.donmai.us/posts.json", params={ "tags": tags, "limit": 200, "random": "true" if count > 200 else "false" }) if len(r.content) > 0 and len(r.json()) > 0: if "success" in r.json() and not r.json()["success"]: event.message.reply(r.json()["message"]) return n = random.randint(0, len(r.json()) - 1) embed = MessageEmbed() embed.color = cfg.color embed.title = tags embed.url = "https://danbooru.donmai.us/posts/{}".format( r.json()[n]["id"]) if "large_file_url" in r.json()[n]: embed.set_image(url=r.json()[n]["large_file_url"]) else: embed.set_image(url=r.json()[n]["file_url"]) event.msg.reply('', embed=embed) else: event.msg.reply("nothing found")
def webhook_circle_ci(): data = request.json['payload'] embed = MessageEmbed() if data['outcome'] == 'success': embed.color = 0x42c88a else: embed.color = 0xed5c5c embed.title = 'Build #{} - {} ({})'.format( data['build_num'], data['subject'], data['author_name'], ) embed.url = data['build_url'] steps = [] for step in data['steps']: emoji = ':x:' if any( True for act in step['actions'] if act.get('failed', False)) else ':white_check_mark:' steps.append('{} - {}'.format(emoji, step['name'])) embed.description = '\n'.join(steps) embed.description += '\n [View Diff]({})'.format(data['compare']) Webhook.execute_url(current_app.config.get('WEBHOOK_URL'), embeds=[embed]) if data['outcome'] != 'success': return subprocess.Popen(['git', 'pull', 'origin', 'master']).wait() rdb.publish('actions', json.dumps({ 'type': 'RESTART', })) return '', 200
def on_google(self, event, search): r = requests.get("https://www.googleapis.com/customsearch/v1", params = { "key": cfg.google_key, "cx": cfg.google_cx, "q": search }) if len(r.content) > 0 and len(r.json()) > 0 and "items" in r.json() and len(r.json()["items"]) > 0: item = r.json()["items"][0] embed = MessageEmbed() embed.color = cfg.color embed.title = item["title"] embed.url = item["link"] embed.description = item["snippet"] event.msg.reply('', embed=embed) else: event.msg.reply("nothing found")
def wrapper(self, event): if not self.config['enabled'].get(event.__class__.__name__): return embed = MessageEmbed() embed.title = space_name(event.__class__.__name__) embed.color = 0x6832E3 embed.description = "" embed.timestamp = datetime.utcnow().isoformat() data = func(self, event) if "thumbnail" in data: embed.set_thumbnail(url=data["thumbnail"]) if "link" in data: embed.url = data['link'] for part in data['parts']: for key, value in part.items(): embed.description += "**" + key.title( ) + ":** " + value + "\n" embed.description += "\n" self.client.api.channels_messages_create( self.config["logging_channel"], " ", embed=embed)
from disco.bot import Plugin from disco.bot.command import CommandEvent from disco.types.message import MessageEmbed embed = MessageEmbed() # Create a discord embed object and set default name/icon embed.set_author(name='Code Network', icon_url='https://codenetwork.co/wp-content/uploads/2018/05/cn-logo-dark-square.png') embed.url = 'https://codenetwork.co/rules' class Bot(Plugin): def get_welcome_embed(self): embed.description = 'Welcome to the official Code Network Discord. To get started, here are some handy links.' embed.description += 'We recommend you read through all of them so you get a better understanding of the ' embed.description += 'community expectations. However, we\'ve also provided a tldr; of each one below.' embed.add_field(name='General Rules', value='https://codenetwork.co/rules', inline=True) embed.add_field(name='Code of Conduct', value='https://codenetwork.co/coc', inline=True) embed.add_field(name='Safe Space Policy', value='https://codenetwork.co/ssp', inline=True) embed.add_field(name='Main Website', value='https://codenetwork.co', inline=True) embed.add_field(name='General Rules tldr;', value='If you’re a recruiter, your job post doesn’t belong in our community. If you’re a technical looking to fill a paid role feel free to advertise it, but include detailed info about the role. No advertising or self promotion - share stuff you’ve built to start conversations, not conversions. Always follow our Code of Conduct and Safe Space Policy.', inline=False) embed.add_field(name='Code of Conduct (CoC) tldr;', value='Always be considerate, respectful and treat others how you’d want to be treated. Never start/continue flame wars or trolling and don’t make anyone feel uncomfortable or unwelcome. Always be collaborative, stay honest and don’t misrepresent the group or executive. Above all, never discriminate against or harass someone.', inline=False) embed.add_field(name='Safe Space Policy (SSP) tldr;', value='Abuse, discrimination, harassment, assault, sexism, racism, ableism, religious persecution or homophobic behaviour of any kind is not tolerated in the Code Network community. This include events, discussions and online communications. Any other behavior which would reasonably make a person feel trivialised or otherwise discriminated against is also prohibited. If you violate this policy you could be asked to leave our community either temporarily or permanently.', inline=False) return embed @Plugin.command('bot') def command_responsive(self, event: CommandEvent): event.msg.reply('Beep Boop. The bot 🤖 is responsive.') @Plugin.command('help') @Plugin.command('usage') def command_help(self, event: CommandEvent):
temp_f = weather['temp_f'] condition = weather['weather'] wind_dir = weather['wind_dir'] wind_mph = weather['wind_mph'] wind_kph = weather['wind_kph'] except KeyError, e: self.log.error('Invalid query') return embed = MessageEmbed() embed.set_author( name='Wunderground', url='http://www.wunderground.com', icon_url='http://icons.wxug.com/graphics/wu2/logo_130x80.png') embed.title = '{}, {}'.format(display_state, display_city) embed.url = forecast_url embed.description = condition embed.add_field(name='Temperature', value='{}° F ({}° C)'.format(temp_f, temp_c), inline=True) embed.add_field(name='Precipitation', value=precip, inline=True) embed.add_field(name='Wind', value='From the {} at {}mph ({}kph)'.format( wind_dir, wind_mph, wind_kph), inline=True) embed.timestamp = pendulum.now().in_tz('America/New_York').isoformat() embed.set_thumbnail(url=icon_url) embed.set_footer(text='Powered by Weather Underground') embed.color = '2189209' # dark blue (hex: #216799) event.msg.reply(embed=embed)
def get_parking_qut(): """Replies with an embed object containing QUT parking information""" url = "https://paseweb.parkassist.com/sites/qut/status/v2/zones.json" # URL that has the parking info embed = MessageEmbed() # Create a discord embed object # Specify the name, logo, url and description of the parking bot response embed.set_author( name='QUT Parking Bot', icon_url= 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/12/QUTLogo.svg/1200px-' + 'QUTLogo.svg.png') embed.url = 'https://paseweb.parkassist.com/en/sites/qut/embedded_widgets/available_spaces' embed.description = 'This is scraped from the parkassist website. Only Gardens Point is supported at the moment.' response = requests.get(url) # Fetch the parking info if response.status_code == 200: # If we got an ok response parse the JSON parking = json.loads(response.text) p = 0 freeway = 0 szc = 0 # This bit of hackery is needed because the parking json segments each level into a separate zone for zone in parking["response"]: if zone["id"] in [1, 2]: p += zone["counts"]["available"] elif zone["id"] in [3]: freeway += zone["counts"]["available"] elif zone["id"] in [4, 5, 6, 7, 8, 9]: szc += zone["counts"]["available"] # Add each zone to the parking bot response embed.add_field(name='P Block (GP)', value='{} parks available.'.format(p), inline=True) embed.add_field(name='Under Freeway (GP)', value='{} parks available.'.format(freeway), inline=True) embed.add_field(name='S/Z/C Block (GP)', value='{} parks available.'.format(szc), inline=True) embed.add_field( name="Last update from QUT:", value=parking["response"][0]["counts"]["timestamp"][11:19], inline=False) else: # If we didn't get an OK response then something went wrong embed.add_field( name='Data Not Available', value='Something went wrong while fetching the parking data. This ' 'is most likely a problem with the server the data ' 'comes from.', inline=False) # Add some more info to the end of the parking bot response embed.add_field( name='More Info', value='For more info about costs and restrictions see this web page: ' + "https://www.qut.edu.au/about/services-and-facilities/all-services/parking", inline=False) return embed # return the embed object so the parent function can send a response
def monster_alert(self, d): legend = json.loads(open('config/monsters.json').read()) if 'form' in d: pmtitle = re.sub('<MON>', d['mon_name'] + '({})'.format(d['form']), legend['mon']) else: pmtitle = re.sub('<MON>', d['mon_name'], legend['mon']) pmintro = legend['time'] description = pmintro adreu = d.get('street', '') + d.get('street_num', '') adrus = d.get('street_num', '') + d.get('street', '') address = legend.get('address', '') stats = legend.get('iv', '') moves = legend.get('moves', '') boost = legend.get('weather', '') rmlinkfield = legend.get('RM', '') if d['geo_enabled']: description += address if 'atk' in d and d['iv_enabled']: description += stats if 'atk' in d and d['moves_enabled']: description += moves if 'boost' in d and d['weather_enabled']: description += boost if args.mapurl: description += rmlinkfield description = re.sub('<DESPAWN>', d.get('time', ''), description) description = re.sub('<TTH>', d.get('tth', ''), description) description = re.sub('<CITY>', d.get('city', ''), description) description = re.sub('<SUB>', d.get('suburb', ''), description) description = re.sub('<STR>', d.get('street', ''), description) description = re.sub('<STR_NUM>', d.get('street_num', ''), description) description = re.sub('<ADDR_EU>', adreu, description) description = re.sub('<ADDR_US>', adrus, description) description = re.sub('<IV>', str(d.get('perfection', '')), description) description = re.sub('<ATK>', str(d.get('atk', '')), description) description = re.sub('<DEF>', str(d.get('def', '')), description) description = re.sub('<STA>', str(d.get('sta', '')), description) description = re.sub('<LVL>', str(d.get('level', '')), description) description = re.sub('<CP>', str(d.get('cp', '')), description) description = re.sub('<MOVE1>', d.get('move1', ''), description) description = re.sub('<MOVE2>', d.get('move2', ''), description) description = re.sub('<WEA>', d.get('description', ''), description) description = re.sub('<RM>', d.get('mapurl', ''), description) embed = MessageEmbed(color=d['color'], description=description) if d['map_enabled']: embed.image = MessageEmbedImage(url=d['static']) embed.author = MessageEmbedAuthor(url=d['gmapurl'], name=pmtitle) embed.title = '{}'.format(d['mon_name']) embed.url = d['gmapurl'] embed.thumbnail = MessageEmbedThumbnail(url=d['thumb'].lower()) self.channels_messages_create(d['channel'], embed=embed)