mirror of
https://github.com/kuhyx/signal-bot.git
synced 2026-11-10 18:17:02 +01:00
A compliment gets a reaction drawn from a small warm set (❤️ 🥰 😊 👍 🎉 🙏 😸) put on the compliment itself, and nothing in the group -- the one answer that adds no line. Same cooldown as every other command. The transport learns reactions: send_reaction on the Protocol, POST /v1/reactions/<number> on the REST adapter with the four fields api.SendReactionRequest requires (204 back), a recorded list on the fake. CommandContext.react() names the target the way a quote does, and falls back to the emoji as text for an envelope with no timestamp, so a shape this bot has never seen is visible rather than swallowed. The fake container gains the endpoint, strict about the schema, and records reactions in order with the sends; a scenario can now expect {kind: reaction, quotes: true}. First two-word trigger: fold() keeps the inner space and the registry matches whole text first, so "!good bot" resolves and "!good" does not; one-word spellings cover a double space. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# Copyright (c) 2026 Krzysztof Rudnicki. MIT licence.
|
|
"""The in-process transport double."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from signal_bot.transport_fake import FakeTransport, Reaction
|
|
|
|
|
|
async def test_queue_and_receive() -> None:
|
|
transport = FakeTransport()
|
|
transport.queue(["a", "b"])
|
|
assert [f async for f in transport.receive()] == ["a", "b"]
|
|
|
|
|
|
async def test_records_sends() -> None:
|
|
transport = FakeTransport()
|
|
await transport.send_text("hi", "g")
|
|
await transport.send_image("B64", "g")
|
|
assert transport.texts == ["hi"]
|
|
assert transport.sent[1].image_base64 == "B64"
|
|
|
|
|
|
async def test_records_reactions_apart_from_sends() -> None:
|
|
transport = FakeTransport()
|
|
await transport.send_reaction("👍", "g", "uuid-alice", 17)
|
|
assert transport.reactions == [Reaction("👍", "g", "uuid-alice", 17)]
|
|
assert transport.sent == []
|
|
|
|
|
|
async def test_attachments_round_trip() -> None:
|
|
transport = FakeTransport(attachments=["a1"])
|
|
assert await transport.list_attachments() == ["a1"]
|
|
await transport.delete_attachment("a1")
|
|
assert transport.deleted == ["a1"]
|