Commit graph

2256 commits

Author SHA1 Message Date
Anders Kaseorg 4787834d75 bridge_with_matrix: Fix test.
It was broken by commit e876a0541e
(#701).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-10-14 13:56:37 -07:00
rht e876a0541e
Matrix bridge: Fix username typo.
The sample username didn't quite match the format of actual Matrix usernames.
2021-10-14 12:26:47 -07:00
PIG208 a06dd4cadf CI: Add test suites from zulip server.
Part of #683.
2021-10-13 09:26:56 -07:00
PIG208 d0edb0952e api: Replace function signatures for legacy zulip server.
To make sure that the API bindings is backward compatible with
older versions of zulip server that uses functions with different
signatures, we use a hack to replace the Client class with a
legacy-compatible version of it.
2021-10-13 09:26:56 -07:00
PIG208 05b9850ba3 api: Fetch server_settings when initializing Client.
We store the information about the version of the server and the feature
level for transparent compatibility handling.
2021-10-13 09:26:56 -07:00
rht 4e5e7b3d0f Slack bridge: Clarify config placeholder content. 2021-10-07 14:10:40 -07:00
rht 1ca696e75b Slack bridge: Explicitly require aiohttp.
It is required by the Slack library, but strangely not installed. So we
explicitly specify it.
2021-09-17 17:04:10 -07:00
Anders Kaseorg bdc139e9ed zulip_git_config: Add old default branch name for compatibility.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-31 15:04:35 -07:00
Anders Kaseorg 5da0857d51 zephyr_mirror_backend: Add missing parens for calling lower().
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-28 08:32:07 -07:00
Anders Kaseorg ffb8a38f26 test_default_arguments: Adjust for Python 3.10.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-26 16:54:59 -07:00
Anders Kaseorg 34f5c4ef02 git: Fix git_repository_name.
Without universal_newlines=True or text=True, subprocess.check_output
returns bytes, not str, so it makes no sense to compare its return to
"true".  But upstream Git’s behavior only depends on the filename, not
whether the repository is bare; emulate this more closely.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 21:01:05 -07:00
Anders Kaseorg d32d442c44 Upgrade mypy to 0.910.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 20:19:05 -07:00
Anders Kaseorg 626359596e Replace typing.Text with str.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 20:07:35 -07:00
Anders Kaseorg 189cf48573 chessbot: Upgrade python-chess to chess.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 19:01:58 -07:00
Anders Kaseorg 1e6513136a tests: Set encoding for mock HTTP responses.
Fixes warnings like ‘UserWarning: Trying to detect encoding from a
tiny portion of (2) byte(s).’

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 18:03:52 -07:00
Anders Kaseorg e8bb65b188 tests: Replace deprecated assertRaisesRegexp with assertRaisesRegex.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 17:20:53 -07:00
Anders Kaseorg 564fc0e527 Replace the custom test runners with pytest.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 17:07:00 -07:00
Anders Kaseorg cb00a29311 test_matrix: Run Python subprocess via sys.executable.
This works better with pytest on Windows.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 16:51:23 -07:00
Anders Kaseorg b02b84204a merels: Add missing __init__.py, and really fix the tests.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 16:05:34 -07:00
Anders Kaseorg 147e9f6b81 test-bots: Remove merels exclusion.
This test was fixed in commit ab97b37ce1
(#448).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 14:22:32 -07:00
Anders Kaseorg 53e59c8c09 Rename default branch to ‘main’
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 12:50:52 -07:00
PIG208 285a946a1f bot_server: Add support for running botserver from bots registry. 2021-07-29 11:08:33 -07:00
PIG208 745f2cd173 zulip_bots: Add a boilerplate bot for external bots.
Add packaged_helloworld as an example of a PyPI package setup for
an external zulip bot that can be installed via pip and lanuched
without the need to include it in the zulip_bots/bots directory.
2021-07-29 11:08:33 -07:00
PIG208 66434d07cf bots: Indicate source of bot (from source/module/registry) upon startup.
Amend tests to include new parameter.
2021-07-29 11:08:33 -07:00
PIG208 4bc0c607c1 bots: Find external packaged bots via 'zulip_bots.registry' entry_point.
Now we will be able to execute `zulip-run-bot` with the `-r` argument
to search for and run bots from the `zulip_bots.registry` entry_point.

Each entry point should have the name correspond to the bot name,
and have the value be the bot module. E.g, an Python package for a
bot called "packaged_bot" should have an `entry_points` setup like
the following:

setup(
    ...
    entry_points={
        "zulip_bot.registry":[
            "packaged_bot=packaged_bot.packaged_bot"
        ]
    }
    ...
)

whose file structure may look like this:

packaged_bot/
├───packaged_bot/
|   ├───packaged_bot.py  # The bot module
|   ├───test_packaged_bot.py
|   ├───packaged_bot.conf
|   └───doc.md
└───setup.py  # Register the entry points here

Add test case.
2021-07-29 11:08:31 -07:00
PIG208 4fd29baf2b bot_server: Reuse import_module_from_source to load bot modules from paths.
This removes the need to have `load_module_from_file`.
2021-07-22 12:18:34 +08:00
PIG208 a87303beb1 zulip_botserver: Fix path finding for external bots.
The previous implementation to locate the `bot_dir` is unfortunately
wrong as it doesn't work with the external custom bots.
2021-07-22 11:14:52 +08:00
rht c602121171 slack bridge: Update doc for current version of making Slack bot user. 2021-07-06 16:21:41 -07:00
anehls93 71d488e560 zulip_bots: Add doc.md for game_of_fifteen bot.
Finishes #513.
2021-06-28 12:40:20 -02:30
PIG208 df60a1ac03 matrix: Fix test failure brought by the hint for usernames change.
Fixes a188a4e72a.
2021-06-28 11:35:54 -02:30
Tim Abbott a188a4e72a matrix: Better hint the format for Matrix usernames. 2021-06-17 14:04:38 -07:00
Anders Kaseorg d1b3ac8d94 gitlint-rules: Remove convoluted binary search for imperative forms.
This also fixes the suggestions for the following words: disabled,
disables, disabling, implemented, implementing, implements, kept,
made, took, using.

(Copied from zulip/zulip@91f048c056a66eb78a102c095e714eff5f28e36e.)

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-14 13:36:30 -07:00
PIG208 9ce7c52a10 pyupgrade: Reformat with --py36-plus.
This includes mainly fixes of string literals using f-strings or
.format(...), as well as unpacking of list comprehensions.
2021-06-02 18:45:57 -07:00
PIG208 e27ac0ddbe pyupgrade: Replace Text with str.
We uses `pyupgrade --py3-plus` to automatically replace all occurence
of `Text`. But manual fix is required to remove the unused imports. Note
that with this configuration pyupgrade also convert string literals to
.format(...) style, which is manually not included in the commit as well.
2021-06-02 18:45:57 -07:00
PIG208 a54cccc012 lint: Add black as a linter. 2021-06-02 18:45:57 -07:00
PIG208 c4edf4bd2f lint: Add isort as a linter. 2021-06-02 18:45:57 -07:00
PIG208 6f3f9bf7e4 black: Reformat without skipping string normalization. 2021-06-02 18:45:57 -07:00
PIG208 fba21bb00d black: Reformat skipping string normalization. 2021-06-02 18:45:57 -07:00
PIG208 5580c68ae5 isort: Reformat using isort. 2021-06-02 18:45:57 -07:00
PIG208 37e2596124 zulip_bots: Add docstrings and comments for TerminalBotHandler. 2021-05-27 23:52:07 -07:00
PIG208 d949f2024f zulip_bots: Rename SimpleMessageServer to MockMessageServer.
Given that the purpose of this message server is solely for testing,
we rename it for clarity.
2021-05-27 23:52:07 -07:00
rht 5f21952b77 Add click as req in setup.py for zulip-cli. 2021-05-27 23:51:32 -07:00
PIG208 bd27631dd1 zulip-bots: Yield cache storage instead bot storage.
Fixes the bug that the context manager doesn't actually manage the
storage.
2021-05-27 23:49:41 -07:00
rht 06bbfd752e Initialize CLI interface for python-zulip-api. 2021-05-24 14:35:02 -07:00
PIG208 b8389b78c1 zulip-bots: Use context manager for incrementor. 2021-05-24 14:30:19 -07:00
PIG208 86fa9f5e35 zulip-bots: Implement context manager.
The context manager is implemented based on a newly added storage called
CachedStorage. It is a bufferred storage that doesn't sync with the
database until it's flushed. With CachedStorage, we can implement the
context manager easily by loading all the data on __enter__ and just
flush all the modified (dirty) data on __exit__. This approach can help
the user minimize the number of round-trips to the server almost
invisibly (despite the fact that they need to use it with "with").

Fixes: #679
2021-05-24 14:30:19 -07:00
PIG208 e0723c1db4 zulip-bots: Move protocols for context manager. 2021-05-24 14:30:19 -07:00
PIG208 b04f5f9753 terminal: Implement react for TerminalBotHandler.
Fixes: #686
2021-05-24 14:22:29 -07:00
PIG208 0b35ed0a93 terminal: Extract message server from the handler.
This makes the user and the bot to share the message server when
sending messages. As a result, the message id can be shared. And history
messages sent by the user will be stored as well.
2021-05-24 14:22:29 -07:00
PIG208 fb77f4bad4 terminal: Apply BotHandler for TerminalBotHandler. 2021-05-24 14:22:29 -07:00