Skip to content

Commit

Permalink
Improvements to want custom, raid archive, pokemon objects
Browse files Browse the repository at this point in the history
  • Loading branch information
doonce committed Jul 27, 2021
1 parent ff6d8b1 commit 2edd16a
Show file tree
Hide file tree
Showing 10 changed files with 11,846 additions and 11,823 deletions.
23,188 changes: 11,609 additions & 11,579 deletions locale/en/pkmn.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions meowth/exts/invasion.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ async def send_dm_messages(self, ctx, inv_pokemon, location, coordinates, embed,
continue
if "invasion" not in user_custom[custom].get('report_types'):
continue
if pokemon and user_custom[custom].get('form') and pokemon.form_name not in user_custom[custom]['form']:
continue
send_invasion.append("Custom")
if type_setting and pkmn_types[0].lower() in user_types:
type_emoji = utils.parse_emoji(ctx.guild, self.bot.config.type_id_dict[pkmn_types[0].lower()])
Expand Down
10 changes: 6 additions & 4 deletions meowth/exts/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,9 +1141,9 @@ async def _wantlist(self, ctx):
alert_text = ""
for custom in user_custom:
if isinstance(user_custom[custom]['pokemon'], str):
alert_text += f"**Pokemon**: {user_custom[custom]['pokemon']}"
alert_text += f"**Pokemon**: {user_custom[custom]['pokemon'].title()}"
else:
alert_text += f"**Pokemon**: {', '.join(user_custom[custom]['pokemon'])}"
alert_text += f"**Pokemon**: {', '.join([x.title() for x in user_custom[custom]['pokemon']])}"
if user_custom[custom].get('min_iv') != None:
alert_text += f" | **IV Percent**: {user_custom[custom]['min_iv']}-{user_custom[custom]['max_iv']}"
if user_custom[custom].get('min_atk') != None:
Expand All @@ -1157,9 +1157,11 @@ async def _wantlist(self, ctx):
if user_custom[custom].get('min_level') != None:
alert_text += f" | **Level**: {user_custom[custom]['min_level']}-{user_custom[custom]['max_level']}"
if user_custom[custom].get('gender'):
alert_text += f" | **Gender**: {user_custom[custom]['gender']}"
alert_text += f" | **Gender**: {user_custom[custom]['gender'].title()}"
if user_custom[custom].get('size'):
alert_text += f" | **Size**: {user_custom[custom]['size']}"
alert_text += f" | **Size**: {user_custom[custom]['size'].upper()}"
if user_custom[custom].get('form'):
alert_text += f" | **Form**: {', '.join([x.title() for x in user_custom[custom]['size']])}"
alert_text += f" | **Report Types**: {(', ').join(user_custom[custom]['report_types'])}\n"
custom_list = alert_text.splitlines()
categories = copy.deepcopy(self.bot.guild_dict[ctx.guild.id].setdefault('trainers', {}).setdefault(ctx.author.id, {}).setdefault('alerts', {}).setdefault('settings', {}).setdefault('categories', {}))
Expand Down
2 changes: 2 additions & 0 deletions meowth/exts/nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ async def send_dm_messages(self, ctx, nest_name, pokemon, embed, dm_dict):
continue
if "nest" not in user_custom[custom].get('report_types'):
continue
if pokemon and user_custom[custom].get('form') and pokemon.form_name not in user_custom[custom]['form']:
continue
send_nest.append("Custom")
if type_setting and nest_types[0].lower() in user_types:
type_emoji = utils.parse_emoji(ctx.guild, self.bot.config.type_id_dict[nest_types[0].lower()])
Expand Down
283 changes: 85 additions & 198 deletions meowth/exts/pokemon.py

Large diffs are not rendered by default.

29 changes: 21 additions & 8 deletions meowth/exts/raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, bot):

def cog_unload(self):
for task in asyncio.Task.all_tasks():
if "expiry_check" in str(task) and "raid" in str(task):
if ("expiry_check" in str(task) or "expire_channel" in str(task)) and "raid" in str(task):
task.cancel()
self.channel_cleanup.cancel()
self.lobby_cleanup.cancel()
Expand Down Expand Up @@ -266,11 +266,18 @@ async def on_message_delete(self, message):
await utils.add_reaction(ctrsmessage, reaction.emoji)
self.bot.guild_dict[guild.id][report_dict][message.channel.id]['ctrsmessage'] = ctrsmessage.id
if channel.id in self.bot.guild_dict.get(guild.id, {}).get(report_dict, {}) and self.bot.guild_dict[guild.id]['configure_dict'].setdefault('archive', {}).setdefault('enabled', False):
if message.content.strip() == "!archive":
if author.bot:
return
ctx = await self.bot.get_context(message)
if not ctx.prefix:
prefix = self.bot._get_prefix(self.bot, ctx.message)
ctx.prefix = prefix[-1]
if message.content.strip() == f"{ctx.prefix}archive":
self.bot.guild_dict[guild.id][report_dict][channel.id]['archive'] = True
if self.bot.guild_dict[guild.id][report_dict][channel.id].get('archive', False):
logs = self.bot.guild_dict[guild.id][report_dict][channel.id].get('logs', {})
logs[message.id] = {'author_id': message.author.id, 'author_str': str(message.author), 'author_avy':str(message.author.avatar_url), 'author_nick':message.author.nick, 'color_int':message.author.color.value, 'content': message.clean_content, 'created_at':message.created_at}
now = datetime.datetime.utcnow()
logs[message.id] = {'author_id': message.author.id, 'author_str': str(message.author), 'author_avy':str(message.author.avatar_url), 'author_nick':message.author.nick, 'color_int':message.author.color.value, 'content': message.clean_content, 'created_at':message.created_at, 'deleted_at': now}
self.bot.guild_dict[guild.id][report_dict][channel.id]['logs'] = logs

@commands.Cog.listener()
Expand Down Expand Up @@ -679,17 +686,19 @@ async def expire_channel(self, channel):
else:
newcat = guild.get_channel(category)
try:
await channel.edit(name=new_name, category=newcat)
self.bot.loop.create_task(channel.edit(name=new_name, category=newcat))
except (discord.errors.NotFound, discord.errors.Forbidden, discord.errors.HTTPException):
pass
await channel.send(_('-----------------------------------------------\n**The channel has been archived and removed from view for everybody but Meowth and those with Manage Channel permissions. Any messages that were deleted after the channel was marked for archival will be posted below. You will need to delete this channel manually or use !recover**\n-----------------------------------------------'))
archive_embed = discord.Embed(colour=guild.me.colour).set_thumbnail(url='https://raw.githubusercontent.com/doonce/Meowth/Rewrite/images/emoji/unicode_inboxtray.png?cache=1')
archive_embed.add_field(name=f"Channel Archived", value=f"The channel has been archived and removed from view for everybody but Meowth and those with Manage Channel permissions. Any messages that were deleted after the channel was marked for archival will be posted below. You will need to delete this channel manually or use !recover")
await channel.send(embed=archive_embed)
while logs:
earliest = min(logs)
embed = discord.Embed(colour=logs[earliest]['color_int'], description=logs[earliest]['content'], timestamp=logs[earliest]['created_at'])
embed = discord.Embed(colour=logs[earliest]['color_int'], description=logs[earliest]['content']).set_footer(text=f"Sent: {logs[earliest]['created_at'].strftime('%y-%m-%d %I:%M%p')} | Deleted: {logs[earliest]['deleted_at'].strftime('%y-%m-%d %I:%M%p')}")
if logs[earliest]['author_nick']:
embed.set_author(name="{name} [{nick}]".format(name=logs[earliest]['author_str'], nick=logs[earliest]['author_nick']), icon_url = logs[earliest]['author_avy'])
embed.set_author(name=f"{logs[earliest]['author_str']} [{logs[earliest]['author_nick']}] deleted a message:", icon_url = logs[earliest]['author_avy'])
else:
embed.set_author(name=logs[earliest]['author_str'], icon_url = logs[earliest]['author_avy'])
embed.set_author(name=f"{logs[earliest]['author_str']} deleted a message:", icon_url = logs[earliest]['author_avy'])
await channel.send(embed=embed)
del logs[earliest]
await asyncio.sleep(.25)
Expand Down Expand Up @@ -756,6 +765,8 @@ async def invite_request_cleanup(self, loop=True):
pokemon_list = self.bot.guild_dict[guild.id]['invite_requests'][trainer]['pokemon_list']
account_str = ""
for account in trainer_dict:
if account == "manual" or account == "party" or account == "entered_interest":
continue
account_str += f"**Name:** {account} | **Trainercode:** {trainer_dict[account]}\n"
embed = discord.Embed(colour=guild.me.colour).set_thumbnail(url='https://raw.githubusercontent.com/doonce/Meowth/Rewrite/images/emoji/unicode_satelliteantenna.png?cache=1')
embed.add_field(name=f"**Invite Interest**", value=f"{'Egg Levels: '+', '.join(level_list) if level_list else ''}\n{'Pokemon: '+', '.join(pokemon_list) if pokemon_list else ''}", inline=False)
Expand Down Expand Up @@ -998,6 +1009,8 @@ async def send_dm_messages(self, ctx, pokemon_or_level, raid_details, coordinate
continue
if "raid" not in user_custom[custom].get('report_types'):
continue
if pokemon and user_custom[custom].get('form') and pokemon.form_name not in user_custom[custom]['form']:
continue
send_raid.append("Custom")
if type_setting and raid_types[0].lower() in user_types:
type_emoji = utils.parse_emoji(ctx.guild, self.bot.config.type_id_dict[raid_types[0].lower()])
Expand Down
2 changes: 2 additions & 0 deletions meowth/exts/research.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,8 @@ async def send_dm_messages(self, ctx, res_pokemon, location, coordinates, item,
continue
if "research" not in user_custom[custom].get('report_types'):
continue
if pokemon and user_custom[custom].get('form') and pokemon.form_name not in user_custom[custom]['form']:
continue
send_research.append("Custom")
if stop_setting and (location.lower() in user_stops or coordinates in user_stops):
send_research.append(f"Pokestop: {location.title()}")
Expand Down
2 changes: 2 additions & 0 deletions meowth/exts/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ async def send_dm_messages(self, ctx, trade_pokemon, embed, dm_dict=None):
continue
if "trade" not in user_custom[custom].get('report_types'):
continue
if pokemon and user_custom[custom].get('form') and pokemon.form_name not in user_custom[custom]['form']:
continue
send_trade.append("Custom")
if type_setting and pkmn_types[0].lower() in user_types:
type_emoji = utils.parse_emoji(ctx.guild, self.bot.config.type_id_dict[pkmn_types[0].lower()])
Expand Down
Loading

0 comments on commit 2edd16a

Please sign in to comment.