Discord: the repository fits in the art's hover text

Discord shows the large image's text in a narrow box that wraps at spaces
only. "github.com/ayozetr/bloodborne_linux" was one word wider than the
box and came out cut ("github.com/ayozetr/bloodbor"). The text is now
"Bloodborne on Linux · ayozetr/bloodborne_linux on GitHub": the
repository has a line of its own and the "Get the Linux port" button
still opens it. The test checks that no word is longer than the box.
This commit is contained in:
ayozetr committed 2026-11-03 21:12:17 +00:00
1 parent 02dc648c96
commit 0f90125d4a
2 files changed
+10 -4

No files matched your search

+5 -2
View File
@@ -27,7 +27,10 @@ import uuid
# "bloodborne").
CLIENT_ID = '1558176258121269389'
REPO_URL = 'https://github.com/ayozetr/bloodborne_linux'
REPO_TEXT = 'github.com/ayozetr/bloodborne_linux'
# Shown when the art is hovered. Discord wraps that text at spaces only, in a narrow box: the
# whole URL was cut off ("github.com/ayozetr/bloodbor"), so the repository goes on a line of its
# own, short enough to fit. The button below opens it.
REPO_TEXT = 'ayozetr/bloodborne_linux'
HANDSHAKE, FRAME, CLOSE = 0, 1, 2
# The areas by map (map/mapstudio/mXX_YY_...): the names of Smithbox's Bloodborne map aliases
# (github.com/vawser/Smithbox, MIT). The Chalice Dungeons (m29) are one name.
@@ -139,7 +142,7 @@ def activity(online, start, area=None, partners=()):
'timestamps': {'start': start},
# The image's tooltip names the repository, and a button opens it (Discord shows the
# buttons to the other people looking at the profile, not to the player).
'assets': {'large_image': 'bloodborne', 'large_text': f'Bloodborne · native Linux port · {REPO_TEXT}'},
'assets': {'large_image': 'bloodborne', 'large_text': f'Bloodborne on Linux · {REPO_TEXT} on GitHub'},
'buttons': [{'label': 'Get the Linux port', 'url': REPO_URL}],
}
if area_name(area):
+5 -2
View File
@@ -57,8 +57,11 @@ class ActivityTests(unittest.TestCase):
class RepositoryLinkTests(unittest.TestCase):
def test_tooltip_and_button_lead_to_the_repository(self):
value = presence.activity(True, 0)
self.assertIn('github.com/ayozetr/bloodborne_linux', value['assets']['large_text'])
self.assertLessEqual(len(value['assets']['large_text']), 128) # Discord's limits
text = value['assets']['large_text']
self.assertIn('ayozetr/bloodborne_linux', text)
# Discord's hover box wraps at spaces and cuts a longer word (about 27 characters).
self.assertLessEqual(max(len(word) for word in text.split()), 26)
self.assertLessEqual(len(text), 128) # Discord's limits
[button] = value['buttons']
self.assertEqual(button['url'], 'https://github.com/ayozetr/bloodborne_linux')
self.assertLessEqual(len(button['label']), 32)