Skip to content

Commit

Permalink
Added auto heal tracking and disable heal warning in hunt/adv while a…
Browse files Browse the repository at this point in the history
…ctive, typos, bugfixes
  • Loading branch information
Miriel committed Mar 14, 2024
1 parent 95132c8 commit a0819c3
Show file tree
Hide file tree
Showing 23 changed files with 180 additions and 148 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.44.1 (07 Mar 2024)
2.45.0 (14 Mar 2024)
14 changes: 12 additions & 2 deletions cogs/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ async def on_message(self, message: discord.Message) -> None:
if pocket_watch_active_match:
search_patterns = [
r'adds a cooldown reduction of ([0-9\.]+)% and doubles', #English
r'adds a cooldown reduction of ([0-9\.]+)% and doubles', #Spanish, MISSING
r'adds a cooldown reduction of ([0-9\.]+)% and doubles', #Portuguese, MISSING
r'adds a cooldown reduction of ([0-9\.]+)% and doubles', #TODO: Spanish
r'adds a cooldown reduction of ([0-9\.]+)% and doubles', #TODO: Portuguese
]
pocket_watch_cooldown_match = await functions.get_match_from_patterns(search_patterns, embed_fields)
pocket_watch_cooldown = float(pocket_watch_cooldown_match.group(1))
Expand All @@ -111,6 +111,16 @@ async def on_message(self, message: discord.Message) -> None:
await partner_settings.update(partner_pocket_watch_multiplier=(100 - pocket_watch_cooldown) / 100)
except exceptions.FirstTimeUserError:
pass
else:
if user_settings.user_pocket_watch_multiplier != 1:
await user_settings.update(user_pocket_watch_multiplier=1)
if user_settings.partner_id is not None:
if user_settings.partner_pocket_watch_multiplier != 1:
try:
partner_settings: users.User = await users.get_user(user_settings.partner_id)
await partner_settings.update(partner_pocket_watch_multiplier=1)
except exceptions.FirstTimeUserError:
pass
if user_settings.reactions_enabled: await message.add_reaction(emojis.NAVI)


Expand Down
175 changes: 88 additions & 87 deletions cogs/auto_flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ async def on_message(self, message: discord.Message) -> None:
added_tts = 1
search_strings = [
r'managed to jump out', #English
r'managed to jump out', #Spanish, MISSING
r'managed to jump out', #Portuguese, MISSING
r'managed to jump out', #TODO: Spanish
r'managed to jump out', #TODO: Portuguese
]
if any(search_string in embed_description.lower() for search_string in search_strings):
added_tts += 1
Expand Down Expand Up @@ -1253,93 +1253,94 @@ async def on_message(self, message: discord.Message) -> None:
'epic bundle', #All languages, halloween shop
'epic coins', #All languages, epic shop
]
if (any(search_string in message_content.lower() for search_string in search_strings)
and all(search_string not in message_content.lower() for search_string in search_strings_excluded)
or ('nice!' in message_content.lower() and 'watermelon' in message_content.lower())):
guild_settings: guilds.Guild = await guilds.get_guild(message.guild.id)
if not guild_settings.auto_flex_enabled: return
user = await functions.get_interaction_user(message)
search_patterns = [
r'\?\? \*\*(.+?)\*\* got (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #English ULTRA log
r'!!1 (.+?)\*\* got (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #English HYPER log
r' \*\*(.+?)\*\* got (.+?) (.+?) __\*\*(ultimate log)\*\*__', #English ULTIMATE log
r'\*\*(.+?)\*\* also got (.+?) (.+?) \*\*(epic berry)\*\*', #English EPIC berry
r'\*\*(.+?)\*\* got (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #English SUPER fish, watermelon
r'\?\? \*\*(.+?)\*\* cons(?:e|i)gui(?:ó|u) (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #Spanish/Portuguese ULTRA log
r'!!1 (.+?)\*\* cons(?:e|i)gui(?:ó|u) (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #Spanish/Portuguese HYPER log
r'\*\*(.+?)\*\* cons(?:e|i)gui(?:ó|u) (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #Spanish/Portuguese ULTIMATE log, SUPER fish, watermelon
]
item_events = {
'epic berry': 'work_epicberry',
'hyper log': 'work_hyperlog',
'super fish': 'work_superfish',
'ultimate log': 'work_ultimatelog',
'ultra log': 'work_ultralog',
'watermelon': 'work_watermelon',
}
match = await functions.get_match_from_patterns(search_patterns, message_content)
if not match:
await functions.add_warning_reaction(message)
await errors.log_error('Couldn\'t find auto flex data in work message.', message)
return
user_name = match.group(1)
item_amount = int(match.group(2))
item_name = match.group(4).lower().replace('**','').strip()
if item_name not in item_events: return
event = item_events[item_name]
if user is None:
user_command_message = (
await messages.find_message(message.channel.id, regex.COMMAND_WORK,
user_name=user_name)
)
if user_command_message is None:
if len(message_content.split('\n')) > 1:
if (any(search_string in message_content.lower() for search_string in search_strings)
and all(search_string not in message_content.lower() for search_string in search_strings_excluded)
or ('nice!' in message_content.lower() and 'watermelon' in message_content.lower())):
guild_settings: guilds.Guild = await guilds.get_guild(message.guild.id)
if not guild_settings.auto_flex_enabled: return
user = await functions.get_interaction_user(message)
search_patterns = [
r'\?\? \*\*(.+?)\*\* got (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #English ULTRA log
r'!!1 (.+?)\*\* got (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #English HYPER log
r' \*\*(.+?)\*\* got (.+?) (.+?) __\*\*(ultimate log)\*\*__', #English ULTIMATE log
r'\*\*(.+?)\*\* also got (.+?) (.+?) \*\*(epic berry)\*\*', #English EPIC berry
r'\*\*(.+?)\*\* got (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #English SUPER fish, watermelon
r'\?\? \*\*(.+?)\*\* cons(?:e|i)gui(?:ó|u) (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #Spanish/Portuguese ULTRA log
r'!!1 (.+?)\*\* cons(?:e|i)gui(?:ó|u) (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #Spanish/Portuguese HYPER log
r'\*\*(.+?)\*\* cons(?:e|i)gui(?:ó|u) (.+?) (.+?) (?:__)?\*\*(.+?)(?:\n|__|$)', #Spanish/Portuguese ULTIMATE log, SUPER fish, watermelon
]
item_events = {
'epic berry': 'work_epicberry',
'hyper log': 'work_hyperlog',
'super fish': 'work_superfish',
'ultimate log': 'work_ultimatelog',
'ultra log': 'work_ultralog',
'watermelon': 'work_watermelon',
}
match = await functions.get_match_from_patterns(search_patterns, message_content)
if not match:
await functions.add_warning_reaction(message)
await errors.log_error('Couldn\'t find user for auto flex work message.', message)
await errors.log_error('Couldn\'t find auto flex data in work message.', message)
return
user = user_command_message.author
try:
user_settings: users.User = await users.get_user(user.id)
except exceptions.FirstTimeUserError:
return
if not user_settings.bot_enabled or not user_settings.auto_flex_enabled: return
user_name = match.group(1)
item_amount = int(match.group(2))
item_name = match.group(4).lower().replace('**','').strip()
if item_name not in item_events: return
event = item_events[item_name]
if user is None:
user_command_message = (
await messages.find_message(message.channel.id, regex.COMMAND_WORK,
user_name=user_name)
)
if user_command_message is None:
await functions.add_warning_reaction(message)
await errors.log_error('Couldn\'t find user for auto flex work message.', message)
return
user = user_command_message.author
try:
user_settings: users.User = await users.get_user(user.id)
except exceptions.FirstTimeUserError:
return
if not user_settings.bot_enabled or not user_settings.auto_flex_enabled: return

if event == 'work_ultimatelog':
description = (
f'**{user_name}** did some really weird timber magic stuff and found **{item_amount:,}** '
f'{emojis.LOG_ULTIMATE} **ULTIMATE logs**!\n'
f'Not sure this is allowed.'
)
elif event == 'work_ultralog':
description = (
f'**{user_name}** just cut down **{item_amount:,}** {emojis.LOG_ULTRA} **ULTRA logs** with '
f'three chainsaws.\n'
f'One of them in their mouth... uh... okay.'
)
elif event == 'work_watermelon':
description = (
f'**{user_name}** got tired of apples and bananas and stole **{item_amount:,}** '
f'{emojis.WATERMELON} **watermelons** instead.\n'
f'They should be ashamed (and make cocktails).'
)
elif event == 'work_superfish':
description = (
f'**{user_name}** went fishing and found **{item_amount:,}** weird purple {emojis.FISH_SUPER} '
f'**SUPER fish** in the river.\n'
f'Let\'s eat them, imagine wasting those on a VOID armor or something.'
)
elif event == 'work_hyperlog':
description = (
f'**{user_name}** took a walk in the park when suddenly a tree fell over and split into '
f'**{item_amount:,}** {emojis.LOG_HYPER} **HYPER logs**.'
)
elif event == 'work_epicberry':
description = (
f'**{user_name}** is making fruit salad!\n'
f'It will consist of bananas, apples and '
f'**{item_amount:,}** {emojis.EPIC_BERRY} **EPIC berries** they just randomly found '
f'while gathering the rest.\n'
)
await self.send_auto_flex_message(message, guild_settings, user_settings, user, event, description)
if event == 'work_ultimatelog':
description = (
f'**{user_name}** did some really weird timber magic stuff and found **{item_amount:,}** '
f'{emojis.LOG_ULTIMATE} **ULTIMATE logs**!\n'
f'Not sure this is allowed.'
)
elif event == 'work_ultralog':
description = (
f'**{user_name}** just cut down **{item_amount:,}** {emojis.LOG_ULTRA} **ULTRA logs** with '
f'three chainsaws.\n'
f'One of them in their mouth... uh... okay.'
)
elif event == 'work_watermelon':
description = (
f'**{user_name}** got tired of apples and bananas and stole **{item_amount:,}** '
f'{emojis.WATERMELON} **watermelons** instead.\n'
f'They should be ashamed (and make cocktails).'
)
elif event == 'work_superfish':
description = (
f'**{user_name}** went fishing and found **{item_amount:,}** weird purple {emojis.FISH_SUPER} '
f'**SUPER fish** in the river.\n'
f'Let\'s eat them, imagine wasting those on a VOID armor or something.'
)
elif event == 'work_hyperlog':
description = (
f'**{user_name}** took a walk in the park when suddenly a tree fell over and split into '
f'**{item_amount:,}** {emojis.LOG_HYPER} **HYPER logs**.'
)
elif event == 'work_epicberry':
description = (
f'**{user_name}** is making fruit salad!\n'
f'It will consist of bananas, apples and '
f'**{item_amount:,}** {emojis.EPIC_BERRY} **EPIC berries** they just randomly found '
f'while gathering the rest.\n'
)
await self.send_auto_flex_message(message, guild_settings, user_settings, user, event, description)

# Christmas loot, non-embed
search_strings = [
Expand Down Expand Up @@ -1417,7 +1418,7 @@ async def on_message(self, message: discord.Message) -> None:
search_strings = [
'stuck in the chimney...', #English
'atascó en la chimenea...', #Spanish
'atascó en la chimenea...', #Portuguese, MISSING
'atascó en la chimenea...', #TODO: Portuguese
]
if (any(search_string in message_content.lower() for search_string in search_strings)):
guild_settings: guilds.Guild = await guilds.get_guild(message.guild.id)
Expand Down
Loading

0 comments on commit a0819c3

Please sign in to comment.