mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon into main
commit
db86620552
12
inbox.py
12
inbox.py
|
|
@ -82,6 +82,7 @@ from delete import removeOldHashtags
|
|||
from categories import guessHashtagCategory
|
||||
from context import hasValidContext
|
||||
from content import htmlReplaceQuoteMarks
|
||||
from speaker import speakerReplaceLinks
|
||||
|
||||
|
||||
def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
|
||||
|
|
@ -2140,7 +2141,8 @@ def _bounceDM(senderPostId: str, session, httpPrefix: str,
|
|||
|
||||
|
||||
def _updateSpeaker(baseDir: str, nickname: str, domain: str,
|
||||
postJsonObject: {}, personCache: {}) -> None:
|
||||
postJsonObject: {}, personCache: {},
|
||||
translate: {}) -> None:
|
||||
""" Generates a json file which can be used for TTS announcement
|
||||
of incoming inbox posts
|
||||
"""
|
||||
|
|
@ -2154,9 +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, detectedLinks)
|
||||
|
||||
imageDescription = ''
|
||||
if postJsonObject['object'].get('attachment'):
|
||||
|
|
@ -2183,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)
|
||||
|
||||
|
|
@ -2524,7 +2529,8 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
|||
else:
|
||||
if boxname == 'inbox':
|
||||
_updateSpeaker(baseDir, nickname, domain,
|
||||
postJsonObject, personCache)
|
||||
postJsonObject, personCache,
|
||||
translate)
|
||||
if not unitTest:
|
||||
if debug:
|
||||
print('Saving inbox post as html to cache')
|
||||
|
|
|
|||
32
speaker.py
32
speaker.py
|
|
@ -33,6 +33,38 @@ def getSpeakerRange(displayName: str) -> int:
|
|||
return random.randint(300, 800)
|
||||
|
||||
|
||||
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
|
||||
"""
|
||||
removeChars = ('.', ',', ';', ':', '?', '!')
|
||||
text = sayText
|
||||
for ch in removeChars:
|
||||
text = text.replace(ch, ' ')
|
||||
replacements = {}
|
||||
wordsList = text.split(' ')
|
||||
linkedStr = translate['Linked']
|
||||
for word in wordsList:
|
||||
domain = None
|
||||
domainFull = None
|
||||
if 'https://' in word:
|
||||
domain = word.split('https://')[1]
|
||||
domainFull = 'https://' + domain
|
||||
elif 'http://' in word:
|
||||
domain = word.split('http://')[1]
|
||||
domainFull = 'http://' + domain
|
||||
if not domain:
|
||||
continue
|
||||
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
|
||||
|
||||
|
||||
def getSpeakerFromServer(baseDir: str, session,
|
||||
nickname: str, password: str,
|
||||
domain: str, port: int,
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "بكسل",
|
||||
"DM bounce": "يتم قبول الرسائل فقط من الحسابات المتبعة",
|
||||
"Next": "التالي",
|
||||
"Preview": "معاينة"
|
||||
"Preview": "معاينة",
|
||||
"Linked": "رابط موقع"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "Els missatges només s’accepten des dels comptes seguits",
|
||||
"Next": "Pròxim",
|
||||
"Preview": "Vista prèvia"
|
||||
"Preview": "Vista prèvia",
|
||||
"Linked": "enllaç web"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "Dim ond o gyfrifon a ddilynir y derbynnir negeseuon",
|
||||
"Next": "Nesaf",
|
||||
"Preview": "Rhagolwg"
|
||||
"Preview": "Rhagolwg",
|
||||
"Linked": "Dolen we"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "Nachrichten werden nur von folgenden Konten akzeptiert",
|
||||
"Next": "Nächster",
|
||||
"Preview": "Vorschau"
|
||||
"Preview": "Vorschau",
|
||||
"Linked": "Weblink"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "Messages are only accepted from followed accounts",
|
||||
"Next": "Next",
|
||||
"Preview": "Preview"
|
||||
"Preview": "Preview",
|
||||
"Linked": "Web linked"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "Solo se aceptan mensajes de cuentas seguidas",
|
||||
"Next": "Próxima",
|
||||
"Preview": "Avance"
|
||||
"Preview": "Avance",
|
||||
"Linked": "enlace web"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "Les messages ne sont acceptés que des comptes suivis",
|
||||
"Next": "Suivante",
|
||||
"Preview": "Aperçu"
|
||||
"Preview": "Aperçu",
|
||||
"Linked": "lien Web"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "Ní ghlactar le teachtaireachtaí ach ó chuntais a leanann",
|
||||
"Next": "Ar Aghaidh",
|
||||
"Preview": "Réamhamharc"
|
||||
"Preview": "Réamhamharc",
|
||||
"Linked": "Nasc gréasáin"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "पिक्सेल",
|
||||
"DM bounce": "संदेश केवल अनुसरण किए गए खातों से स्वीकार किए जाते हैं",
|
||||
"Next": "अगला",
|
||||
"Preview": "पूर्वावलोकन"
|
||||
"Preview": "पूर्वावलोकन",
|
||||
"Linked": "वेब लिंक"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "I messaggi sono accettati solo dagli account seguiti",
|
||||
"Next": "Il prossimo",
|
||||
"Preview": "Anteprima"
|
||||
"Preview": "Anteprima",
|
||||
"Linked": "collegamento web"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "ピクセル",
|
||||
"DM bounce": "メッセージはフォローされているアカウントからのみ受け付けられます",
|
||||
"Next": "次",
|
||||
"Preview": "プレビュー"
|
||||
"Preview": "プレビュー",
|
||||
"Linked": "ウェブリンク"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,5 +369,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "Messages are only accepted from followed accounts",
|
||||
"Next": "Next",
|
||||
"Preview": "Preview"
|
||||
"Preview": "Preview",
|
||||
"Linked": "Web link"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Pixel",
|
||||
"DM bounce": "Mensagens são aceitas apenas de contas seguidas",
|
||||
"Next": "Próxima",
|
||||
"Preview": "Antevisão"
|
||||
"Preview": "Antevisão",
|
||||
"Linked": "link da web"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "Пиксель",
|
||||
"DM bounce": "Сообщения принимаются только от следующих аккаунтов",
|
||||
"Next": "Следующий",
|
||||
"Preview": "Предварительный просмотр"
|
||||
"Preview": "Предварительный просмотр",
|
||||
"Linked": "интернет-ссылка"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,6 @@
|
|||
"Pixel": "像素点",
|
||||
"DM bounce": "仅接受来自后续帐户的邮件",
|
||||
"Next": "下一个",
|
||||
"Preview": "预览"
|
||||
"Preview": "预览",
|
||||
"Linked": "网页链接"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue