diff --git a/modules/wa.py b/modules/wa.py index e2b955e..ceda4df 100644 --- a/modules/wa.py +++ b/modules/wa.py @@ -1,6 +1,7 @@ import urllib.request import wolframalpha from html import escape +import json from modules.common.module import BotModule @@ -40,7 +41,6 @@ class MatrixModule(BotModule): elif short[0]: html, plain = short else: - print(short) plain = 'Could not find response for ' + query html = plain await bot.send_html(room, html, plain) @@ -91,23 +91,26 @@ class MatrixModule(BotModule): if title: html = f'{escape(title)}: {escape(text)}' - text = f'title: text' + text = f'{title}: {text}' else: - html = escape(text) - plain = text - pod_htmls += [f'
  • {s}
  • ' for s in html.split('\n')] - pod_texts += [f'- {s}' for s in text.split('\n')] + html = escape(text) + pod_htmls += html.split('\n') + pod_texts += text.split('\n') if pod_texts: title = pod.get('@title') - pod_html = '\n'.join([f'

    {escape(title)}\n

    ']) - pod_text = '\n'.join([title] + pod_texts) + pod_html = '\n'.join([f'

    {escape(title)}\n

    ']) + pod_text = '\n'.join([title] + + [f'- {s}' for s in pod_texts]) htmls.append(pod_html) texts.append(pod_text) if not primary and self.is_primary(pod): - primary = (pod_html, pod_text) + primary = (f'{escape(title)}: ' + ' | '.join(pod_htmls), + f'{title}: ' + ' | '.join(pod_texts)) else: - fallback = fallback or (pod_html, pod_text) + fallback = fallback or (' | '.join(pod_htmls), ' | '.join(pod_texts)) return (primary or fallback, ('\n'.join(htmls), '\n'.join(texts)))