Skip to content

Commit d6c2182

Browse files
committed
splitjoin to remove duplicate spaces
1 parent 11ea690 commit d6c2182

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

plugins/wordnik.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def define(text):
4444

4545
if json:
4646
data = json[0]
47-
47+
data['word'] = " ".join(data['word'].split())
4848
data['url'] = web.try_shorten(WEB_URL.format(data['word']))
4949
data['attrib'] = ATTRIB_NAMES[data['sourceDictionary']]
5050
return "\x02{word}\x02: {text} - {url} ({attrib})".format(**data)
@@ -69,7 +69,7 @@ def word_usage(text):
6969
out = "\x02{}\x02: ".format(word)
7070
example = random.choice(json['examples'])
7171
out += "{} ".format(example['text'])
72-
return out
72+
return " ".join(out.split())
7373
else:
7474
return "I could not find any usage examples for \x02{}\x02.".format(word)
7575

@@ -107,7 +107,7 @@ def pronounce(text):
107107
url = web.try_shorten(json[0]['fileUrl'])
108108
out += " - {}".format(url)
109109

110-
return out
110+
return " ".join(out.split())
111111

112112

113113
@hook.command()
@@ -128,7 +128,7 @@ def synonym(text):
128128
if json:
129129
out = "\x02{}\x02: ".format(word)
130130
out += " • ".join(json[0]['words'])
131-
return out
131+
return " ".join(out.split())
132132
else:
133133
return "Sorry, I couldn't find any synonyms for \x02{}\x02.".format(word)
134134

@@ -153,7 +153,7 @@ def antonym(text):
153153
out = "\x02{}\x02: ".format(word)
154154
out += " • ".join(json[0]['words'])
155155
out = out[:-2]
156-
return out
156+
return " ".join(out.split())
157157
else:
158158
return "Sorry, I couldn't find any antonyms for \x02{}\x02.".format(word)
159159

@@ -192,7 +192,7 @@ def wordoftheday(text, conn):
192192
out += "\x0305({})\x0305 ".format(pos)
193193
out += "\x0310{}\x0310 ".format(note)
194194
out += "\x02Definition:\x02 \x0303{}\x0303".format(definition)
195-
return out
195+
return " ".join(out.split())
196196
else:
197197
return "Sorry I couldn't find the word of the day, check out this awesome otter instead {}".format(
198198
"http://i.imgur.com/pkuWlWx.gif")

0 commit comments

Comments
 (0)