ещё фиксы форматирования
This commit is contained in:
12
news-bot.py
12
news-bot.py
@@ -35,7 +35,7 @@ params_get = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
handler = colorlog.StreamHandler()
|
handler = colorlog.StreamHandler()
|
||||||
handler.setFormatter(colorlog.ColoredFormatter(
|
handler.setFormatter(colorlog.ColoredFormatter(
|
||||||
@@ -83,12 +83,14 @@ def html_to_text(html_content):
|
|||||||
# Убираем переносы строк внутри квадратных скобок []
|
# Убираем переносы строк внутри квадратных скобок []
|
||||||
markdown_text = re.sub(r'\[(.*?)\]', lambda x: '[' + x.group(1).replace('\n', ' ') + ']', markdown_text, flags=re.DOTALL)
|
markdown_text = re.sub(r'\[(.*?)\]', lambda x: '[' + x.group(1).replace('\n', ' ') + ']', markdown_text, flags=re.DOTALL)
|
||||||
|
|
||||||
# Удаление переносов строк и пробелов внутри текста
|
# # Удаление переносов строк и пробелов внутри текста
|
||||||
markdown_text = re.sub(r'(?<!\n)\n(?!\n)', ' ', markdown_text)
|
# markdown_text = re.sub(r'(?<!\n)\n(?!\n)', ' ', markdown_text)
|
||||||
|
|
||||||
# Удаление строк, содержащих '* * *'
|
# Удаление строк, содержащих '* * *'
|
||||||
markdown_text = re.sub(r'^.*\* \* \*.*$', '', markdown_text, flags=re.MULTILINE)
|
markdown_text = re.sub(r'^.*\* \* \*.*$', '', markdown_text, flags=re.MULTILINE)
|
||||||
|
|
||||||
|
markdown_text = re.sub(r'^.*\*', '*', markdown_text, flags=re.MULTILINE)
|
||||||
|
|
||||||
# Работа с #
|
# Работа с #
|
||||||
patterns_to_remove = [
|
patterns_to_remove = [
|
||||||
r'###',
|
r'###',
|
||||||
@@ -167,7 +169,7 @@ def script_content(script_ver, resp_changelog):
|
|||||||
|
|
||||||
if index_script_ver != -1:
|
if index_script_ver != -1:
|
||||||
changelog_text = changelog_text_last[index_script_ver:]
|
changelog_text = changelog_text_last[index_script_ver:]
|
||||||
post_text = (f"-----------------------------\nОбновление скриптов {script_ver}\t\n") + changelog_text
|
post_text = (f"-----------------------------\n") + changelog_text
|
||||||
site_text = (f"[center][img]/uploads/default/original/1X/5cfa59077a5275971401fab0114e56f3ffdd0ec4.png[/img]["
|
site_text = (f"[center][img]/uploads/default/original/1X/5cfa59077a5275971401fab0114e56f3ffdd0ec4.png[/img]["
|
||||||
f"/center]\n{post_text}")
|
f"/center]\n{post_text}")
|
||||||
|
|
||||||
@@ -349,7 +351,7 @@ def check_discord_public():
|
|||||||
for topic_id, topic_title in reversed(list_for_public):
|
for topic_id, topic_title in reversed(list_for_public):
|
||||||
text_data = news_content(topic_id)
|
text_data = news_content(topic_id)
|
||||||
if text_data:
|
if text_data:
|
||||||
content = f"----------------------------------------------------------\n### {topic_title}\t\n" + text_data + "\n" + "@here"
|
content = f"----------------------------------------------------------\n### {topic_title}\t\n" + text_data + "\n"
|
||||||
# Разбиваем содержимое на части по 4000 символов
|
# Разбиваем содержимое на части по 4000 символов
|
||||||
for i in range(0, len(content), 2000):
|
for i in range(0, len(content), 2000):
|
||||||
await channel.send(content[i:i+2000])
|
await channel.send(content[i:i+2000])
|
||||||
|
Reference in New Issue
Block a user