bots: Add bot for uploading files to Zulip server.
Add file_uploader bot as an example of using ExternalBotHandler's methods for uploading files to Zulip server.
This commit is contained in:
parent
e5239c5c54
commit
7fc1ff5e0e
7 changed files with 122 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from typing import List, Dict, Any, Tuple, Optional
|
||||
from typing import List, Dict, Any, Tuple, Optional, IO
|
||||
|
||||
from zulip_bots.custom_exceptions import (
|
||||
ConfigValidationError,
|
||||
|
@ -53,6 +53,15 @@ class StubBotHandler:
|
|||
def update_message(self, message: Dict[str, Any]) -> None:
|
||||
self.message_server.update(message)
|
||||
|
||||
def upload_file_from_path(self, file_path):
|
||||
# type: (str) -> Dict[str, Any]
|
||||
with open(file_path, 'rb') as file:
|
||||
return self.message_server.upload_file(file)
|
||||
|
||||
def upload_file(self, file):
|
||||
# type: (IO[Any]) -> Dict[str, Any]
|
||||
return self.message_server.upload_file(file)
|
||||
|
||||
class BotQuitException(Exception):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue