Browse Source

Вынесены все личные настройки в отдельный модуль #19

pull/32/head
Artur Galyamov 2 years ago
parent
commit
a84b8615e8
  1. 3
      .gitignore
  2. 7
      cms/promoters.py
  3. 14
      crossposting_backend/settings.py

3
.gitignore vendored

@ -4,4 +4,5 @@ db.sqlite3
.env
__pycache__/
identifier.sqlite
vk_config.v2.json
vk_config.v2.json
crossposting_backend/private_settings.py

7
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()

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

Loading…
Cancel
Save