bots: Rename BotHandlerApi class to ExternalBotHandler.
This change is done for better understanding of the class functionality
from its class name. Now there will be 3 different classes for bots,
namely 'ExternalBotHandler', 'FlaskBotHandler' and  'EmbeddedBotHandler'.
MODIFY
bots_api/bot_lib.py
bots_api/bot_lib.py
@@ -51,7 +51,7 @@ class RateLimit(object):
sys.exit(1)
-class BotHandlerApi(object):
+class ExternalBotHandler(object):
def __init__(self, client):
# type: (Client) -> None
# Only expose a subset of our Client's functionality
@@ -129,7 +129,7 @@ def run_message_handler_for_bot(lib_module, quiet, config_file):
#
# Make sure you set up your ~/.zuliprc
client = Client(config_file=config_file)
- restricted_client = BotHandlerApi(client)
+ restricted_client = ExternalBotHandler(client)
message_handler = lib_module.handler_class()
if hasattr(message_handler, 'initialize'):
@@ -141,7 +141,7 @@ def run_message_handler_for_bot(lib_module, quiet, config_file):
print(message_handler.usage())
def extract_query_without_mention(message, client):
- # type: (Dict[str, Any], BotHandlerApi) -> str
+ # type: (Dict[str, Any], ExternalBotHandler) -> str
"""
If the bot is the first @mention in the message, then this function returns
the message with the bot's @mention removed. Otherwise, it returns None.
@@ -154,7 +154,7 @@ def run_message_handler_for_bot(lib_module, quiet, config_file):
return query_without_mention.lstrip()
def is_private(message, client):
- # type: (Dict[str, Any], BotHandlerApi) -> bool
+ # type: (Dict[str, Any], ExternalBotHandler) -> bool
# bot will not reply if the sender name is the same as the bot name
# to prevent infinite loop
if message['type'] == 'private':

MODIFY
bots_api/bots_test_lib.py
bots_api/bots_test_lib.py
@@ -43,8 +43,8 @@ class BotTestCase(TestCase):
def setUp(self):
# type: () -> None
- # Mocking BotHandlerApi
- self.patcher = patch('bots_api.bot_lib.BotHandlerApi')
+ # Mocking ExternalBotHandler
+ self.patcher = patch('bots_api.bot_lib.ExternalBotHandler')
self.MockClass = self.patcher.start()
self.message_handler = self.get_bot_message_handler()

MODIFY
flask_bot_server.py
flask_bot_server.py
@@ -15,7 +15,7 @@ if os.path.exists(os.path.join(our_dir, '../api/zulip')):
from zulip import Client
from bots_api.run import get_lib_module
-from bots_api.bot_lib import BotHandlerApi, StateHandler
+from bots_api.bot_lib import ExternalBotHandler, StateHandler
bots_config = {} # type: Dict[str, Mapping[str, str]]
available_bots = [] # type: List[str]
@@ -50,7 +50,7 @@ def handle_bot(bot):
client = Client(email=bots_config[bot]["email"],
api_key=bots_config[bot]["key"],
site=bots_config[bot]["site"])
- restricted_client = BotHandlerApi(client)
+ restricted_client = ExternalBotHandler(client)
message_handler = bots_lib_module[bot].handler_class()
# TODO: Handle stateful bots properly.

bots: Rename BotHandlerApi class to ExternalBotHandler.

This change is done for better understanding of the class functionality
from its class name. Now there will be 3 different classes for bots,
namely 'ExternalBotHandler', 'FlaskBotHandler' and  'EmbeddedBotHandler'.