| @@ -92,6 +92,8 @@ async def answer ( | |||||
| for answered_flag in answered_flags: | for answered_flag in answered_flags: | ||||
| td: dict[str, Any] | td: dict[str, Any] | ||||
| answer = answered_flag.answer | answer = answered_flag.answer | ||||
| answered_flag.answered = True | |||||
| answered_flag.save () | |||||
| match QueryType (answer.query_rel.query_type): | match QueryType (answer.query_rel.query_type): | ||||
| case QueryType.BLUESKY_COMMENT: | case QueryType.BLUESKY_COMMENT: | ||||
| td = answer.query_rel.transfer_data or { } | td = answer.query_rel.transfer_data or { } | ||||
| @@ -104,12 +106,10 @@ async def answer ( | |||||
| strong_ref = atproto.models.create_strong_ref (sref) # type: ignore | strong_ref = atproto.models.create_strong_ref (sref) # type: ignore | ||||
| reply_ref = ReplyRef (root = strong_ref, parent = strong_ref) | reply_ref = ReplyRef (root = strong_ref, parent = strong_ref) | ||||
| try: | try: | ||||
| client.post (answer.content, reply_to = reply_ref) | |||||
| client.post (answer.content[:250], reply_to = reply_ref) | |||||
| except Exception as e: | except Exception as e: | ||||
| print (f"[answer/reply] { type (e).__name__ }: { e }") | print (f"[answer/reply] { type (e).__name__ }: { e }") | ||||
| continue | continue | ||||
| answered_flag.answered = True | |||||
| answered_flag.save () | |||||
| case QueryType.KIRIBAN | QueryType.NICO_REPORT: | case QueryType.KIRIBAN | QueryType.NICO_REPORT: | ||||
| td = answer.query_rel.transfer_data or { } | td = answer.query_rel.transfer_data or { } | ||||
| video_code: str | None = td.get ('video_code') | video_code: str | None = td.get ('video_code') | ||||
| @@ -136,12 +136,10 @@ async def answer ( | |||||
| uri = uri) | uri = uri) | ||||
| embed_external = AppBskyEmbedExternal.Main (external = external) | embed_external = AppBskyEmbedExternal.Main (external = external) | ||||
| try: | try: | ||||
| client.post (answer.content, embed = embed_external) | |||||
| client.post (answer.content[:250], embed = embed_external) | |||||
| except Exception as e: | except Exception as e: | ||||
| print (f"[answer/nico-post] { type (e).__name__ }: { e }") | print (f"[answer/nico-post] { type (e).__name__ }: { e }") | ||||
| continue | continue | ||||
| answered_flag.answered = True | |||||
| answered_flag.save () | |||||
| case QueryType.SNACK_TIME: | case QueryType.SNACK_TIME: | ||||
| try: | try: | ||||
| with open ('./assets/snack-time.jpg', 'rb') as f: | with open ('./assets/snack-time.jpg', 'rb') as f: | ||||
| @@ -159,10 +157,8 @@ async def answer ( | |||||
| '下部に「おやつタイムだ!!!!」という' | '下部に「おやつタイムだ!!!!」という' | ||||
| '日本語のテキストが表示されている。'), | '日本語のテキストが表示されている。'), | ||||
| image = client.com.atproto.repo.upload_blob (f).blob) | image = client.com.atproto.repo.upload_blob (f).blob) | ||||
| client.post (answer.content, | |||||
| client.post (answer.content[:250], | |||||
| embed = AppBskyEmbedImages.Main (images = [image])) | embed = AppBskyEmbedImages.Main (images = [image])) | ||||
| answered_flag.answered = True | |||||
| answered_flag.save () | |||||
| except Exception: | except Exception: | ||||
| pass | pass | ||||
| case QueryType.HOT_SPRING: | case QueryType.HOT_SPRING: | ||||
| @@ -180,10 +176,8 @@ async def answer ( | |||||
| '下部に「温泉に入ろう!!!」という' | '下部に「温泉に入ろう!!!」という' | ||||
| '日本語のテキストが表示されている。'), | '日本語のテキストが表示されている。'), | ||||
| image = client.com.atproto.repo.upload_blob (f).blob) | image = client.com.atproto.repo.upload_blob (f).blob) | ||||
| client.post (answer.content, | |||||
| client.post (answer.content[:250], | |||||
| embed = AppBskyEmbedImages.Main (images = [image])) | embed = AppBskyEmbedImages.Main (images = [image])) | ||||
| answered_flag.answered = True | |||||
| answered_flag.save () | |||||
| except Exception: | except Exception: | ||||
| pass | pass | ||||
| await asyncio.sleep (10) | await asyncio.sleep (10) | ||||