Browse Source

字数制限

pull/18/head
みてるぞ 2 weeks ago
parent
commit
a6af306204
1 changed files with 6 additions and 12 deletions
  1. +6
    -12
      main.py

+ 6
- 12
main.py View File

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


Loading…
Cancel
Save