mirror of https://gitlab.com/bashrc2/epicyon
Include any detected links within speaker endpoint
parent
eabfdd367c
commit
9851a0f1af
6
inbox.py
6
inbox.py
|
@ -2156,10 +2156,11 @@ def _updateSpeaker(baseDir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
speakerFilename = \
|
speakerFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/speaker.json'
|
baseDir + '/accounts/' + nickname + '@' + domain + '/speaker.json'
|
||||||
|
detectedLinks = []
|
||||||
content = urllib.parse.unquote_plus(postJsonObject['object']['content'])
|
content = urllib.parse.unquote_plus(postJsonObject['object']['content'])
|
||||||
content = html.unescape(content)
|
content = html.unescape(content)
|
||||||
content = removeHtml(htmlReplaceQuoteMarks(content))
|
content = removeHtml(htmlReplaceQuoteMarks(content))
|
||||||
content = speakerReplaceLinks(content, translate)
|
content = speakerReplaceLinks(content, translate, detectedLinks)
|
||||||
|
|
||||||
imageDescription = ''
|
imageDescription = ''
|
||||||
if postJsonObject['object'].get('attachment'):
|
if postJsonObject['object'].get('attachment'):
|
||||||
|
@ -2186,7 +2187,8 @@ def _updateSpeaker(baseDir: str, nickname: str, domain: str,
|
||||||
"name": speakerName,
|
"name": speakerName,
|
||||||
"summary": summary,
|
"summary": summary,
|
||||||
"say": content,
|
"say": content,
|
||||||
"imageDescription": imageDescription
|
"imageDescription": imageDescription,
|
||||||
|
"detectedLinks": detectedLinks
|
||||||
}
|
}
|
||||||
saveJson(speakerJson, speakerFilename)
|
saveJson(speakerJson, speakerFilename)
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ def getSpeakerRange(displayName: str) -> int:
|
||||||
return random.randint(300, 800)
|
return random.randint(300, 800)
|
||||||
|
|
||||||
|
|
||||||
def speakerReplaceLinks(sayText: str, translate: {}) -> str:
|
def speakerReplaceLinks(sayText: str, translate: {},
|
||||||
|
detectedLinks: []) -> str:
|
||||||
"""Replaces any links in the given text with "link to [domain]".
|
"""Replaces any links in the given text with "link to [domain]".
|
||||||
Instead of reading out potentially very long and meaningless links
|
Instead of reading out potentially very long and meaningless links
|
||||||
"""
|
"""
|
||||||
|
@ -58,6 +59,7 @@ def speakerReplaceLinks(sayText: str, translate: {}) -> str:
|
||||||
if '/' in domain:
|
if '/' in domain:
|
||||||
domain = domain.split('/')[0]
|
domain = domain.split('/')[0]
|
||||||
replacements[domainFull] = '. ' + linkedStr + ' ' + domain + '.'
|
replacements[domainFull] = '. ' + linkedStr + ' ' + domain + '.'
|
||||||
|
detectedLinks.append(domainFull)
|
||||||
for replaceStr, newStr in replacements.items():
|
for replaceStr, newStr in replacements.items():
|
||||||
sayText = sayText.replace(replaceStr, newStr)
|
sayText = sayText.replace(replaceStr, newStr)
|
||||||
return sayText
|
return sayText
|
||||||
|
|
Loading…
Reference in New Issue