aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--_pytest/test_unwrap_attachments.py15
-rw-r--r--requirements.txt3
-rw-r--r--wee_slack.py5
4 files changed, 28 insertions, 2 deletions
diff --git a/README.md b/README.md
index 999f40f..4115414 100644
--- a/README.md
+++ b/README.md
@@ -288,10 +288,13 @@ Show channel name in hotlist after activity
/set weechat.look.hotlist_names_level 14
```
-Debugging
---------------
+Development
+-----------------
+
+To run the tests, create a virtualenv and pip install from the `requirements.txt`. Then `pytest` to run them locally.
Enable debug mode and change debug level (default 3, decrease to increase logging and vice versa):
+
```
/set plugins.var.python.slack.debug_mode on
/set plugins.var.python.slack.debug_level 2
diff --git a/_pytest/test_unwrap_attachments.py b/_pytest/test_unwrap_attachments.py
index ee5bd8b..0839613 100644
--- a/_pytest/test_unwrap_attachments.py
+++ b/_pytest/test_unwrap_attachments.py
@@ -32,6 +32,21 @@ import pytest
'input_message': {'attachments': [{
'title': 'Title',
'text': 'Attachment text',
+ 'title_link': 'http://title.link',
+ 'image_url': 'http://image.url',
+ 'fallback': 'Fallback',
+ }]},
+ 'input_text_before': "",
+ 'output': "\n".join([
+ "Title (http://title.link)",
+ "Attachment text",
+ "http://image.url",
+ ]),
+ },
+ {
+ 'input_message': {'attachments': [{
+ 'title': 'Title',
+ 'text': 'Attachment text',
'title_link': 'http://link?a=1&b=2',
'from_url': 'http://link?a=1&b=2',
}]},
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..d0d67bc
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,3 @@
+pytest
+mock
+websocket-client
diff --git a/wee_slack.py b/wee_slack.py
index 9262e7f..dae13b0 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2812,6 +2812,11 @@ def unwrap_attachments(message_json, text_before):
tx = re.sub(r' *\n[\n ]+', '\n', atext)
t.append(prepend_title_text + tx)
prepend_title_text = ''
+
+ image_url = attachment.get('image_url', '')
+ if image_url not in text_before_unescaped and image_url != title_link:
+ t.append(image_url)
+
fields = attachment.get("fields", None)
if fields:
for f in fields: