mirror of
https://wiilab.wiimart.org/wiimart/WiiMartBot
synced 2025-09-03 20:11:08 +02:00
added modifications
This commit is contained in:
parent
0b10c84f90
commit
21ee8b290e
11
bot.py
11
bot.py
@ -8,6 +8,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
|
import sys
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from mysql.connector import Error
|
from mysql.connector import Error
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
@ -19,7 +20,7 @@ class ColoredFormatter(logging.Formatter):
|
|||||||
"""Adds colors to log levels"""
|
"""Adds colors to log levels"""
|
||||||
COLORS = {
|
COLORS = {
|
||||||
'DEBUG': Fore.CYAN,
|
'DEBUG': Fore.CYAN,
|
||||||
'INFO': Fore.GREEN,
|
'INFO': Fore.BLUE,
|
||||||
'WARNING': Fore.YELLOW,
|
'WARNING': Fore.YELLOW,
|
||||||
'ERROR': Fore.RED,
|
'ERROR': Fore.RED,
|
||||||
'CRITICAL': Fore.RED + Style.BRIGHT
|
'CRITICAL': Fore.RED + Style.BRIGHT
|
||||||
@ -33,10 +34,10 @@ class ColoredFormatter(logging.Formatter):
|
|||||||
|
|
||||||
# Your original config with colors added
|
# Your original config with colors added
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.DEBUG,
|
||||||
format='%(levelname)s at %(asctime)s : %(message)s',
|
format='%(levelname)s at %(asctime)s : %(message)s',
|
||||||
datefmt='%H:%M:%S',
|
datefmt='%H:%M:%S',
|
||||||
handlers=[logging.StreamHandler()]
|
handlers=[logging.StreamHandler(sys.stderr)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Apply the colored formatter
|
# Apply the colored formatter
|
||||||
@ -110,7 +111,7 @@ class LeaderElection:
|
|||||||
try:
|
try:
|
||||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||||
s.settimeout(TIMEOUT)
|
s.settimeout(TIMEOUT)
|
||||||
s.connect((TAILSCALE_IP1, LOCK_PORT))
|
s.connect((TAILSCALE_IP2, LOCK_PORT))
|
||||||
return True
|
return True
|
||||||
except (ConnectionRefusedError, socket.timeout, OSError):
|
except (ConnectionRefusedError, socket.timeout, OSError):
|
||||||
return False
|
return False
|
||||||
@ -130,7 +131,7 @@ def health_check(leader_election):
|
|||||||
try:
|
try:
|
||||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||||
s.settimeout(TIMEOUT)
|
s.settimeout(TIMEOUT)
|
||||||
s.connect((TAILSCALE_IP2, LOCK_PORT))
|
s.connect((TAILSCALE_IP1, LOCK_PORT))
|
||||||
except:
|
except:
|
||||||
# Lost leadership
|
# Lost leadership
|
||||||
#print("Lost leadership")
|
#print("Lost leadership")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user