This commit is contained in:
user committed 2024-04-05 16:01:15 +03:00
1 parent c90ce0fc70
commit c485bd27e3
6 files changed
+86 -9

No files matched your search

+4
View File
@@ -17,6 +17,10 @@ TELEGRAM_API_KEY = os.environ.get('TELEGRAM_API_KEY')
assert TELEGRAM_API_KEY, "Telegram API_KEY required"
CLIENT_TELEGRAM_API_KEY = os.environ.get('CLIENT_TELEGRAM_API_KEY')
assert CLIENT_TELEGRAM_API_KEY, "Client Telegram API_KEY required"
import httpx
TELEGRAM_BOT_USERNAME = httpx.get(f"https://api.telegram.org/bot{TELEGRAM_API_KEY}/getMe").json()['result']['username']
CLIENT_TELEGRAM_BOT_USERNAME = httpx.get(f"https://api.telegram.org/bot{CLIENT_TELEGRAM_API_KEY}/getMe").json()['result']['username']
MYSQL_URI = os.environ['MYSQL_URI']
MYSQL_DATABASE = os.environ['MYSQL_DATABASE']
+11 -1
View File
@@ -2,7 +2,7 @@ from app.core.models.node_storage import StoredContent
from app.core.models.content.user_content import UserContent
from app.core.logger import make_log
from app.core._utils.tg_process_template import tg_process_template
from app.core._config import PROJECT_HOST
from app.core._config import PROJECT_HOST, CLIENT_TELEGRAM_BOT_USERNAME
from app.core._keyboards import get_inline_keyboard
from aiogram.types import URLInputFile
import json
@@ -66,6 +66,16 @@ class PlayerTemplates:
if cover_content:
template_kwargs['thumbnail'] = URLInputFile(cover_content.web_url)
if self.bot_id == 1:
inline_keyboard_array.append([{
'text': self.user.translated('shareTrack_button'),
'switch_inline_query': f"C{content.cid.serialize_v2()}"
}])
else:
inline_keyboard_array.append([{
'text': self.user.translated('viewTrackAsClient_button'),
'url': f"https://t.me/{CLIENT_TELEGRAM_BOT_USERNAME}?start=C{content.telegram_cid}"
}])
else:
local_content = None
+3 -2
View File
@@ -42,7 +42,7 @@ class Wrapped_CBotChat(T, PlayerTemplates):
CLIENT_TELEGRAM_API_KEY: 1
}[self._bot_key]
async def return_result(self, result, message_type='common', message_meta={}):
async def return_result(self, result, message_type='common', message_meta={}, content_id=None, **kwargs):
if self.db_session:
if message_type == 'common':
ci = 0
@@ -71,7 +71,8 @@ class Wrapped_CBotChat(T, PlayerTemplates):
message_id=message_id,
from_user=False,
created=datetime.now(),
meta=message_meta or {}
meta=message_meta or {},
content_id=content_id
)
)
self.db_session.commit()