You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.0 KiB
Python
78 lines
2.0 KiB
Python
"""
|
|
BOT configuration.
|
|
"""
|
|
import logging.config as logger
|
|
import os
|
|
|
|
from sqlalchemy import create_engine
|
|
|
|
# Discord token.
|
|
DISCORD_BOT_TOKEN = os.environ.get('DISCORD_BOT_TOKEN')
|
|
|
|
# Mysql configuration.
|
|
MYSQL_CONFIG = {
|
|
'host': os.environ.get('MYSQL_HOST', 'localhost'),
|
|
'port': int(os.environ.get('MYSQL_PORT', '3306')),
|
|
'db': os.environ.get('MYSQL_DATABASE', 'neeble'),
|
|
'user': os.environ.get('MYSQL_USER', 'neeble'),
|
|
'password': os.environ.get('MYSQL_PASSWORD', 'neeble'),
|
|
}
|
|
|
|
SQLACHEMY = create_engine(
|
|
'mysql://%s:%s@%s:%s/%s' % (
|
|
os.environ.get('MYSQL_USER', 'neeble'),
|
|
os.environ.get('MYSQL_PASSWORD', 'neeble'),
|
|
os.environ.get('MYSQL_HOST', 'localhost'),
|
|
int(os.environ.get('MYSQL_PORT', '3306')),
|
|
os.environ.get('MYSQL_DATABASE', 'neeble'),
|
|
)
|
|
)
|
|
|
|
# Define the log level
|
|
LOGLEVEL = os.environ.get('LOGLEVEL', 'info').upper()
|
|
|
|
# Logging custom config.
|
|
LOGGING_CONFIG = {
|
|
'version': 1,
|
|
'disable_existing_loggers': False,
|
|
'formatters': {
|
|
'default': {
|
|
'format': '[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s',
|
|
},
|
|
},
|
|
'handlers': {
|
|
'console': {
|
|
'level': LOGLEVEL,
|
|
'class': 'logging.StreamHandler',
|
|
'formatter': 'default',
|
|
},
|
|
'logfile': {
|
|
'level': LOGLEVEL,
|
|
'class': 'logging.handlers.RotatingFileHandler',
|
|
'filename': '/tmp/neeble.log',
|
|
'maxBytes': 50000,
|
|
'backupCount': 9,
|
|
'formatter': 'default',
|
|
},
|
|
},
|
|
'loggers': {
|
|
'': {
|
|
'level': LOGLEVEL,
|
|
'handlers': ['console', 'logfile'],
|
|
'propagate': False,
|
|
},
|
|
'neeble': {
|
|
'level': LOGLEVEL,
|
|
'handlers': ['console', 'logfile'],
|
|
'propagate': False,
|
|
},
|
|
},
|
|
}
|
|
|
|
PERMISSIONS = {
|
|
'dq' : ['O emissário', 'BotMan'],
|
|
'v' : ['Operador']
|
|
}
|
|
|
|
logger.dictConfig(LOGGING_CONFIG)
|