Commit Graph

120 Commits

Author SHA1 Message Date
Abhijeet Kaur 601d018367 testsuite: Add tests for wikipedia bot in contrib_bots.
Add test file 'Test_wikipedia.py'.

Since wikipedia links for the same query may different according
to relevance. This test will also be written by mocking HTTP
traffic. But this can work for now.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur 9f861d6d67 testsuite: Add tests for virtual_fs bot in contrib_bots.
Add test file 'test_virtual_fs.py'.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur 02256f79e4 bots: Add a new command 'sample_conversation' in virtual_fs bot.
The previous test function in virtual_Bot made use of another function
called a 'sample_conversation' which had stateful example conversation
with virtual_fs bot.

The function sample_conversation is really useful, so made it accessible
to the users too.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur 469e2acf4d bots: Remove already present test function in virtual_fs bot.
Remove test function for virtual_fs bot from virtual_fs.py file.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur b3dddbe75f bots: Modify 'virtual_fs' bot to respond with help message on bot mention.
Earlier, if virtual_fs bot is called without any argument, then the
bot returns nothing.
Now, virtual_fs bot replies with help message on how the user can
call this bot.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur d4443b05fb testsuite: Add tests for thesaurus bot in contrib_bots.
Add test file 'test_thesaurus.py'.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur af4750799c bots: Remove unwanted spaces from 'help_message' in thesaurus bot.
Remove unwanted spaces from the file contrib_bots/bots/thesaurus/thesaurus.py,
these spaces were being stripped while being written to
zulip console.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur dbe5a65378 testsuite: Add tests for help bot in contrib_bots.
Add test file 'test_help.py'.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur 707cc6ec2c bots: Remove unnecessary split() function from help bot.
Remove unnecessary split() function from the file
contrib_bots/bots/help/help.py and replaced it with equivalent
simpler string.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur afbaa30e4b testsuite: Add tests for helloworld bot in contrib_bots.
Add test file 'test_helloworld.py'.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur 74acc53a8a testsuite: Add tests for encrypt bot in contrib_bots.
Remove previous unittest file for encrypt bot. Add new
test file which is in accordance with the test-suite famework
developed for contrib_bots.
2017-05-28 17:12:11 -07:00
Abhijeet Kaur d2e359e05c testsuite: Add tests for converter bot in contrib_bots.
Remove previous unittest file for converter bot. Add new
test file which is in accordance with the test-suite famework
developed for contrib_bots.

Since 'coverter' folder is now a package (addition of __init__.py),
modify converter.py to import utils.py from the same package.
2017-05-28 17:12:11 -07:00
derAnfaenger 024101be6b bots: Add mypy annotations for bots framework.
This commit adds mypy annotations for both the main
bots and the bots testing runner. It involves a change
to the BotHandlerApi send_message and update_message
funtions, which is compatible with every bot.

Tweaked by tabbott to use more expressive annotations.
2017-05-26 10:25:06 -07:00
Tim Abbott c12023840d contrib_bots: Fix python 3 lint errors. 2017-05-26 10:18:40 -07:00
Elliott Jin f7b124145b bots: Add __init__.py so bot modules can be imported. 2017-05-25 15:00:51 -07:00
Tim Abbott 47c8da28ff bots: Simplify automated testing library. 2017-05-24 20:13:25 -07:00
derAnfaenger 4ec13d3693 bots: Simplify define bot test. 2017-05-24 19:44:22 -07:00
derAnfaenger c3c7874e3f bots: Fix unit tests not running in Vagrant.
`test-bots` would not run in Vagrant, displaying
the error "ValueError: no such test method in <class
'bots_test_lib.BotTestCase'>: runTest" This was due to
the `BotTestCase` class inheriting from the TestCase
class, even though it was not a unit test on its own.

This commit removes the inheritance of TestCase and
specifies `test_define` as the `runTest` method in
`TestDefineBot`.
2017-05-24 19:44:22 -07:00
Krzysztof Krzysztof 5bc719ebbb bots: Add empty message support in Wikipedia bot. 2017-05-24 19:23:36 -07:00
derAnfaenger ba323faef6 bots: Make test-bots independent from current working path. 2017-05-24 17:34:11 -07:00
derAnfaenger 0965e3698d bots: Make run.py independent from current working path. 2017-05-24 17:34:11 -07:00
Krzysztof Krzysztof cad50d8be1 bots: Add empty message support in Wikipedia bot. 2017-05-24 14:49:57 -07:00
derAnfaenger 5480f6fd0f bots: Refactor bots to use send_reply.
The send_reply function makes it easier for bots
to send messages. This commit updates all bots to
make use of this function, when possible.
2017-05-24 13:16:23 -07:00
Abhijeet Kaur 5ed6c29ccf tests: Add contrib_bots/test-bots file.
This test uses unittest and mock library. It mocks
'BotHandlerApi' class. This test works independent of
the rest of the code outside contrib_bots folder.

Merged with a few changes by tabbott to fix lint issues; we'll need to
do further work on this framework, but since it's not hooked up to
anything, it's reasonable to merge early so others can collaborate on
improving it.
2017-05-24 13:13:03 -07:00
Krzysztof Krzysztof 75794acc46 bots: Correct weird behavior of followup bot for empty messages.
Before it sends an empty message to followup stream, now it sends a
help message back to the user/stream where it was mentioned.
2017-05-24 11:58:12 -07:00
derAnfaenger 169f1e35b8 bots: Add incrementor bot.
This bot provides a sample implementation
for updating existing messages sent by the
bot.
2017-05-24 11:01:47 -07:00
derAnfaenger 0b2969a363 bots: Dedup rate limiting error code. 2017-05-24 11:01:47 -07:00
derAnfaenger 188f313e15 bots: Allow bots to update messages. 2017-05-24 11:01:46 -07:00
Tim Abbott ed82f6f3d0 contrib_bots: Fix lint errors in virtual_fs.py. 2017-05-23 21:35:09 -07:00
neiljp a859dadd29 contrib_bots: Clean up and document virtual_fs bot. 2017-05-23 21:04:34 -07:00
Abhijeet Kaur aa576d83b0 Refactor: Make StateHandler() function independent.
This refactor makes the nested class 'StateHandler' in the
file /contrib_bots/bot_lib.py independent class. It previously
was nested in 'run_message_handler_for_bot' function.

This is done to write a cleaner test file for contrib_bots using
mock library.
2017-05-23 20:42:09 -07:00
Theodore Chen 42f9cdcc78 bots: Fix googlesearch bot exceptions and add readme. 2017-05-23 20:18:24 -07:00
derAnfaenger 74069561f1 bots: Fix converter bot.
The converter bot depended on past.utils.old_div,
which is not supported anymore. Updating the code
to use the // operator, which provides the same
functionality.
2017-05-23 20:13:29 -07:00
neiljp fb9ea6b0d9 contrib_bots: Update xkcd bot to use send_reply.
This enables private message usage.
2017-05-23 18:43:43 -07:00
neiljp 62ac170880 contrib_bots: Remove triage_message() from help bot.
This completes removing triage_message from the tree.
2017-05-23 18:30:39 -07:00
neiljp 8b25766ff2 contrib_bots: Switch encrypt bot to use send_reply. 2017-05-23 17:32:51 -07:00
neiljp d766687632 bots: Switch define bot to use send_reply. 2017-05-23 17:02:03 -07:00
neiljp fe1fc45a9e bots: Fix help bot replies in private chat, including 3+ users.
Also deduplicates the code.
2017-05-23 14:38:49 -07:00
Theodore Chen d2090306ad bots: Add helloworld example bot. 2017-05-23 13:15:21 -07:00
neiljp 13649d8846 Factor out send_reply functionality into bot_lib 2017-05-23 12:40:08 -07:00
neiljp 66d8464d2c Update Wikipedia bot to reply to multiple user private chats. 2017-05-23 08:17:35 -07:00
Tim Abbott 454421e098 bot_lib: Fix indentation. 2017-05-23 08:17:22 -07:00
derAnfaenger 2e298d89ab bots: Strip leading whitespaces from bot queries. 2017-05-22 19:13:42 -07:00
derAnfaenger e74714f6ac bots: Clarify message handling for @-mentions. 2017-05-22 19:13:42 -07:00
derAnfaenger b90a5f60e2 bots: Allow empty bot queries.
This commit allows bots to be adressed with empty queries,
that is, by just @-mentioning them. @-mentioning is now the
only way to adress a bot.
2017-05-22 19:13:42 -07:00
Elliott Jin 759d4450c3 bots: Allow symlinks in bot paths provided to run.py.
run.py requires that the location of the provided bot matches the location
of run.py.  However, run.py previously failed in the case where the location
included a symlink.
2017-05-22 16:52:29 -07:00
Aditya Bansal acfb7c902a pep8: Add compliance with rule E261 to bots/define/define.py. 2017-05-07 23:21:50 -07:00
Yago González eb3304bf37 bots: Move Google search bot and fix bugs.
Now this bot follows our latest structure for contrib_bots.

Switched the dependencies instructions, to install "google" rather than
"google-api-python-client".

Added all the search terms to the query (not only the first one).
2017-03-17 13:03:06 -07:00
Tim Abbott a32dc12a4f lint: Fix PEP8 lint error in googlesearch.py. 2017-03-17 12:15:43 -07:00
royabouhamad 5aff3c7bf6 interactive bots: create a google bot. 2017-03-17 11:54:21 -07:00