Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit e50928d

Browse files
authored
feat(howsign): improved display of links (#14)
1 parent e34fdb2 commit e50928d

File tree

2 files changed

+95
-50
lines changed

2 files changed

+95
-50
lines changed

bot.py

+23-26
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,23 @@ async def on_ready():
109109

110110
# -----------------------------------------------------------------------------
111111

112-
HOWSIGN_TEMPLATE = """{word_uppercased}
113-
_Handspeak_ : {handspeak}
114-
_Lifeprint_ : {lifeprint}
115-
_SigningSavvy_: <{signingsavvy}>
116-
_Spread The Sign_: <{spread_the_sign}>
117-
_YouGlish_: {youglish}
112+
HOWSIGN_TEMPLATE = """[👋 **Handspeak** - Search results]({handspeak})
113+
[🧬 **Lifeprint** - Search results]({lifeprint})
114+
[🤝 **SigningSavvy** - Sign for {word_uppercased}]({signingsavvy})
115+
[🌐 **Spread The Sign** - {word_uppercased}]({spread_the_sign})
116+
[📹 **YouGlish** - Videos containing {word_uppercased}]({youglish})
118117
"""
119118

120-
HOWSIGN_SPOILER_TEMPLATE = """||{word_uppercased}||
121-
_Handspeak_ : || {handspeak} ||
122-
_Lifeprint_ : || {lifeprint} ||
123-
_SigningSavvy_: || <{signingsavvy}> ||
124-
_Spread The Sign_: || <{spread_the_sign}> ||
125-
_YouGlish_: || {youglish} ||
119+
HOWSIGN_SPOILER_TEMPLATE = """[👋 **Handspeak** - Search results]({handspeak})
120+
[🧬 **Lifeprint** - Search results]({lifeprint})
121+
[🤝 **SigningSavvy** - Sign for ||{word_uppercased}||]({signingsavvy})
122+
[🌐 **Spread The Sign** - ||{word_uppercased}||]({spread_the_sign})
123+
[📹 **YouGlish** - Videos containing ||{word_uppercased}||]({youglish})
126124
"""
127125

128126
HOWSIGN_HELP = """Look up a word or phrase
129127
130-
If the word or phrase is sent in spoiler text, i.e. enclosed in `||`, the corresponding links will be blacked out.
128+
If the word or phrase is sent in spoiler text, i.e. enclosed in `||`, the word will also be blacked out in the reply.
131129
132130
Examples:
133131
{COMMAND_PREFIX}howsign tiger
@@ -141,22 +139,21 @@ async def on_ready():
141139
def howsign_impl(word: str):
142140
spoiler = get_spoiler_text(word)
143141
word = spoiler if spoiler else word
142+
title = f"||{word.upper()}||" if spoiler else word.upper()
144143
template = HOWSIGN_SPOILER_TEMPLATE if spoiler else HOWSIGN_TEMPLATE
145-
log = (
146-
f"sending spoiler links for: '{word}'"
147-
if spoiler
148-
else f"sending links for: '{word}'"
149-
)
150-
logger.info(log)
144+
logger.info(f"sending links for: '{word}'")
151145
quoted_word = quote_plus(word)
152146
return {
153-
"content": template.format(
154-
word_uppercased=word.upper(),
155-
lifeprint=f"https://www.google.com/search?&q=site%3Alifeprint.com+{quoted_word}",
156-
handspeak=f"https://www.google.com/search?&q=site%3Ahandspeak.com+{quoted_word}",
157-
signingsavvy=f"https://www.signingsavvy.com/search/{quoted_word}",
158-
spread_the_sign=f"https://www.spreadthesign.com/en.us/search/?q={quoted_word}",
159-
youglish=f"https://youglish.com/pronounce/{quoted_word}/signlanguage/asl",
147+
"embed": discord.Embed(
148+
title=title,
149+
description=template.format(
150+
word_uppercased=word.upper(),
151+
lifeprint=f"https://www.google.com/search?&q=site%3Alifeprint.com+{quoted_word}",
152+
handspeak=f"https://www.google.com/search?&q=site%3Ahandspeak.com+{quoted_word}",
153+
signingsavvy=f"https://www.signingsavvy.com/search/{quoted_word}",
154+
spread_the_sign=f"https://www.spreadthesign.com/en.us/search/?q={quoted_word}",
155+
youglish=f"https://youglish.com/pronounce/{quoted_word}/signlanguage/asl",
156+
),
160157
)
161158
}
162159

tests/__snapshots__/test_bot.ambr

+72-24
Original file line numberDiff line numberDiff line change
@@ -118,40 +118,88 @@
118118
---
119119
# name: test_howsign[tiger]
120120
<class 'dict'> {
121-
'content': '
122-
TIGER
123-
_Handspeak_ : https://www.google.com/search?&q=site%3Ahandspeak.com+tiger
124-
_Lifeprint_ : https://www.google.com/search?&q=site%3Alifeprint.com+tiger
125-
_SigningSavvy_: <https://www.signingsavvy.com/search/tiger>
126-
_Spread The Sign_: <https://www.spreadthesign.com/en.us/search/?q=tiger>
127-
_YouGlish_: https://youglish.com/pronounce/tiger/signlanguage/asl
121+
'embed': <class 'Embed'> {
122+
Empty=Embed.Empty,
123+
author=EmbedProxy(),
124+
color=Embed.Empty,
125+
colour=Embed.Empty,
126+
description='
127+
[👋 **Handspeak** - Search results](https://www.google.com/search?&q=site%3Ahandspeak.com+tiger)
128+
[🧬 **Lifeprint** - Search results](https://www.google.com/search?&q=site%3Alifeprint.com+tiger)
129+
[🤝 **SigningSavvy** - Sign for TIGER](https://www.signingsavvy.com/search/tiger)
130+
[🌐 **Spread The Sign** - TIGER](https://www.spreadthesign.com/en.us/search/?q=tiger)
131+
[📹 **YouGlish** - Videos containing TIGER](https://youglish.com/pronounce/tiger/signlanguage/asl)
128132

129-
',
133+
',
134+
fields=<class 'list'> [
135+
],
136+
footer=EmbedProxy(),
137+
image=EmbedProxy(),
138+
provider=EmbedProxy(),
139+
thumbnail=EmbedProxy(),
140+
timestamp=Embed.Empty,
141+
title='TIGER',
142+
type='rich',
143+
url=Embed.Empty,
144+
video=EmbedProxy(),
145+
},
130146
}
131147
---
132148
# name: test_howsign[what's up]
133149
<class 'dict'> {
134-
'content': '
135-
WHAT'S UP
136-
_Handspeak_ : https://www.google.com/search?&q=site%3Ahandspeak.com+what%27s+up
137-
_Lifeprint_ : https://www.google.com/search?&q=site%3Alifeprint.com+what%27s+up
138-
_SigningSavvy_: <https://www.signingsavvy.com/search/what%27s+up>
139-
_Spread The Sign_: <https://www.spreadthesign.com/en.us/search/?q=what%27s+up>
140-
_YouGlish_: https://youglish.com/pronounce/what%27s+up/signlanguage/asl
150+
'embed': <class 'Embed'> {
151+
Empty=Embed.Empty,
152+
author=EmbedProxy(),
153+
color=Embed.Empty,
154+
colour=Embed.Empty,
155+
description='
156+
[👋 **Handspeak** - Search results](https://www.google.com/search?&q=site%3Ahandspeak.com+what%27s+up)
157+
[🧬 **Lifeprint** - Search results](https://www.google.com/search?&q=site%3Alifeprint.com+what%27s+up)
158+
[🤝 **SigningSavvy** - Sign for WHAT'S UP](https://www.signingsavvy.com/search/what%27s+up)
159+
[🌐 **Spread The Sign** - WHAT'S UP](https://www.spreadthesign.com/en.us/search/?q=what%27s+up)
160+
[📹 **YouGlish** - Videos containing WHAT'S UP](https://youglish.com/pronounce/what%27s+up/signlanguage/asl)
141161

142-
',
162+
',
163+
fields=<class 'list'> [
164+
],
165+
footer=EmbedProxy(),
166+
image=EmbedProxy(),
167+
provider=EmbedProxy(),
168+
thumbnail=EmbedProxy(),
169+
timestamp=Embed.Empty,
170+
title="WHAT'S UP",
171+
type='rich',
172+
url=Embed.Empty,
173+
video=EmbedProxy(),
174+
},
143175
}
144176
---
145177
# name: test_howsign[||tiger||]
146178
<class 'dict'> {
147-
'content': '
148-
||TIGER||
149-
_Handspeak_ : || https://www.google.com/search?&q=site%3Ahandspeak.com+tiger ||
150-
_Lifeprint_ : || https://www.google.com/search?&q=site%3Alifeprint.com+tiger ||
151-
_SigningSavvy_: || <https://www.signingsavvy.com/search/tiger> ||
152-
_Spread The Sign_: || <https://www.spreadthesign.com/en.us/search/?q=tiger> ||
153-
_YouGlish_: || https://youglish.com/pronounce/tiger/signlanguage/asl ||
179+
'embed': <class 'Embed'> {
180+
Empty=Embed.Empty,
181+
author=EmbedProxy(),
182+
color=Embed.Empty,
183+
colour=Embed.Empty,
184+
description='
185+
[👋 **Handspeak** - Search results](https://www.google.com/search?&q=site%3Ahandspeak.com+tiger)
186+
[🧬 **Lifeprint** - Search results](https://www.google.com/search?&q=site%3Alifeprint.com+tiger)
187+
[🤝 **SigningSavvy** - Sign for ||TIGER||](https://www.signingsavvy.com/search/tiger)
188+
[🌐 **Spread The Sign** - ||TIGER||](https://www.spreadthesign.com/en.us/search/?q=tiger)
189+
[📹 **YouGlish** - Videos containing ||TIGER||](https://youglish.com/pronounce/tiger/signlanguage/asl)
154190

155-
',
191+
',
192+
fields=<class 'list'> [
193+
],
194+
footer=EmbedProxy(),
195+
image=EmbedProxy(),
196+
provider=EmbedProxy(),
197+
thumbnail=EmbedProxy(),
198+
timestamp=Embed.Empty,
199+
title='||TIGER||',
200+
type='rich',
201+
url=Embed.Empty,
202+
video=EmbedProxy(),
203+
},
156204
}
157205
---

0 commit comments

Comments
 (0)