Skip to content

Commit

Permalink
♻️ Change default vendor stop words
Browse files Browse the repository at this point in the history
  • Loading branch information
esemi committed Aug 16, 2024
1 parent 5eea88a commit cd1b890
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Restoring the maximum durability of items is also up to you.
See also [farming math guide here](https://teletype.in/@esemiko/epsa-farming-economics) [RU lang].

### Bot start/stop commands
You can start/stop the bot by sending apropriate commands in @me channel (@Избранное).
You can start/stop the bot by sending apropriate commands in [t.me/@me](t.me/@me) channel (@Избранное).
There are 3 commands:
```
'!exit' - force exit,
Expand All @@ -138,7 +138,7 @@ There are 3 commands:
`skip_random_vendor`: Skipping the random vendor you meet. On by default.

`skip_random_vendor_stop_words`: Prevents the random vendor from skipping for rare items.
By default it does not skip `Свиток Кселеса` and `Безопасный свиток заточки [IV]`.
Empty by default, might be looks like `Кселес,Безопасный свиток заточки [IV]`.

`equip_farming_number`: Binding number of your farming equipment set. By default `1`.

Expand Down
2 changes: 1 addition & 1 deletion epsilion_wars_mmorpg_automation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AppSettings(BaseSettings):
)

skip_random_vendor: bool = True
skip_random_vendor_stop_words: str = 'Свиток Кселеса,Безопасный свиток заточки [IV]'
skip_random_vendor_stop_words: str = ''
use_backup_game_bot: bool = False
equip_farming_number: int = 1
equip_travel_number: int = 2
Expand Down
27 changes: 20 additions & 7 deletions epsilion_wars_mmorpg_automation/trainer/handlers/farming.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def repair_or_go_to_next(event: events.NewMessage.Event) -> None:
repair_location.lower() in location_name.lower()
for repair_location in app_settings.repairman_locations
)
logging.info(f'debug {location_name} {is_repairman_location} ')
logging.debug(f'debug {location_name} {is_repairman_location} ')

if shared_state.FARMING_STATE is shared_state.FarmingState.need_repair:
if is_repairman_location:
Expand Down Expand Up @@ -189,23 +189,36 @@ async def repair_item_approve(event: events.NewMessage.Event) -> None:

async def skip_vendor(event: events.NewMessage.Event) -> None:
"""Skip vendor."""
logging.info('call skip vendor dialog {0}, {1}'.format(
app_settings.skip_random_vendor,
app_settings.skip_random_vendor_stop_words,
))
logging.info('call skip vendor dialog')

if not app_settings.skip_random_vendor:
return await notifications.send_desktop_notify(
message='random vendor lock',
is_urgent=True,
)

message = parsers.strip_message(event.message.message)
inline_buttons = get_buttons_flat(event)
if not inline_buttons:
raise InvalidMessageError('Invalid vendor buttons.')

has_stop_word = False
if app_settings.skip_random_vendor_stop_words:
for stop_word in app_settings.skip_random_vendor_stop_words.split(','):
if stop_word.strip().lower() in message:
return
has_stop_word = True
break

if app_settings.skip_random_vendor:
if has_stop_word:
return await notifications.send_desktop_notify(
message='random vendor lock by stop word',
is_urgent=True,
)

else:
await wait_for()
await event.message.click(len(inline_buttons) - 1)
return


def _get_repairman(event: events.NewMessage.Event) -> str | None:
Expand Down

0 comments on commit cd1b890

Please # to comment.