Commit graph

2287 commits

Author SHA1 Message Date
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
rht 05eaaff802 slack-bridge: Order imports properly. 2021-05-24 14:17:38 -07:00
rht 5b2da94ba5 slack-bridge: Use threading instead of multiprocessing.
This will fix the bug reported in
https://chat.zulip.org/#narrow/stream/127-integrations/topic/bridge_with_slack/near/1182555,
which is specific to macOS.

The error message is
```
AttributeError: Can't pickle local object 'SlackBridge.zulip_to_slack.<locals>._zulip_to_slack'
```
2021-05-24 14:17:38 -07:00
rht 2d9cf64db8 slack-bridge: Use slack_sdk instead of the deprecated slackclient. 2021-05-24 14:17:38 -07:00
LoopThrough-i-j 470967cfdb lint: Set repository variable in tools/lint-commits.
refer to:
zulip/zulip#17506
2021-05-24 14:16:41 -07:00
PIG208 4083849b5d lint: Configure Black. 2021-05-24 14:02:51 -07:00
PIG208 74c99ac405 lint: Configure isort for py files. 2021-05-24 14:02:51 -07:00
PIG208 f537c7f4d5 lint: Disable E203 that will conflict with Black. 2021-05-24 14:02:51 -07:00
PIG208 5a17c60987 lint: Pre-fix places where Black will reformat incorrectly. 2021-05-24 14:02:51 -07:00
Eeshan Garg 63fefd2a0f pypi: Release version 0.8.0. 2021-05-19 22:44:45 -02:30
LoopThrough-i-j dda9e0a638 botserver: Fix mypy error.
Value of type "Optional[Any]" is not indexable error
was originated in PR #682. This is due to request in Flask 2.0.
2021-05-12 15:17:52 -07:00
PIG208 5b32b32914 botserver: Return a valid JSON that is acceptable to outgoing webhooks.
In zulip/zulip@b998138d3a, we introduce
a check for responses from outgoing webhooks that require them to be
a dictionary. This commit fixes the return value of the botserver view
function to accommodate with the change from the serverside.
2021-05-11 09:08:04 -07:00
Abhijeet Prasad Bodas 4d482e0ef3 zulip: Replace GET realm/filters with realm/linkifiers.
In zulip/zulip@3947b0c80a, we replaced
the legacy endpoint to use the term "linkifier" instead of
"filter" and to return the data in a dictionary format.

None of the official clients currently actually use this
endpoint.
2021-04-27 11:06:17 -07:00
LoopThrough-i-j 3c3c361f50 zulip: Fix call_on_each_event.
Fix Improper assignement of narrow variable outside its scope.
2021-04-26 14:14:14 -07:00
Tim Abbott 175972ce49
docs: Create FUNDING.yml. 2021-04-08 06:29:09 -07:00
Anders Kaseorg 83d4a0c217 sync-public-streams: Rewrite using an event queue.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-06 23:36:35 -07:00
Anders Kaseorg 15c46dce46 sync-public-streams: Fix for Python 3.
bytes are not JSON serializable.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-06 23:36:35 -07:00
PIG208 42aecf683e zulip-bots: Fix incrementor to handle edit time limit error.
When the incrementor attempts to edit a message that was sent long
ago, it will fail and the message will not be updated, nor will a
new message be sent.

Fixes: #673
2021-04-06 17:36:22 -07:00
Tim Abbott 4627b07396 zephyr: Decrease update frequency of sync-public-streams. 2021-04-06 15:15:42 -07:00
LoopThrough-i-j 70f457f82a zulip: Add support for additional args for Client.call_on_each_*.
- Added `**kwargs` typed `object` in the definition of
  `Client.call_on_each_*` .

- Replaced `**kwargs` type from `Any` to `object` in the
  definition of `Client.register`.

Fixes part of #647
2021-03-24 15:00:44 -07:00