Skip to content

Commit

Permalink
♻️ Up dependency (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
esemi authored Mar 15, 2024
1 parent 92b74fe commit 4ae6c52
Show file tree
Hide file tree
Showing 18 changed files with 573 additions and 834 deletions.
37 changes: 27 additions & 10 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,35 @@ max-line-length = 125
max-module-members = 9

ignore =
DAR101, # Missing parameter(s) in Docstring
DAR201, # Missing "Returns" in Docstring
DAR401, # Missing exception(s) in Raises section
# Missing parameter(s) in Docstring
DAR101,

WPS204, # Found overused expression
WPS305, # F-strings is OK
WPS306, # Found class without a base class - dataclass used
WPS323, # Found `%` string formatting - simple logging format
WPS332, # Walrus operator is OK
# Missing "Returns" in Docstring
DAR201,

S311, # Standard pseudo-random generators are not suitable for security/cryptographic purposes is OK for the project
# Missing exception(s) in Raises section
DAR401,

# Found overused expression
WPS204,

# Found too long ``try`` body length
WPS229,

# F-strings is OK
WPS305,

# Found class without a base class - dataclass used
WPS306,

# Found `%` string formatting - simple logging format
WPS323,

# Found walrus operator
WPS332,

# Standard pseudo-random generators are not suitable for security/cryptographic purposes is OK for the project
S311,


per-file-ignores =
Expand All @@ -26,7 +44,6 @@ per-file-ignores =
# WPS432 Found magic number - ok for settings
# WPS604 Found incorrect node inside `class` body - custom exceptions
# F401: imported but unused

epsilion_wars_mmorpg_automation/exceptions.py: WPS420, WPS604,
epsilion_wars_mmorpg_automation/settings.py: WPS432,
epsilion_wars_mmorpg_automation/shared_state.py: WPS407,
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
python-version: ['3.12']
steps:
- uses: actions/checkout@v2

Expand All @@ -24,8 +24,8 @@ jobs:
- name: Run MyPy
run: |
poetry run mypy epsilion_wars_mmorpg_automation/ etc/
poetry run mypy epsilion_wars_mmorpg_automation/
- name: Run flake8
run: |
poetry run flake8 epsilion_wars_mmorpg_automation/ etc/
poetry run flake8 epsilion_wars_mmorpg_automation/
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
python-version: ['3.12']
steps:
- uses: actions/checkout@v2

Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Table of Contents

* [What about the rules?](#what-about-the-rules)
* [Requirements](#requirements)
* [Installation](#installation)
* [Installation Windows](#installation-windows)
* [Installation Linux](#installation-linux)
* [Usage](#usage)
* [Grinding](#grinding)
* [Farming](#farming-experimental)
Expand All @@ -26,7 +27,6 @@ Table of Contents
* [What about the captcha?](#what-about-the-captcha)
* [Developers](#developers)
* [Run on server](#run-on-server)
* [TData converter](#tdata-converter)
* [Need more characters](#need-more-characters)


Expand All @@ -36,7 +36,7 @@ TL;DR Screw [the rules](https://teletype.in/@epsilionwar/HkPsNEfZL)
![img.png](assets/block.png)

## Requirements
1. [Python 3.11 or later](https://www.python.org/downloads/) and [pip](https://pip.pypa.io/en/stable/installation/)
1. [Python 3.12 or later](https://www.python.org/downloads/) and [pip](https://pip.pypa.io/en/stable/installation/)
2. Telegram [API ID and token](https://docs.telethon.dev/en/stable/basic/signing-in.html#signing-in)
3. [Registration](https://t.me/epsilionwarbot?start=ref-537453818) on the game.

Expand Down Expand Up @@ -215,12 +215,6 @@ vi /etc/supervisor/conf.d/epsa.conf
service supervisor restart
```

### TData converter
If you plan to buy Telegram accounts, you will need a utility to convert credentials from tdata to .session (for Telethon library).
```shell
python etc/tdata_converter.py -f ~/.local/share/TelegramDesktop/tdata
```

### Need more characters?
The game allows you to have three characters per telegram account.
If you need more, you will need new telegram accounts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def create_task(self, image_base64: str) -> dict:
raise AntiCaptchaError('network error') from fetch_exc

task_data = response.json()
logging.info(f'response createTask {task_data=}')
logging.info('response createTask {0}'.format(task_data))
error = task_data.get('errorCode')
if error:
raise AntiCaptchaError(error)
Expand Down Expand Up @@ -88,7 +88,7 @@ async def get_task(self, task_id: int) -> dict:
raise AntiCaptchaError('network error') from fetch_exc

task_data = response.json()
logging.info(f'response getTaskResult {task_data=}')
logging.info('response getTaskResult {0}'.format(task_data))
error = task_data.get('errorCode')
if error:
raise AntiCaptchaError(error)
Expand Down
2 changes: 1 addition & 1 deletion epsilion_wars_mmorpg_automation/captcha/simple_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def simple_grammar(message: str, *_: Any) -> str | None:

found_word_pattern = found.group('question').replace('*', '.').strip().lower()
found_word_pattern = replace_eng_chars(found_word_pattern)
logging.debug(f'grammar captcha resolver: {found_word_pattern=}')
logging.debug('grammar captcha resolver: {0}'.format(found_word_pattern))

for answer in _words:
if re.match(found_word_pattern, answer):
Expand Down
2 changes: 1 addition & 1 deletion epsilion_wars_mmorpg_automation/game/action/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def ping(entity: int | events.NewMessage.Event) -> None:
message = random.choice(
seq=app_settings.ping_commands,
)
logging.info(f'call ping command debug {game_bot_id=} {message=}')
logging.info(f'call ping command debug {game_bot_id} {message}')
await wait_for()
await client.send_message(
entity=game_bot_id,
Expand Down
17 changes: 14 additions & 3 deletions epsilion_wars_mmorpg_automation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
import os
from typing import Literal

from pydantic import BaseSettings, Field
from pydantic import Field
from pydantic_settings import BaseSettings

APP_PATH = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'..',
),
)


class AppSettings(BaseSettings):
Expand All @@ -22,7 +30,10 @@ class AppSettings(BaseSettings):
captcha_solver_enabled: bool = True

select_combo_strategy: Literal['simple', 'random', 'random-or-skip', 'disabled', 'tuned', 'priority'] = 'simple'
skip_combo_chance: int = Field(default=30, description='Chance to skip combo bite if `random-or-skip` strategy selected')
skip_combo_chance: int = Field(
default=30,
description='Chance to skip combo bite if `random-or-skip` strategy selected',
)

skip_random_vendor: bool = True
skip_random_vendor_stop_words: str = 'Свиток Кселеса,Безопасный свиток заточки [IV]'
Expand Down Expand Up @@ -178,7 +189,7 @@ class AppSettings(BaseSettings):


app_settings = AppSettings(
_env_file=os.path.join(os.path.dirname(__file__), '..', '.env'),
_env_file=os.path.join(APP_PATH, '.env'), # type: ignore
)

game_bot_name = app_settings.game_username_backup if app_settings.use_backup_game_bot else app_settings.game_username
2 changes: 1 addition & 1 deletion epsilion_wars_mmorpg_automation/trainer/captcha_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def main() -> None:
'captcha_solver_enabled': app_settings.captcha_solver_enabled,
'anti_captcha_enabled': bool(app_settings.anti_captcha_com_apikey),
}
logging.info(f'start captcha-solver ({local_settings=})')
logging.info('start captcha-solver ({0})'.format(local_settings))

if not app_settings.captcha_solver_enabled:
logging.warning('Enable captcha_solver_enabled setting first')
Expand Down
2 changes: 1 addition & 1 deletion epsilion_wars_mmorpg_automation/trainer/farming.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def main(repair_locations_path: str = '') -> None:
'repair_locations_path': app_settings.repair_locations_path,
}
repair_locations_path = repair_locations_path or app_settings.repair_locations_path
logging.info(f'start farming ({local_settings=}), {repair_locations_path}')
logging.info(f'start farming ({local_settings}), {repair_locations_path}')

shared_state.REPAIR_LOCATIONS_PATH = repair_locations_path.split(',')

Expand Down
2 changes: 1 addition & 1 deletion epsilion_wars_mmorpg_automation/trainer/grinding.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def main(execution_limit_minutes: int | None = None) -> None:
'notifications_enabled': app_settings.notifications_enabled,
'slow_mode': app_settings.slow_mode,
}
logging.info(f'start grinding ({local_settings=})')
logging.info('start grinding ({0})'.format(local_settings))
logging.info('move u character to hunting location first')

me = await client.get_me()
Expand Down
2 changes: 1 addition & 1 deletion epsilion_wars_mmorpg_automation/trainer/handlers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from epsilion_wars_mmorpg_automation.trainer import loop


async def skip_turn_handler(event: events.NewMessage.Event) -> None:
async def skip_turn_handler(_: events.NewMessage.Event) -> None:
"""Just skip event."""
logging.info('skip event')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async def fishing_start(event: events.NewMessage.Event) -> None:
logging.info('start fishing event')
response = await action.fishing_actions.select_fishing_type(event)
if response:
logging.info(f'{response.message=}')
logging.info(f'{response.message}')
if state.fishing_states.is_rod_equip_needed(response.message):
await action.common_actions.show_equip(event)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async def hunting_start(event: events.NewMessage.Event) -> None:
logging.info('start hunting event')
response = await action.hunting_actions.select_hunt_type(event)
if response:
logging.info(f'{response.message=}')
logging.info(f'{response.message}')
if state.hunting_states.is_bow_equip_needed(response.message):
await action.common_actions.show_equip(event)

Expand Down
2 changes: 1 addition & 1 deletion epsilion_wars_mmorpg_automation/wait_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class WaitActions(enum.Enum):


async def wait_for(timing: WaitActions = WaitActions.COMMON) -> None:
"""Lets wait like human =)."""
"""Let wait like human."""
min_seconds, max_seconds, min_slow_mode, max_slow_mode = timing.value
if app_settings.slow_mode:
sleep_time = random.randint(min_slow_mode, max_slow_mode)
Expand Down
38 changes: 0 additions & 38 deletions etc/tdata_converter.py

This file was deleted.

Loading

0 comments on commit 4ae6c52

Please sign in to comment.