Commit graph

247 commits

Author SHA1 Message Date
Anders Kaseorg
b009dcd7d3 ruff: Fix SIM108 Use ternary operator instead of if-else-block.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 18:17:39 -07:00
Anders Kaseorg
2aa36f90fb ruff: Fix SIM105 Use contextlib.suppress instead of try-except-pass.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 18:17:39 -07:00
Anders Kaseorg
58a3026f37 ruff: Fix SIM102 Use a single if statement instead of nested if statements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 18:17:39 -07:00
Anders Kaseorg
774edb434e ruff: Fix C400 Unnecessary generator (rewrite as a list comprehension).
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 17:36:51 -07:00
Anders Kaseorg
353c2de050 ruff: Fix EXE002 The file is executable but no shebang is present.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 16:54:40 -07:00
Anders Kaseorg
ca3e5a2746 ruff: Fix EXE001 Shebang is present but file is not executable.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 16:54:40 -07:00
Anders Kaseorg
6b2861c3ec ruff: Fix G004 Logging statement uses f-string.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-28 16:18:11 -07:00
Anders Kaseorg
d85ace8e7e ruff: Fix G003 Logging statement uses +.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-28 16:17:21 -07:00
Anders Kaseorg
02e0555e0d ruff: Fix G002 Logging statement uses %.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-28 16:17:21 -07:00
Anders Kaseorg
e537bbefdf ruff: Fix G001 Logging statement uses str.format.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-28 16:17:21 -07:00
Anders Kaseorg
1ccb5db6ef ruff: Fix G010 Logging statement uses warn instead of warning.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-28 16:17:21 -07:00
Anders Kaseorg
63246e4369 ruff: Fix RUF010 Use explicit conversion flag.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:41:04 -07:00
Anders Kaseorg
c471f26d45 ruff: Fix ISC001 Implicitly concatenated string literals on one line.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:14:10 -07:00
Anders Kaseorg
fcd4fe330d ruff: Fix UP031 Use format specifiers instead of percent format.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:04:41 -07:00
Anders Kaseorg
ddccf0eda3 ruff: Fix UP032 Use f-string instead of format call.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:01:58 -07:00
Anders Kaseorg
a49add3d02 lint: Replace Black with Ruff.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 19:08:40 -07:00
Anders Kaseorg
6cb1d5f775 mypy: Enable explicit-override error.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 14:03:17 -07:00
Anders Kaseorg
95b33b83b5 mypy: Enable redundant-expr error.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 13:41:24 -07:00
Anders Kaseorg
a9e3fe9d0c zulip_trello: Add type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 16:21:34 -07:00
Anders Kaseorg
40fba154c2 get-google-credentials: Remove Python 2 compatibility.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 16:19:32 -07:00
Anders Kaseorg
2ecabb3260 Fix signal handler types.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 13:23:51 -07:00
Anders Kaseorg
a9607dfdf9 Convert type comments to Python ≥ 3.6 variable annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-18 01:04:47 -07:00
Daniel Teunis
35a8ff8839 zulip-integrations: Add missing dependencies to requirement files.
Adds missing items to the requirement files for the zulip integrations
in `zulip/integrations/*`.
2023-08-11 12:36:11 -07:00
Daniel Teunis
ae142a380d rss-bot: Allow overriding the topic default.
rss-bot selects the topic of its RSS notification messages based on the
topic of the RSS feed. Monitoring a large number of RSS feeds therefore
leads to a large number of topics in the stream. Also, the user has no
option to customize the topic names.

This patch adds a new `--topic` argument that replaces the topic for
all RSS feed notifications with the provided string. If no custom topic
is provided, the bot uses the default behaviour described above.
2023-06-12 12:24:29 -07:00
i-ky
768959d633
rss-bot: Remove unnecessary "sender" in request data.
I've experienced that `rss-bot` works fine when using config file, but fails when `--site`, `--api-key`, and `--user` are provided via command line. The error is the following:
```
{'result': 'error', 'msg': 'Invalid mirrored message', 'code': 'BAD_REQUEST'}
```
Debugging shows that in the latter case `rss-bot` calls `zulip.Client.send_message()` with `"sender"` field in `message_data`. In the former case `"sender"` is `None`. Clearly, it is a bug that `rss-bot`'s behaviour depends on `--user` being provided on the command line.

`"sender"` field in request causes [this exception](e26f9180c1/zerver/views/message_send.py (L227)) on the server side.
Judging by surrounding code, `"sender"` is only expected together with a [specific set of clients](e26f9180c1/zerver/views/message_send.py (L186)). `rss-bot` uses a different one:
1b8f1d6e51/zulip/integrations/rss/rss-bot (L204)
Therefore I think, that providing `"sender"` is totally unnecessary.
2023-05-30 17:03:26 -07:00
Zixuan James Li
1b8f1d6e51 lint: Pin black to avoid inconsistent formatting.
This also runs black to reformat the affected files, which had been
causing failures because of upstream updates.

Ideally, we need a more sophisticated toolchain for managing the
versions of the dependencies instead of just requirements.txt. This
should be due in a possible future cleanup.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-05-29 10:53:22 -07:00
Zixuan James Li
63f46f4bbb zephyr: Add missing return type annotation.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-05-29 10:53:22 -07:00
Anders Kaseorg
02586f1d34 zephyr_mirror: Port sharding wrapper to asyncio.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-25 16:53:09 -08:00
Anders Kaseorg
7831d979c9 zephyr: Free received notices with ZFreeNotice.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-24 12:23:44 -08:00
Anders Kaseorg
c94da617ed Remove Python 3.6; add Python 3.10.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-24 12:04:59 -08:00
rht
582e9733a9 Slack bridge: Inform user to subscribe their Slack bot. 2022-10-19 15:17:15 -07:00
rht
eef02fbb76 Slack bridge: Implement multiple channels bridges. 2022-10-19 15:17:15 -07:00
Robert Imschweiler
41ec1a9a29 matrix bridge: Improve mime-type detection. 2022-09-22 09:13:19 -07:00
Anders Kaseorg
92120914f8 process_ccache: Adjust supervisor_path to avoid Puppet purging.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-13 16:43:40 -07:00
Anders Kaseorg
a534446315 zephyr: Remove python-zephyr in favor of ctypes.
Our custom patched version of python-zephyr only worked on Python 2.
Now we don’t need python-zephyr at all.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-13 16:43:40 -07:00
Anders Kaseorg
56f805a5d7 zephyr_mirror_backend: Fix thread safety problems.
As of commit 5eaac7bfba (#18),
zulip.Client is not thread-safe and especially not fork-safe due to
connections held open by requests.Session.

Delay construction of the Client until after forking off
zulip_to_zephyr.  Replace the fork for each message sent by
zephyr_to_zulip with a threaded queue worker.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-13 16:43:40 -07:00
Robert Imschweiler
63c259b2bc integrations: Enhanced matrix bridge. 2022-09-08 16:14:23 -07:00
Anders Kaseorg
091511b164 Revert "integrations: Enhanced matrix bridge."
This reverts commit 72ef52d12e (#723).

The test failure on Windows will need to be debugged before this can
be re-merged.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-08-22 21:13:10 -07:00
Robert Imschweiler
72ef52d12e integrations: Enhanced matrix bridge. 2022-08-18 14:21:17 -07:00
rht
b290717bb2 Matrix bridge: Print reminder to subscribe the bots on startup. 2022-07-27 16:23:49 -07:00
rht
31365a8aac bridge_with_matrix: Bump matrix-client 0.2.0 -> 0.4.0. 2022-05-24 14:49:04 -07:00
rht
56f5ee3d70 Matrix bridge: Say that the user may have to wait 1 minute. 2021-11-08 21:01:09 -08:00
rht
c41ead698f Matrix bridge: Rename username to mxid.
The username doesn't include the Matrix homeserver domain name, while
the mxid does. Since we change the usage of the old "username" to
include the domain, it is incorrect to remain saying it as "username."
2021-11-08 21:01:09 -08:00
rht
59fd4f070a Matrix bridge: Remove hardcoded matrix.org from username.
This allows people to mirror from self-hosted Matrix instances.
2021-11-08 21:01:09 -08:00
rht
58e51c7ae5 Slack bridge: Bump slack-sdk to 3.11.2.
We also upgrade the RTM client API from v1 to v2. This is so that we no
longer require aiohttp. If we use v1, it would still require aiohttp.
2021-10-19 16:26:40 -07:00
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
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