xMistt / fortnitepy-bot

A Fortnite HTTP/XMPP bot coded in Python with party capabilities.
https://partybot.net
Other
358 stars 364 forks source link

Rewrite #184

Closed AtieP closed 4 years ago

AtieP commented 4 years ago

Please, rewrite this. This is both a mess and inconsistent. You use colored prints instead of coloredlogs. You put everything on a single file and the result is a messy 2000 liner file. Create a new folder. Make a new file with the bot class. Then another __main__.py file that runs the bot as a module. Make a new folder with extensions there. Then load them from the __main__.py. It's for your and our sanity.

xMistt commented 4 years ago

I'm using crayons as I want the print text to be colored, it isn't meant for logging at all.

AtieP commented 4 years ago

You can use coloredlogs for colored logging. Note that you need to install colorama if you are using Windows.


import logging
import sys

import coloredlogs

format = "%(asctime)s | %(name)s | %(levelname)s | %(message)s"
root_logger = logging.getLogger()

coloredlogs.DEFAULT_LOG_FORMAT = format
coloredlogs.DEFAULT_LOG_LEVEL = logging.DEBUG
coloredlogs.install(logger=root_logger, stream=sys.stdout)

# Set log level to WARNING to all internal loggers
logging.getLogger("aiosasl").setLevel(logging.WARNING)
logging.getLogger("aioxmpp").setLevel(logging.WARNING)
logging.getLogger("asyncio").setLevel(logging.WARNING)
logging.getLogger("fortnitepy").setLevel(logging.WARNING)

# Use this logger for logging.
logger = logging.getLogger(__name__)```
xMistt commented 4 years ago

Happy now?

AtieP commented 4 years ago

Wow, this is better. Now the bot is modular and it's easier to read.