From a84b8615e82340283cc91ea771ece4cf5df5c886 Mon Sep 17 00:00:00 2001 From: Artur Galyamov Date: Wed, 21 Dec 2022 09:42:09 +0500 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=B5=D1=81=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=B2=D1=81=D0=B5=20=D0=BB=D0=B8=D1=87=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=B2=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20#19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- cms/promoters.py | 7 +++---- crossposting_backend/settings.py | 14 ++------------ 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 310e716..0af966a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ db.sqlite3 .env __pycache__/ identifier.sqlite -vk_config.v2.json \ No newline at end of file +vk_config.v2.json +crossposting_backend/private_settings.py \ No newline at end of file diff --git a/cms/promoters.py b/cms/promoters.py index f94d880..3e2dd0e 100644 --- a/cms/promoters.py +++ b/cms/promoters.py @@ -21,14 +21,13 @@ class Promoter(abc.ABC): class TelegramPromoter(Promoter): def promote(self): - bot_token = os.getenv('TELEGRAM_BOT_TOKEN') - channel_id = os.getenv('TELEGRAM_CHAT_ID') + from crossposting_backend.private_settings import BOT_TOKEN, CHANNEL_ID long_text = f'{self.article.body}\n{self.article.link}' - querystring = (('chat_id', channel_id), ('text', long_text)) + querystring = (('chat_id', CHANNEL_ID), ('text', long_text)) encoded_querystring = urlencode(querystring) - send_message_url = f'https://api.telegram.org/bot{bot_token}/sendMessage?{encoded_querystring}' + send_message_url = f'https://api.telegram.org/bot{BOT_TOKEN}/sendMessage?{encoded_querystring}' response = requests.get(send_message_url) result = response.json() diff --git a/crossposting_backend/settings.py b/crossposting_backend/settings.py index 27efb74..32908c2 100644 --- a/crossposting_backend/settings.py +++ b/crossposting_backend/settings.py @@ -10,27 +10,17 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.1/ref/settings/ """ -from pathlib import Path -from os import path -import dotenv + +from .private_settings import * # Build paths inside the project like this: BASE_DIR / 'subdir'. from django.urls import reverse -BASE_DIR = Path(__file__).resolve().parent.parent -env_file = path.join(BASE_DIR, '.env') -dotenv.read_dotenv(env_file) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-kwt7g7603)dmr(3r0*a-@ctj(id0*sm4x0jv8gu5h0_r)#!(tg' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - ALLOWED_HOSTS = [] LOGIN_URL = '/cms/'