logo image, interval intro, try fix search

This commit is contained in:
user 2025-03-06 17:47:01 +03:00
parent 94ecd3234c
commit 0b401e721b
3 changed files with 32 additions and 19 deletions

View File

@ -7,12 +7,12 @@ async def s_api_tonconnect_manifest(request):
return response.json({
"url": f"{PROJECT_HOST}/#from=tonconnect",
"name": "@MY Node",
"iconUrl": "https://github.com/projscale/assets/blob/main/ton-connect.png?raw=true",
"iconUrl": "https://github.com/projscale/my-assets/blob/main/ton-connect.png?raw=true",
})
async def s_api_platform_metadata(request):
return response.json({
"name": "@MY",
"image": "https://git.projscale.dev/my-dev/assets/raw/commit/890ed9e60a25a65c8ad600d6d0ad3ac4480e3039/images/logo.png"
"image": "https://github.com/projscale/my-assets/blob/main/ton-connect.png?raw=true"
})

View File

@ -35,12 +35,14 @@ async def t_callback_purchase_node_content(query: types.CallbackQuery, memory=No
return await query.answer(user.translated('error_contentNotFound'), show_alert=True)
if not is_cancel_request:
make_log("OwnedContent", f"{user} Try to purchase content: {content_oid}", level='info')
# Logging purchase attempt with detailed information
license_price = content.meta.get('license', {}).get('listen', {}).get('price')
license_price_num = int(license_price)
if license_price_num < 1:
return await query.answer(user.translated('error_contentPrice'), show_alert=True)
make_log("Purchase", f"User {user.id} initiated purchase for content ID {content_oid}. License price: {license_price_num}.", level='info')
ton_connect, ton_connection = TonConnect.by_user(db_session, user, callback_fn=())
await ton_connect.restore_connection()
assert ton_connect.connected, "No connected wallet"
@ -72,7 +74,8 @@ async def t_callback_purchase_node_content(query: types.CallbackQuery, memory=No
)
db_session.add(new_action)
else:
make_log("OwnedContent", f"{user} Try to cancel purchase: {content_oid}", level='info')
# Logging cancellation attempt with detailed information
make_log("Purchase", f"User {user.id} cancelled purchase for content ID {content_oid}.", level='info')
action = db_session.query(UserAction).filter_by(
type='purchase',
content_id=content_oid,
@ -92,18 +95,19 @@ router.callback_query.register(t_callback_purchase_node_content, F.data.startswi
async def t_inline_query_node_content(query: types.InlineQuery, memory=None, user=None, db_session=None, chat_wrap=None, **extra):
make_log("OwnedContent", f"Inline query: {query.query}", level='info')
# Logging the received inline query using issuer "InlineSearch"
make_log("InlineSearch", f"Received inline query: '{query.query}'", level='info')
try:
source_args = query.query[1:]
source_args_ext = query.query
if query.query.startswith('Q'):
if source_args.startswith('Q'):
license_onchain_address = query.query[1:]
args = db_session.query(UserContent).filter_by(
onchain_address=license_onchain_address,
).first().content.cid.serialize_v2()
else:
args = query.query[1:]
args = source_args[1:]
cid = ContentId.deserialize(args)
@ -120,7 +124,8 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
with open(metadata_content.filepath, 'r') as f:
metadata_content_json = json.loads(f.read())
except BaseException as e:
make_log("OwnedContent", f"Can't get metadata content: {e}", level='warning')
# Logging metadata retrieval failure with detailed query information
make_log("InlineSearch", f"Failed to retrieve metadata for query '{query.query}': {e}", level='warning')
return await query.answer(content_list, cache_time=1)
audio_title = metadata_content_json.get('name', "").split(' - ')
@ -157,16 +162,16 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
preview_url = preview_content.web_url
if content_type_declared == 'video':
preview_message = await query.bot.send_video(
chat_id=CACHE_CHAT_ID, # Cache chat id defined in configuration
video=types.URLInputFile(preview_url), # Upload video using URL
chat_id=CACHE_CHAT_ID, # English: Cache chat ID defined in configuration
video=types.URLInputFile(preview_url), # English: Upload video using URL
caption="Preview upload", # English caption
supports_streaming=True
)
preview_file_id = preview_message.video.file_id
else:
preview_message = await query.bot.send_audio(
chat_id=CACHE_CHAT_ID, # Cache chat id defined in configuration
audio=types.URLInputFile(preview_url), # Upload audio using URL
chat_id=CACHE_CHAT_ID, # English: Cache chat ID defined in configuration
audio=types.URLInputFile(preview_url), # English: Upload audio using URL
caption="Preview upload", # English caption
title=title,
performer=performer,
@ -180,7 +185,8 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
}
db_session.commit()
except Exception as e:
make_log("OwnedContent", f"Error uploading preview {content_type_declared}: {e}", level='error')
# Logging error during preview upload with detailed content type and query information
make_log("InlineSearch", f"Error uploading preview for content type '{content_type_declared}' during inline query '{query.query}': {e}", level='error')
content_share_link = {
'text': user.translated('p_shareLinkContext').format(title=' '.join(audio_title)),
@ -198,7 +204,7 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
reply_markup=get_inline_keyboard([
[
{
'text': {
'text': {
'audio': user.translated('shareTrack_button'),
'video': user.translated('shareVideo_button'),
}[content_type_declared],
@ -236,7 +242,6 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
'url': f"https://t.me/share/url?text={urllib.parse.quote(content_share_link['text'])}&url={urllib.parse.quote(content_share_link['url'])}"
}
],
[{
'text': user.translated('viewTrack_button'),
'url': f"https://t.me/MY_Web3Bot/content?startapp={source_args}"
@ -245,18 +250,23 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
**result_kwargs
)
)
# Logging the final inline query result count with detailed explanation
make_log("InlineSearch", f"Processed inline query '{query.query}'. Found {len(content_list)} inline result(s) based on query parsing and content retrieval.", level='info')
return await query.answer(content_list, cache_time=1)
except BaseException as e:
logger.error(f"Error in t_inline_query_node_content: {e}")
# Logging exception during inline query processing with detailed query information
make_log("InlineSearch", f"Error processing inline query '{query.query}': {e}", level='error')
traceback.print_exc()
return await query.answer([], cache_time=1)
async def t_chosen_inline_result_node_content(query: types.ChosenInlineResult, memory=None, user=None, db_session=None, chat_wrap=None, **extra):
make_log("OwnedContent", f"Chosen inline result: {query.result_id}", level='info')
# Logging chosen inline result with detailed user and result ID
make_log("ChosenResult", f"User {user.id} selected inline result with ID '{query.result_id}'.", level='info')
# return await query.answer([])
router.inline_query.register(t_inline_query_node_content, F.query.startswith('C') | F.query.startswith('Q'))
router.inline_query.register(t_inline_query_node_content, F.query.startswith('C'))
router.inline_query.register(t_inline_query_node_content, F.query.startswith('Q'))
router.chosen_inline_result.register(t_chosen_inline_result_node_content, lambda: True)

View File

@ -43,6 +43,9 @@ async def convert_loop(memory):
# Static preview interval in seconds
preview_interval = [0, 30]
if unprocessed_encrypted_content.onchain_index in [2]:
preview_interval = [0, 60]
# List of conversion options to process
REQUIRED_CONVERT_OPTIONS = ['high', 'low', 'low_preview']