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
|
||||
speakerFilename = \
|
||||
baseDir + '/accounts/' + nickname + '@' + domain + '/speaker.json'
|
||||
detectedLinks = []
|
||||
content = urllib.parse.unquote_plus(postJsonObject['object']['content'])
|
||||
content = html.unescape(content)
|
||||
content = removeHtml(htmlReplaceQuoteMarks(content))
|
||||
content = speakerReplaceLinks(content, translate)
|
||||
content = speakerReplaceLinks(content, translate, detectedLinks)
|
||||
|
||||
imageDescription = ''
|
||||
if postJsonObject['object'].get('attachment'):
|
||||
|
@ -2186,7 +2187,8 @@ def _updateSpeaker(baseDir: str, nickname: str, domain: str,
|
|||
"name": speakerName,
|
||||
"summary": summary,
|
||||
"say": content,
|
||||
"imageDescription": imageDescription
|
||||
"imageDescription": imageDescription,
|
||||
"detectedLinks": detectedLinks
|
||||
}
|
||||
saveJson(speakerJson, speakerFilename)
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ def getSpeakerRange(displayName: str) -> int:
|
|||
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]".
|
||||
Instead of reading out potentially very long and meaningless links
|
||||
"""
|
||||
|
@ -58,6 +59,7 @@ def speakerReplaceLinks(sayText: str, translate: {}) -> str:
|
|||
if '/' in domain:
|
||||
domain = domain.split('/')[0]
|
||||
replacements[domainFull] = '. ' + linkedStr + ' ' + domain + '.'
|
||||
detectedLinks.append(domainFull)
|
||||
for replaceStr, newStr in replacements.items():
|
||||
sayText = sayText.replace(replaceStr, newStr)
|
||||
return sayText
|
||||
|
|
Loading…
Reference in New Issue