Skip to content

Commit ffc977a

Browse files
committed
bots: Refactor bot_details handling into function.
1 parent 3451545 commit ffc977a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

zulip_bots/zulip_bots/lib.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ def is_private_message_from_another_user(message_dict, current_user_id):
168168
return current_user_id != message_dict['sender_id']
169169
return False
170170

171+
def get_bot_details(bot_class, bot_name):
172+
bot_details = {
173+
'name': bot_name.capitalize(),
174+
'description': "",
175+
}
176+
bot_details.update(getattr(bot_class, 'META', {}))
177+
return bot_details
178+
171179
def run_message_handler_for_bot(lib_module, quiet, config_file, bot_name):
172180
# type: (Any, bool, str) -> Any
173181
#
@@ -188,11 +196,7 @@ def run_message_handler_for_bot(lib_module, quiet, config_file, bot_name):
188196
state_handler = StateHandler()
189197

190198
# Set default bot_details, then override from class, if provided
191-
bot_details = {
192-
'name': bot_name.capitalize(),
193-
'description': "",
194-
}
195-
bot_details.update(getattr(lib_module.handler_class, 'META', {}))
199+
bot_details = get_bot_details(message_handler, bot_name)
196200

197201
if not quiet:
198202
print("Running {} Bot:".format(bot_details['name']))

0 commit comments

Comments
 (0)