Вынесены все личные настройки в отдельный модуль #19
This commit is contained in:
parent
765bcab97d
commit
a84b8615e8
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,4 +4,5 @@ db.sqlite3
|
|||||||
.env
|
.env
|
||||||
__pycache__/
|
__pycache__/
|
||||||
identifier.sqlite
|
identifier.sqlite
|
||||||
vk_config.v2.json
|
vk_config.v2.json
|
||||||
|
crossposting_backend/private_settings.py
|
@ -21,14 +21,13 @@ class Promoter(abc.ABC):
|
|||||||
|
|
||||||
class TelegramPromoter(Promoter):
|
class TelegramPromoter(Promoter):
|
||||||
def promote(self):
|
def promote(self):
|
||||||
bot_token = os.getenv('TELEGRAM_BOT_TOKEN')
|
from crossposting_backend.private_settings import BOT_TOKEN, CHANNEL_ID
|
||||||
channel_id = os.getenv('TELEGRAM_CHAT_ID')
|
|
||||||
|
|
||||||
long_text = f'{self.article.body}\n{self.article.link}'
|
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)
|
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)
|
response = requests.get(send_message_url)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
@ -10,27 +10,17 @@ For the full list of settings and their values, see
|
|||||||
https://docs.djangoproject.com/en/4.1/ref/settings/
|
https://docs.djangoproject.com/en/4.1/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
from os import path
|
from .private_settings import *
|
||||||
import dotenv
|
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
from django.urls import reverse
|
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
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
|
# 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 = []
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
LOGIN_URL = '/cms/'
|
LOGIN_URL = '/cms/'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user