-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.py
More file actions
60 lines (41 loc) · 1.58 KB
/
App.py
File metadata and controls
60 lines (41 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from LoggerPackage import Logger as TibiaAcBotLogger
from ScreenAnalizerPackage.Shared.Screen import Screen
from ScreenAnalizerPackage.Stats.Stat import Stat
from CaveBot.CaveBot import CaveBot
from CaveBot.AutoTrainner import AutoTrainner
from dotenv import load_dotenv
import argparse
class TibiaAcBot:
@staticmethod
def init():
try:
TibiaAcBot.setup_global()
training_mode = TibiaAcBot.collect_program_arguments()
TibiaAcBotLogger.info('Started...')
TibiaAcBotLogger.info('Press Ctrl+C to stop the execution')
if training_mode:
AutoTrainner().train()
raise SystemExit
cave_bot = CaveBot()
cave_bot.start()
except KeyboardInterrupt:
TibiaAcBotLogger.info('Graceful shutdown')
raise SystemExit
except Exception as error:
TibiaAcBotLogger.error(str(error), error)
raise SystemExit from error
@staticmethod
def setup_global() -> None:
TibiaAcBotLogger.info('Setting env...')
load_dotenv()
Screen.setup_global_variables()
Stat.setup_global_variables()
@staticmethod
def collect_program_arguments() -> bool:
TibiaAcBotLogger.info('Collecting program arguments...')
parser = argparse.ArgumentParser()
parser.add_argument('--train', action="store_true", help='Indicate that program should start in training mode')
if parser.parse_args() and parser.parse_args().train:
return True
return False
TibiaAcBot().init()