Move tokens
This commit is contained in:
parent
cf3812da42
commit
1b230ea56f
|
@ -6,6 +6,8 @@ import httpx
|
|||
from mastodon import Mastodon
|
||||
from nio import AsyncClient, MatrixRoom, RoomMessageText
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def run_in_thread(fn):
|
||||
def run(*k, **kw):
|
||||
|
@ -16,11 +18,12 @@ def run_in_thread(fn):
|
|||
|
||||
|
||||
def public_social(message, cartel):
|
||||
|
||||
path_cartel = cartel.url
|
||||
_public_telegram(message, path_cartel)
|
||||
return
|
||||
|
||||
|
||||
def public_mastodon(message, cartel):
|
||||
def _public_mastodon(message, cartel):
|
||||
MT = {
|
||||
'jpg': 'image/jpeg',
|
||||
'png': 'image/png',
|
||||
|
@ -33,22 +36,25 @@ def public_mastodon(message, cartel):
|
|||
access_token=settings.TOKEN_MASTODON,
|
||||
api_base_url=settings.URL_MASTODON)
|
||||
|
||||
media = server.media_post(cartel.read(), media_type)
|
||||
media = server.media_post(cartel, media_type)
|
||||
server.status_post(message, media_ids=media)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return
|
||||
|
||||
|
||||
def public_telegram(message, cartel):
|
||||
url = f'https://api.telegram.org/bot{settings.TOKEN_TELEGRAM}/sendPhoto'
|
||||
url_cartel = settings.URL_CDN.format(cartel)
|
||||
data = {'chat_id': settings.CHAT_ID, 'photo': url_cartel, 'caption': message}
|
||||
def _public_telegram(message, path_image):
|
||||
TOKEN = settings.TOKENS['TELEGRAM']['TOKEN']
|
||||
ID_CHAT = settings.TOKENS['TELEGRAM']['ID_CHAT']
|
||||
|
||||
url = f'https://api.telegram.org/bot{TOKEN}/sendPhoto'
|
||||
url_cartel = settings.URL_CDN.format(path_image)
|
||||
data = {'chat_id': ID_CHAT, 'photo': url_cartel, 'caption': message}
|
||||
result = httpx.post(url, data=data).json()
|
||||
print(result)
|
||||
return
|
||||
|
||||
|
||||
def public_matrix():
|
||||
|
||||
return
|
||||
|
||||
|
||||
def _public_matrix():
|
||||
|
||||
return
|
||||
|
|
|
@ -17,10 +17,8 @@ from .conf import (
|
|||
DEBUG,
|
||||
DEFAULT_DB,
|
||||
SECRET_KEY,
|
||||
TOKEN_MASTODON,
|
||||
TOKEN_TELEGRAM,
|
||||
CHAT_ID,
|
||||
API_TOKEN,
|
||||
TOKENS,
|
||||
)
|
||||
|
||||
|
||||
|
@ -32,7 +30,7 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
|
|||
MEDIA_URL = 'media/'
|
||||
|
||||
|
||||
ALLOWED_HOSTS = ['mauflix.elmau.net', 'elmau.net']
|
||||
ALLOWED_HOSTS = ['mauflix.club']
|
||||
if DEBUG:
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
|
@ -142,5 +140,5 @@ SESSION_COOKIE_AGE = 3600
|
|||
|
||||
|
||||
# ~ URL_CDN = 'https://sos-ch-dk-2.exo.io/mauflix/{}/{}'
|
||||
URL_CDN = 'https://mauflix.elmau.net/{}'
|
||||
URL_CDN = 'https://mauflix.club/{}'
|
||||
URL_MASTODON = 'https://mstdn.mx/'
|
||||
|
|
Loading…
Reference in New Issue