Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance uploads #218

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
24 changes: 16 additions & 8 deletions slackbot/slackclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,23 @@ def rtm_send_message(self, channel, message, attachments=None, thread_ts=None):
}
self.send_to_websocket(message_json)

def upload_file(self, channel, fname, fpath, comment):
def upload_file(self, channel, fname, fpath, comment, thread_ts=None, filetype=None):
fname = fname or to_utf8(os.path.basename(fpath))
self.webapi.files.upload(fpath,
channels=channel,
filename=fname,
initial_comment=comment)
initial_comment=comment,
thread_ts=thread_ts,
filetype=filetype)

def upload_content(self, channel, fname, content, comment):
def upload_content(self, channel, fname, content, comment, thread_ts=None, filetype=None):
self.webapi.files.upload(None,
channels=channel,
content=content,
filename=fname,
initial_comment=comment)
initial_comment=comment,
thread_ts=thread_ts,
filetype=filetype)

def send_message(self, channel, message, attachments=None, as_user=True, thread_ts=None):
self.webapi.chat.post_message(
Expand Down Expand Up @@ -193,18 +197,22 @@ def __eq__(self, compare_str):
cid = self._body['id']
return name == compare_str or "#" + name == compare_str or cid == compare_str

def upload_file(self, fname, fpath, initial_comment=''):
def upload_file(self, fname, fpath, initial_comment='', thread_ts=None, filetype=None):
self._client.upload_file(
self._body['id'],
to_utf8(fname),
to_utf8(fpath),
to_utf8(initial_comment)
to_utf8(initial_comment),
thread_ts,
filetype
)

def upload_content(self, fname, content, initial_comment=''):
def upload_content(self, fname, content, initial_comment='', thread_ts=None, filetype=None):
self._client.upload_content(
self._body['id'],
to_utf8(fname),
to_utf8(content),
to_utf8(initial_comment)
to_utf8(initial_comment),
thread_ts,
filetype
)