Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions zulip_bots/zulip_bots/bots/define/define.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# See readme.md for instructions on running this code.
import logging
import string
import subprocess
from typing import Dict

import html2text
import requests

from zulip_bots.lib import AbstractBotHandler
Expand Down Expand Up @@ -66,8 +66,11 @@ def get_bot_define_response(self, original_content: str) -> str:
# Show definitions line by line.
for d in definitions:
example = d["example"] if d["example"] else "*No example available.*"
example_text = subprocess.check_output(
["html2text", "--unicode-snob"], input=example, text=True
)
response += "\n" + "* (**{}**) {}\n  {}".format(
d["type"], d["definition"], html2text.html2text(example)
d["type"], d["definition"], example_text
)

except Exception:
Expand Down
Loading