Commit graph

475 commits

Author SHA1 Message Date
derAnfaenger
f41030b515 API: rename get_state & update_state to get_storage & update_storage. 2017-11-18 08:58:47 -08:00
derAnfaenger
2736223073 bots: Make StateHandler store state on Zulip server.
This makes the StateHandler functional. To reduce the
number of server roundtrips when fetching/updating the
state, the entire state is fetched ocne at bot
initialization and cached. All changes are stored in the
cache and only saved externally after handle_message()
has been executed.

Fixes #141.
2017-11-18 08:58:47 -08:00
derAnfaenger
979bbb1c14 bot tests: Consistently use mock_bot_handler instance of MockClass. 2017-11-18 08:58:47 -08:00
derAnfaenger
daad7f24e4 bots: Set JSON as default serializer for StateHandler.
With this change, StateHandler.put() does only accept JSON-able
objects by default. The incrementor test tried to store the return
value of send_reply(), a non-JSON-able MockObject, in the state.
Therefore, this commits also sets functional default test return
values for send_message() and send_reply().
Finally, it fixes the tictactoe bot which relied on directly
modifying the state_ attribute.
2017-11-18 08:58:47 -08:00
Eeshan Garg
bd7db69bac bots/giphy: Document the bot. 2017-11-16 09:09:04 -08:00
derAnfaenger
a8b858d78f zulip_bots: Update links to docs. 2017-11-16 13:54:02 +01:00
neiljp (Neil Pilgrim)
03f5e9110b mypy: Add comment on ConfigParser.readfp 'type: ignore'.
readfp remains valid but is deprecated, so is not in the python3 stubs.
2017-11-15 13:43:08 -08:00
derAnfaenger
5f3b3436f6 zulip_bots: Remove redundant custom tests in encrypt. 2017-11-14 09:39:00 -08:00
derAnfaenger
9c37f92a01 zulip_bots: Add common tests.
unittest includes by default all module-level classes that inherit
from TestCase and implement at least one method starting with 'test'.
Since it doesn't provide a convenient way for excluding TestSuites,
we need to manually filter out the unwanted testing of our test base
class itself.
2017-11-14 09:39:00 -08:00
Josh Mandel
94b7c2eaef zulip_bots: Make xkcd bot error more verbose. 2017-11-13 17:00:32 +01:00
derAnfaenger
55332d8cbc zulip_bots: Fix and simplify extract_query_without_mention.
This fixes quirks related to the regex not covering all potential
weird usernames and adds tests for stripping the @-mentions.
2017-11-10 16:09:20 -08:00
derAnfaenger
e05ce661c5 zulip_bots: Enforce default config file schema.
This requires the bot's config section to be named
after the bot. All config entries must be contained
in this section.
2017-11-06 14:20:39 -08:00
derAnfaenger
1a096b317b zulip_bots: Standardize weather bot's config file. 2017-11-06 14:20:39 -08:00
derAnfaenger
56ac3f1b73 zulip_bots: Add config file for github_detail bot. 2017-11-06 14:20:39 -08:00
derAnfaenger
8d81d37351 zulip_bots: Move unmaintained bots to unmaintained dir. 2017-11-02 15:15:52 +01:00
derAnfaenger
8cdc4a6619 zulip_bots: Remove github helper module.
No bot is dependant on this module. No
future bot should be dependant on it,
since it is not a bot itself and is thus
blurring the structure of the bots dir.
2017-11-02 15:15:52 +01:00
derAnfaenger
8dab6140ee zulip_bots: Remove git_hub_comment bot.
This bot has no tests and a command set that is
impractical and confusing to use. It offers no
practical benefit.
2017-11-02 15:15:52 +01:00
derAnfaenger
ff05a8f710 zulip_bots: Remove github_issues bot.
This bot has no tests and no documentation. Its
usage and purpose are unclear.
2017-11-02 15:15:52 +01:00
derAnfaenger
80534a50b6 zulip_bots: Add directory for unmaintained bots. 2017-11-02 15:15:47 +01:00
derAnfaenger
cfb767ad0f zulip_bots: Make virtual_fs bot state fully JSON-able. 2017-10-31 23:15:28 +01:00
derAnfaenger
aef41de37a tools: Remove obsolete state_handler param from handle_message(). 2017-10-31 12:23:29 +01:00
Alena Volkova
fd519252d6 mypy: zulip_bots: Fix errors in zulip_bots/zulip_bot_output.py. 2017-10-27 00:56:16 -04:00
Alena Volkova
5e7f4c595f mypy: zulip_bots: Annotate zulip_bots/test_run.py. 2017-10-27 00:56:16 -04:00
Alena Volkova
afb9886553 mypy: zulip_bots: Fix errors in zulip_bots/test_lib.py. 2017-10-27 00:56:16 -04:00
Alena Volkova
6546917088 mypy: zulip_bots: Annotate zulip_bots/run.py. 2017-10-27 00:56:16 -04:00
Alena Volkova
47d8ab8f9a mypy: zulip_bots: Fix errors in zulip_bots/provision.py. 2017-10-27 00:56:15 -04:00
Alena Volkova
3a20dee621 mypy: zulip_bots: Fix errors in zulip_bots/lib.py. 2017-10-27 00:56:15 -04:00
derAnfaenger
59f81845dd zulip_bots: Update StateHandler API to behave dict-like.
This matches the external StateHandler API with the embedded
StateHandler API.
2017-10-24 13:15:51 +02:00
derAnfaenger
32df4e097d tictactoe bot: Store game state in JSON-able format. 2017-10-24 13:03:41 +02:00
derAnfaenger
8761e47893 zulip_bots: Store testing conversations in lists.
This enforces the use of a list of tuples for
conversations, as opposed to dicts.
2017-10-24 11:14:09 +02:00
derAnfaenger
8179b30873 zulip_bots: Reify StateHandler testing.
This simplifies testing stateful bots by integrating the StateHandler
into the test library. As a side-effect, the mock bot handler gets
reused during a test, making the tests more realistic. The
StateHandler now keeps its state during a call to check_expected_responses,
forcing some stateful tests to be more verbose and explicit.
2017-10-24 11:07:58 +02:00
derAnfaenger
e331426c64 zulip_bots: Rename state_handler to storage. 2017-10-23 12:24:41 +02:00
derAnfaenger
eb6982e670 zulip_bots: Make state_handler property of bot_handler. 2017-10-23 12:17:46 +02:00
derAnfaenger
45c38d0dcf bot tests: Autospec mock bot handler.
This makes test development less error-prone and closer
to reality.
2017-10-23 11:56:01 +02:00
Steve Howell
08e212138d Look for mentioned in flags.
The Zulip server, starting in 1.7, no longer sends
`is_mentioned` in the message payload, and it was buggy in
earlier versions, so now we check `flags`.
2017-10-20 17:33:59 -07:00
neiljp (Neil Pilgrim)
8987ec23e2 bots: zulip_bot_output.py: Check for absence of handler_class in bot. 2017-10-05 11:59:56 -07:00
neiljp (Neil Pilgrim)
8e9c6cd22e bots: zulip_bot_output.py: Check for failed bot module import. 2017-10-05 11:59:56 -07:00
neiljp (Neil Pilgrim)
dd283d88f6 bots: zulip_bot_output.py: Adjust examples in help text. 2017-10-05 11:59:56 -07:00
neiljp (Neil Pilgrim)
682ef81970 bots: zulip_bot_output.py: Use built-in argparse formatting for usage. 2017-10-05 11:59:56 -07:00
neiljp (Neil Pilgrim)
7835f1cc19 bots: zulip_bot_output.py: Add note to usage re using quotes. 2017-10-05 11:59:56 -07:00
neiljp (Neil Pilgrim)
4fff603f44 bots: zulip_bot_output.py: Switch message to being required. 2017-10-05 11:59:56 -07:00
neiljp (Neil Pilgrim)
c33ac65ac9 define bot: add check & test to avoid sending words with non-letters. 2017-10-05 11:54:43 -07:00
neiljp (Neil Pilgrim)
f862cf2222 wikipedia bot: encode urls correctly in http request & adjust tests. 2017-10-05 11:54:43 -07:00
Eeshan Garg
8adf51890a bots/xkcd: Improve and refactor doc.md to use Markdown macros.
This commit does the following:
* Minor improvements to the writing wherever possible.
* Replace links to screenshots with links that would work when
  rendering said screenshots on the main repo. This would mean
  the screenshots won't be rendered outside the main repo.
* Adds a section that links to our Bots Guide's How to run a bot
  tutorial by using a Markdown a macro.
2017-10-03 18:11:38 -07:00
Eeshan Garg
4a162ba625 bots/xkcd: Add a logo. 2017-10-03 18:11:38 -07:00
neiljp (Neil Pilgrim)
34515454b5 bots: Mark --message/-m argument to zulip_bot_output.py as required. 2017-09-30 21:53:51 +02:00
neiljp (Neil Pilgrim)
85f2a9e03d bots: Add basic metadata with failover, used on running only. 2017-09-25 14:39:02 -07:00
Eeshan Garg
5681b6e9e2 zulip_bots: Remove get_bot_doc_path and get_bot_logo_path.
These functions were rendered redundant by changes in our
approach on how the main repo renders docs and logos contained
in the zulip_bots package (see #6103). So, these should now be
removed.
2017-09-16 17:10:12 -02:30
derAnfaenger
18157095c4 zulip_bots: Add unittests for run.py.
These are tests that assert the correct argument
parsing; the successful execution of bots is not verified.
2017-09-13 00:25:16 -07:00
derAnfaenger
3e1d9b17a4 zulip_bots: Import imp.load_source for Python < 3.5. 2017-09-12 05:21:00 -07:00