mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-22 19:58:26 +00:00
support bot light: show contact ids in /list
This commit is contained in:
1 parent
9b640d721e
commit
a1b510650d
4 files changed
+21
-16
No files matched your search
@@ -106,7 +106,7 @@ Available in the roster group.
|
||||
| Command | Effect |
|
||||
| --- | --- |
|
||||
| `/dm` | Join the roster. If the bot has no direct contact, it sends a contact request first; membership becomes active once that request is accepted. |
|
||||
| `/list` | List active members, members who are no longer reachable, and those pending a contact request. |
|
||||
| `/list` | List active members, members who are no longer reachable, and those pending a contact request, each as `ID:name`. |
|
||||
| `/leave` | Leave the roster. Chats already joined are unaffected. |
|
||||
| `/help` | Summarise the above. |
|
||||
| `/feed <text>` | Send a message to every chat. Only for `roster.broadcasters`. |
|
||||
@@ -128,10 +128,11 @@ installation sets `SIMPLEX_LIBS_DIR` to the output of
|
||||
`scripts/desktop/build-lib-linux.sh`, in
|
||||
`apps/multiplatform/common/src/commonMain/cpp/desktop/libs/linux-$(uname -m)`.
|
||||
|
||||
`roster.broadcasters` lists `"ID:name"` strings, such as `["12:Alice", "15:Bob"]`.
|
||||
A broadcaster must be a contact of the bot; `/feed` from anyone else replies
|
||||
with their contact id, or asks them to run `/dm` when they have no contact. The
|
||||
bot exits at start if an id is not a contact or its display name differs.
|
||||
`roster.broadcasters` lists `"ID:name"` strings, such as `["12:Alice", "15:Bob"]`;
|
||||
`/list` shows the ID of each roster member. A broadcaster must be a contact of
|
||||
the bot; `/feed` from anyone else replies with their contact id, or asks them to
|
||||
run `/dm` when they have no contact. The bot exits at start if an id is not a
|
||||
contact or its display name differs.
|
||||
|
||||
## State
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ def _section(title: str, label: str, entries: Sequence[RosterEntry]) -> list[str
|
||||
rather than silently dropped.
|
||||
"""
|
||||
lines = [f"{title} ({len(entries)}):"]
|
||||
lines += [f" • {e.name}{_since(label, e.since)}" for e in entries[:MAX_LISTED]]
|
||||
lines += [f" • {e.contact_id}:{e.name}{_since(label, e.since)}" for e in entries[:MAX_LISTED]]
|
||||
if len(entries) > MAX_LISTED:
|
||||
lines.append(f" … and {len(entries) - MAX_LISTED} more")
|
||||
return lines
|
||||
|
||||
@@ -59,7 +59,7 @@ def test_list_shows_forty_before_it_summarises():
|
||||
|
||||
|
||||
def test_a_reply_at_the_byte_cap_is_not_truncated():
|
||||
room = messages.MAX_REPLY_BYTES - len("On the roster (1):\n • ") - len(" — since 2026-08-13")
|
||||
room = messages.MAX_REPLY_BYTES - len("On the roster (1):\n • 1:") - len(" — since 2026-08-13")
|
||||
assert messages.render_roster([entry("a" * min(room, text.MAX_NAME))]).endswith("2026-08-13")
|
||||
|
||||
over = [entry("漢" * text.MAX_NAME) for _ in range(messages.MAX_LISTED)]
|
||||
|
||||
@@ -2,16 +2,20 @@ from support_bot_light import messages
|
||||
from support_bot_light.roster import RosterEntry
|
||||
|
||||
|
||||
def entry(name, state, since="2026-08-13T09:00:00+00:00", reachable=True):
|
||||
return RosterEntry(contact_id=1, name=name, state=state, since=since, reachable=reachable)
|
||||
def entry(name, state, since="2026-08-13T09:00:00+00:00", reachable=True, contact_id=1):
|
||||
return RosterEntry(
|
||||
contact_id=contact_id, name=name, state=state, since=since, reachable=reachable
|
||||
)
|
||||
|
||||
|
||||
def test_render_roster_lists_active_and_pending():
|
||||
out = messages.render_roster([entry("sh", "active"), entry("Alex", "pending")])
|
||||
def test_render_roster_lists_active_and_pending_with_contact_ids():
|
||||
out = messages.render_roster(
|
||||
[entry("sh", "active", contact_id=142682), entry("Alex", "pending", contact_id=7)]
|
||||
)
|
||||
assert "On the roster (1):" in out
|
||||
assert "• sh — since 2026-08-13" in out
|
||||
assert "• 142682:sh — since 2026-08-13" in out
|
||||
assert "Contact request not accepted (1):" in out
|
||||
assert "• Alex — asked 2026-08-13" in out
|
||||
assert "• 7:Alex — asked 2026-08-13" in out
|
||||
|
||||
|
||||
def test_render_roster_empty():
|
||||
@@ -25,13 +29,13 @@ def test_render_roster_omits_pending_section_when_none():
|
||||
|
||||
def test_render_roster_omits_date_suffix_when_since_is_empty():
|
||||
out = messages.render_roster([entry("sh", "active", since="")])
|
||||
assert out == "On the roster (1):\n • sh"
|
||||
assert out == "On the roster (1):\n • 1:sh"
|
||||
assert "since" not in out
|
||||
|
||||
|
||||
def test_render_roster_formats_date_suffix():
|
||||
out = messages.render_roster([entry("sh", "active")])
|
||||
assert out == "On the roster (1):\n • sh — since 2026-08-13"
|
||||
assert out == "On the roster (1):\n • 1:sh — since 2026-08-13"
|
||||
|
||||
|
||||
def test_invite_log_lists_added_names():
|
||||
@@ -56,7 +60,7 @@ def test_render_roster_separates_unreachable_members():
|
||||
)
|
||||
assert "On the roster (1):" in out
|
||||
assert "Not reachable, not being added (1):" in out
|
||||
assert "• dead" in out
|
||||
assert "• 1:dead" in out
|
||||
|
||||
|
||||
def test_render_roster_caps_long_sections():
|
||||
|
||||
Reference in new issue
Block a user