-
-
Notifications
You must be signed in to change notification settings - Fork 392
bots: Enable 'run_bot_message_handler_for_bot' to be used by Embedded… #64
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
Conversation
zulip_bots/zulip_bots/lib.py
Outdated
# message['content'] will be None when the bot's @-mention is not at the beginning. | ||
# In that case, the message shall not be handled. | ||
message['content'] = extract_query_without_mention(message=message, at_mention_bot_name=at_mention_bot_name) | ||
if message['content'] is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving empty messages unhandled for now, as I saw a PR regarding empty messages by @neiljp.
We can remove merge conflicts as and when any of the PR gets merged. :)
@abhijeetkaur I think it might make sense to add docstring notes for the functions shared between the embedded and external bot systems explaining that they're part of the interface used by zulip/zulip. Otherwise, there's risk of someone doing the opposite refactoring and breaking things :). |
24e5309
to
fbed437
Compare
@timabbott Done! I can modify it as per your suggestion. :) |
I'd just have the docstrings for all but the first such function just point to the first one's. Can you rebase so the tests pass? |
@timabbott Sure! Even I thought of pointing to the first one, but then I thought eventually the ordering of the functions might also change. So, it may lose it meaning. Rebasing... |
fbed437
to
8be02d9
Compare
I wonder why the test is failing here, it is getting passed in my local env. |
8be02d9
to
793996b
Compare
I checked each test log, all of them are passing. But due to environment variable not being set, it shows that travis tests have failed. |
The issue is the linter is failing:
@derAnfaenger we may want to make the linter its own separate suite from the tests... |
@timabbott I'm not sure I understand you correctly; are you thinking of something like a second Travis run that just runs the linter? |
Yes, I'm thinking of moving the linter to a separate job, like do things in the server repository. |
External bots are executed by the run.py script, which calls 'run_message_handler_for_bot'. This function has multiple nested functions that Embedded bots need to use in order to run without duplicating code. So, make utility nested functions independent function in lib.py so that Embedded bots can leverage these. Since External bots uses an explicit 'Client' class object to run, but Embedded bots run without it. Modifications to the function had to be done along with refactoring.
This is done so that any further modification or refactoring of such functions takes into account working in both the repository and does not lead to breaking of any flow.
793996b
to
c915502
Compare
Heads up @abhijeetkaur, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
OK, for this PR, @abhijeetkaur you need to split out your changes to be more reviewable. It is basically impossible to review a change where you both move some functions around and edit their content in the same commit. I split out a chunk of moving a couple functions as part of reviewing this, and merge that commit. Reading this, I also notice some other things need significant work:
Once those are done, we can pick up the other two functions, which are simpler. Sound good? |
@timabbott I have opened #81 for |
@timabbott For the second point raised by you above, we already are doing the checks. Only when mentioned flag is set, only then are we extracting the at-mention string. Adding further commits for |
@timabbott With you already have merged the "Extraction of nested functions to top-level", what I started with an endeavour to create a separate PR for each function; Since all functions were dependent, I ended up adding atomic commits in #81. This PR can be closed as all the rest of the work apart from refactoring is reproduced in #81. :) |
Closing, thanks @abhijeetkaur! |
… bots.
External bots are executed by the run.py script, which calls
'run_bot_message_handler_for_bot'. This function has multiple
nested functions that Embedded bots need to use in order to run
smoothly.
Since External bots uses an explicit 'Client' class object to run,
but Embedded bots run without it. Modifications to the function
had to be done along with refactoring.