ocd
This commit is contained in:
parent
4b1b508be9
commit
78b97a42a6
1 changed files with 17 additions and 13 deletions
|
@ -18,7 +18,7 @@ from .helpers import configure_logging
|
||||||
def main():
|
def main():
|
||||||
root = Path(os.getcwd())
|
root = Path(os.getcwd())
|
||||||
# TODO would be cool if it was possible to configure addons path, but we need to load addons before doing argparse so we can do helptext
|
# TODO would be cool if it was possible to configure addons path, but we need to load addons before doing argparse so we can do helptext
|
||||||
# addon_path = Path(args.addon_path) if args.addon_path else ( root/'addons' )
|
# addon_path = Path(args.path) if args.addon_path else ( root/'addons' )
|
||||||
addon_path = root/'addons'
|
addon_path = root/'addons'
|
||||||
addons : List[Type[Addon]] = []
|
addons : List[Type[Addon]] = []
|
||||||
|
|
||||||
|
@ -30,11 +30,14 @@ def main():
|
||||||
addons.append(obj)
|
addons.append(obj)
|
||||||
|
|
||||||
class ChatLogger(Addon):
|
class ChatLogger(Addon):
|
||||||
"""This addon will print (optionally colored) game chat to terminal"""
|
"""print (optionally colored) game chat to terminal"""
|
||||||
REMOVE_COLOR_FORMATS = re.compile(r"§[0-9a-z]")
|
REMOVE_COLOR_FORMATS = re.compile(r"§[0-9a-z]")
|
||||||
@dataclass
|
@dataclass
|
||||||
class Options(ConfigObject):
|
class Options(ConfigObject):
|
||||||
|
test : str
|
||||||
|
something : int
|
||||||
color : bool = True
|
color : bool = True
|
||||||
|
blah : str = 'porcodio'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -45,6 +48,7 @@ def main():
|
||||||
addons.append(ChatLogger)
|
addons.append(ChatLogger)
|
||||||
|
|
||||||
class ChatInput(Addon):
|
class ChatInput(Addon):
|
||||||
|
"""read input from stdin and send to game chat"""
|
||||||
task : asyncio.Task
|
task : asyncio.Task
|
||||||
running : bool
|
running : bool
|
||||||
|
|
||||||
|
@ -74,8 +78,8 @@ def main():
|
||||||
|
|
||||||
help_text = '\n\naddons:\n' + str.join( # TODO do this iteratively to make it readable!
|
help_text = '\n\naddons:\n' + str.join( # TODO do this iteratively to make it readable!
|
||||||
'\n', (
|
'\n', (
|
||||||
f" {addon.__name__}: {addon.__doc__ or '-no description-'}\n " + str.join('\n ',
|
f" {addon.__name__}\t\t{addon.__doc__ or '-no description-'}\n " + str.join('\n ',
|
||||||
(f"- {name} ({clazz.__name__}) {'[!]' if not hasattr(addon.Options, name) else ''}" for (name, clazz) in get_type_hints(addon.Options).items())
|
(f"* {name} ({clazz.__name__}) {'[required]' if not hasattr(addon.Options, name) else ''}" for (name, clazz) in get_type_hints(addon.Options).items())
|
||||||
) for addon in addons
|
) for addon in addons
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -89,10 +93,10 @@ def main():
|
||||||
|
|
||||||
parser.add_argument('name', help='name to use for this client session')
|
parser.add_argument('name', help='name to use for this client session')
|
||||||
parser.add_argument('server', help='server to connect to')
|
parser.add_argument('server', help='server to connect to')
|
||||||
parser.add_argument('--ms-client-id', dest='client_id', default='c63ef189-23cb-453b-8060-13800b85d2dc', help='Azure application client_id')
|
parser.add_argument('--client-id', dest='cid', default='c63ef189-23cb-453b-8060-13800b85d2dc', help='client_id of your Azure application')
|
||||||
parser.add_argument('--ms-client-secret', dest='client_secret', default='N2e7Q~ybYA0IO39KB1mFD4GmoYzISRaRNyi59', help='Azure application client_secret')
|
parser.add_argument('--secret', dest='secret', default='N2e7Q~ybYA0IO39KB1mFD4GmoYzISRaRNyi59', help='client_secret of your Azure application')
|
||||||
parser.add_argument('--ms-redirect-uri', dest='redirect_uri', default='https://fantabos.co/msauth', help='Azure application redirect_uri')
|
parser.add_argument('--redirect-uri', dest='uri', default='https://fantabos.co/msauth', help='redirect_uri of your Azure application')
|
||||||
parser.add_argument('--addon-path', dest='addon-path', default='', help='Path for loading addons')
|
parser.add_argument('--addon-path', dest='path', default='', help='path for loading addons')
|
||||||
parser.add_argument('--chat-log', dest='chat_log', action='store_const', const=True, default=False, help="print (colored) chat to terminal")
|
parser.add_argument('--chat-log', dest='chat_log', action='store_const', const=True, default=False, help="print (colored) chat to terminal")
|
||||||
parser.add_argument('--chat-input', dest='chat_input', action='store_const', const=True, default=False, help="read input from stdin and send it to chat")
|
parser.add_argument('--chat-input', dest='chat_input', action='store_const', const=True, default=False, help="read input from stdin and send it to chat")
|
||||||
parser.add_argument('--debug', dest='_debug', action='store_const', const=True, default=False, help="enable debug logs")
|
parser.add_argument('--debug', dest='_debug', action='store_const', const=True, default=False, help="enable debug logs")
|
||||||
|
@ -103,16 +107,16 @@ def main():
|
||||||
configure_logging(args.name, level=logging.DEBUG if args._debug else logging.INFO)
|
configure_logging(args.name, level=logging.DEBUG if args._debug else logging.INFO)
|
||||||
setproctitle(f"treepuncher[{args.name}]")
|
setproctitle(f"treepuncher[{args.name}]")
|
||||||
|
|
||||||
code = input(f"-> Go to 'https://fantabos.co/msauth?client_id={args.client_id}&state=hardcoded', click 'Auth' and login, then copy here the code you received\n--> ")
|
code = input(f"-> Go to 'https://fantabos.co/msauth?client_id={args.cid}&state=hardcoded', click 'Auth' and login, then copy here the code you received\n--> ")
|
||||||
|
|
||||||
client = Treepuncher(
|
client = Treepuncher(
|
||||||
args.name,
|
args.name,
|
||||||
args.server,
|
args.server,
|
||||||
use_packet_whitelist=use_packet_whitelist,
|
use_packet_whitelist=use_packet_whitelist,
|
||||||
notifier=notifier,
|
notifier=notifier,
|
||||||
client_id=args.client_id,
|
client_id=args.cid,
|
||||||
client_secret=args.client_secret,
|
client_secret=args.secret,
|
||||||
redirect_uri="https://fantabos.co/msauth"
|
redirect_uri=args.uri
|
||||||
)
|
)
|
||||||
|
|
||||||
for addon in addons:
|
for addon in addons:
|
||||||
|
|
Loading…
Reference in a new issue