Skip to content

Commit

Permalink
modified generate/bot-generate.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Asker Kakhramanov committed Feb 25, 2024
1 parent 9ba10e0 commit d5144c4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion generate/bot-generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from prometheus_client import start_http_server, Counter, Gauge
import logging

logging.basicConfig(level=logging.INFO, format='%(name)s - %(levelname)s - %(message)s')
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

bot=telebot.TeleBot(os.environ.get('generate_bot'))

Expand All @@ -21,6 +22,7 @@ def escape_markdown(text):
Функция для экранирования специальных символов в тексте для форматирования MarkdownV2.
"""
escape_chars = r'_*[]()~`>#+-=|{}.!' # Список символов, которые необходимо экранировать
logger.info('def escape_markdown. Escaping markdown for text: %s', text)
LAST.set_to_current_time()
return ''.join('\\' + char if char in escape_chars else char for char in text)

Expand All @@ -43,6 +45,7 @@ def generate_nickname(message):
adjective = random.choice(adjectives)
animal = random.choice(animals)
nickname = f'{adjective}_{animal}'
logger.info('def generate_nickname. Escaping markdown for text: %s', nickname)
bot.send_message(message.chat.id, f'Your nickname:\n```\n{nickname}\n```', parse_mode='MarkdownV2')

@bot.message_handler(commands=['generate_password'])
Expand Down

0 comments on commit d5144c4

Please sign in to comment.