From e619c19b368b0ea602ff4fa830ed4139ecb01c75 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Tue, 25 Jul 2017 18:24:08 -0700 Subject: [PATCH] bots: Set user-agent for individual bots automatically. Fixes #28. --- zulip_bots/zulip_bots/lib.py | 4 ++-- zulip_bots/zulip_bots/run.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/zulip_bots/zulip_bots/lib.py b/zulip_bots/zulip_bots/lib.py index 5d1b362..62768d6 100644 --- a/zulip_bots/zulip_bots/lib.py +++ b/zulip_bots/zulip_bots/lib.py @@ -126,7 +126,7 @@ class StateHandler(object): yield new_state self.set_state(new_state) -def run_message_handler_for_bot(lib_module, quiet, config_file): +def run_message_handler_for_bot(lib_module, quiet, config_file, bot_name): # type: (Any, bool, str) -> Any # # lib_module is of type Any, since it can contain any bot's @@ -135,7 +135,7 @@ def run_message_handler_for_bot(lib_module, quiet, config_file): # function. # # Make sure you set up your ~/.zuliprc - client = Client(config_file=config_file) + client = Client(config_file=config_file, client="Zulip{}Bot".format(bot_name.capitalize())) restricted_client = ExternalBotHandler(client) message_handler = lib_module.handler_class() diff --git a/zulip_bots/zulip_bots/run.py b/zulip_bots/zulip_bots/run.py index e8cc7e9..93179cc 100755 --- a/zulip_bots/zulip_bots/run.py +++ b/zulip_bots/zulip_bots/run.py @@ -107,7 +107,8 @@ def main(): run_message_handler_for_bot( lib_module=lib_module, config_file=options.config_file, - quiet=options.quiet + quiet=options.quiet, + bot_name=bot_name ) if __name__ == '__main__':