Skip to content

Commit

Permalink
Merge branch 'develop' into regex-kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
tribela authored Apr 20, 2017
2 parents 72ff387 + 19d1d31 commit 63f9e9d
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dist: trusty
sudo: false
language: python
python: 3.5
python: 3.6
cache:
directories:
- $HOME/.cache/pip
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Besides specifying `DEFAULT_REPLY` in `slackbot_settings.py`, you can also decor

```python
@default_reply
def my_default_hanlder(messsage):
def my_default_hanlder(message):
message.reply('...')
```

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5'])
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'])
2 changes: 1 addition & 1 deletion slackbot/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _get_bot_name(self):
return self._client.login_data['self']['name']

def filter_text(self, msg):
full_text = msg.get('text', '')
full_text = msg.get('text', '') or ''
channel = msg['channel']
bot_name = self._get_bot_name()
bot_id = self._get_bot_id()
Expand Down
12 changes: 7 additions & 5 deletions slackbot/plugins/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
@respond_to(r'upload \<?(.*)\>?')
def upload(message, url):
url = url.lstrip('<').rstrip('>')
fname = os.path.basename(url)
message.reply('uploading {}'.format(fname))
message.reply('uploading {}'.format(url))
if url.startswith('http'):
with create_tmp_file() as tmpf:
download_file(url, tmpf)
message.channel.upload_file(fname, tmpf, 'downloaded from {}'.format(url))
elif url.startswith('/'):
message.channel.upload_file(fname, url)
message.channel.upload_file(url, tmpf,
'downloaded from {}'.format(url))
elif url == 'slack.png':
cwd = os.path.abspath(os.path.dirname(__file__))
fname = os.path.join(cwd, '../../tests/functional/slack.png')
message.channel.upload_file(url, fname)
3 changes: 2 additions & 1 deletion tests/functional/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ def _has_uploaded_file(self, name, start=None, end=None):
def _has_uploaded_file_rtm(self, name):
with self._events_lock:
for event in self.events:
if event['type'] == 'file_shared' \
if event['type'] == 'message' \
and event.get('subtype') == 'file_share' \
and event['file']['name'] == name \
and event['file']['user'] == self.testbot_userid:
return True
Expand Down
8 changes: 3 additions & 5 deletions tests/functional/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,17 @@ def test_bot_default_reply(driver):
driver.send_direct_message('youdontunderstandthiscommand do you')
driver.wait_for_bot_direct_message('.*You can ask me.*')

@pytest.mark.skip
def test_bot_upload_file(driver):
png = join(abspath(dirname(__file__)), 'slack.png')
driver.send_direct_message('upload %s' % png)
driver.send_direct_message('upload slack.png')
driver.wait_for_bot_direct_message('uploading slack.png')
driver.wait_for_file_uploaded('slack.png')

@pytest.mark.skip
def test_bot_upload_file_from_link(driver):
url = 'https://slack.com/favicon.ico'
fname = basename(url)
driver.send_direct_message('upload %s' % url)
driver.wait_for_bot_direct_message('uploading %s' % fname)
driver.wait_for_bot_direct_message('uploading <%s>' % url)
driver.wait_for_file_uploaded(fname)

def test_bot_reply_to_channel_message(driver):
driver.send_channel_message('hello')
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34,py35
envlist = py27,py34,py35,py36
[testenv]
deps =
pytest
Expand Down

0 comments on commit 63f9e9d

Please sign in to comment.