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/'