Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- coding: utf-8 -*-
import re
import os
import logging
from colored import fore, back, style
STY_DESC = fore.LIGHT_GREEN + back.BLACK
STY_DESC_DEBUG = fore.SKY_BLUE_1 + back.BLACK + style.DIM
STY_USER = style.RESET + fore.WHITE + back.BLACK
STY_CURSOR = fore.LIGHT_GOLDENROD_2B + back.BLACK + style.BOLD
STY_RESP = fore.WHITE + back.MEDIUM_VIOLET_RED + style.BOLD
STY_RECIPIENT = fore.WHITE + back.DODGER_BLUE_2 + style.BOLD
# STY_RESP = fore.WHITE + back.GREY_11 + style.BOLD #+ style.NORMAL
STY_EMAIL = fore.WHITE + back.GREY_11 + style.BOLD
def setup_custom_logger(name):
formatter = logging.Formatter(
STY_DESC_DEBUG + '%(asctime)s - %(module)s - %(levelname)8s - %(message)s' +
style.RESET, datefmt='%Y-%b-%d %H:%M:%S')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
LC_USER_FILTER = ['XXXXX']
LC_BASE_URL = 'http://localhost:8080/rooms/base'
LC_POLLING_TIME = 1
TAGGED_OUTPUT_FILE = os.path.abspath(os.path.join('data', 'base_tagged.txt'))
EMAIL_OUTPUT_FILE = os.path.abspath(os.path.join('data', 'base_email.txt'))
# -----------------------
# END OF CUSTOMISED ITEMS
# -----------------------
CHANNEL_IN = 'screen' # 'email' OR 'screen' OR 'online'
CHANNELS_OUT = {'email': False, 'online': False, 'screen': True}
STY_DESC = fore.LIGHT_GREEN + back.BLACK
STY_DESC_DEBUG = fore.SKY_BLUE_1 + back.BLACK + style.DIM
STY_HELP = fore.DARK_SLATE_GRAY_3 + back.BLACK
STY_HIDDEN = fore.BLACK + back.BLACK
STY_USER = style.RESET + fore.WHITE + back.BLACK
STY_CURSOR = fore.LIGHT_GOLDENROD_2B + back.BLACK + style.BOLD
STY_RESP = fore.WHITE + back.MEDIUM_VIOLET_RED + style.BOLD
# STY_RESP = fore.WHITE + back.GREY_11 + style.BOLD #+ style.NORMAL
STY_EMAIL = fore.WHITE + back.GREY_11 + style.BOLD
STY_RESP_SPECIAL = fore.WHITE + back.LIGHT_GOLDENROD_2B + style.BOLD
STY_HIGHLIGHT = fore.DEEP_PINK_4C + back.BLACK
STY_DRAW = fore.WHITE + back.BLACK + style.BOLD
logger = logging.getLogger(BOTNAME)
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.WARN)
# ch.setLevel(logging.DEBUG)
# see a full list of color codes: https://gitlab.com/dslackw/colored
if p_length >= break_point:
sys.stderr.write(back.CYAN + fore.BLACK + c[:break_point] + \
back.GREY_30 + fore.WHITE + c[break_point:end_point] + \
back.CYAN + fore.CYAN + c[end_point] + \
back.GREY_50 + fore.LIGHT_CYAN + c[end_point:] + \
style.RESET)
else:
sys.stderr.write(back.CYAN + fore.BLACK + c[:break_point - p_length] + \
back.SALMON_1 + fore.BLACK + p_text + \
back.GREY_30 + fore.WHITE + c[break_point:end_point] + \
back.GREY_50 + fore.LIGHT_CYAN + c[end_point:] + \
style.RESET)
sys.stderr.flush()
else:
sys.stderr.write(back.CYAN + fore.BLACK + c + style.RESET)
sys.stderr.flush()