telegram warning message if PK not found

This commit is contained in:
Dobromir Popov 2024-10-09 11:57:19 +03:00
parent 71e4681d60
commit 4f4ec03f97

View File

@ -57,21 +57,7 @@ error_logger = logging.getLogger('error_logger')
error_logger.setLevel(logging.ERROR)
error_logger.addHandler(error_file_handler)
pk = os.getenv("PK")
if not pk:
try:
with open('./crypto/sol/secret.pk', 'r') as f:
pk = f.read().strip()
if pk:
logging.info("Private key loaded successfully from file.")
else:
logging.warning("Private key file is empty.")
except FileNotFoundError:
logging.warning("Private key file not found.")
except Exception as e:
logging.error(f"Error reading private key file: {str(e)}")
if not pk:
logging.error("Private key not found in environment variables. Will not be able to sign transactions.")
app = Flask(__name__)
@ -1169,6 +1155,24 @@ async def subscribe_to_wallet():
pk = os.getenv("PK")
if not pk:
try:
with open('./crypto/sol/secret.pk', 'r') as f:
pk = f.read().strip()
if pk:
logging.info("Private key loaded successfully from file.")
else:
logging.warning("Private key file is empty.")
except FileNotFoundError:
logging.warning("Private key file not found.")
except Exception as e:
logging.error(f"Error reading private key file: {str(e)}")
if not pk:
logging.error("Private key not found in environment variables. Will not be able to sign transactions.")
# send TG warning message
send_telegram_message("<b>Warning:</b> Private key not found in environment variables. Will not be able to sign transactions.")
async def main():
# Initialize logging