The functions `extract_query_without_mention` and
`is_private_message_but_not_group_pm` now accept `BotHandler`
instead of `ExternalBotHandler` which allows passing objects of both
`EmbeddedBotHandler` and `ExternalBotHandler`.
Fixes#639
- The `BotHandler` Protocol is a mypy Protocol
s.t. all BotHandlers can use it as a default type.
- Fix ExternalBotHandler and StubBotHandler to
follow `BotHandler` Protocol
Fixes part of #639
The `BotStorage` Protocol is created to add a common type to all
storage classes.
Note: Protocol is imported from `typing_extensions` as `typing`
doesn't provide Protocol for python <= 3.7.
- Replace virtualenv with python 3's native venv feature. The venv used is native to
python3.5+, so there's no need for a separate dependency.
- Remove redundant activation script. An activation script is required
to use the pip and python in the virtual environment, but because we're
calling the pip inside the venv, we don't need one.
Fixes#625.
The issue linked to this commit suggest suggests to replace the avatar
with the username only, I just needed to remove !avatar as the code
already shows the username.
Fixes part of #632.
- Call `super()` in the init method.
- Change return hashlib.md5 syntax to encode properly for Python 3
Signed-off-by: Manu LN <manu+github@lacavernedemanu.fr>
Adds the method move_topic to the class Client that allows moving
topics between streams.
- The topic can be renamed if the new_topic argument is given
- Partial topic can be moved givent the proper message_id and
propagate_mode arguments.
- notification to old/new stream can be silenced (active by default)
This adds hash_util_decode() to decode a hash_util_encode() [present in
zulip/zulip's zerver/lib/url_encoding.py [1]] encoded string.
The intent is to facilitate code sharing among various python clients
(primarily, Zulip Terminal).
The string replacement before the `unquote` is to recoup for the custom
string replacements in zulip/zulip's zerver/lib/url_encoding.py [1].
Test added.
[1] See hash_util_encode() in https://github.com/zulip/zulip/blob/master/zerver/lib/url_encoding.py.
Additionally, pin the irc library version to 18.0 because the newer
version has an error in the AioReactor:
```
File "/home/rht/code/venv/lib/python3.8/site-packages/irc/bot.py", line 108, in run
self.bot.reactor.scheduler.execute_after(intvl, self.check)
AttributeError: 'AioReactor' object has no attribute 'scheduler'
```
This reduces the number of retries that might spam APIs.
There is some complexity here which is left un-managed -- for
instance, maybe_restart_mirroring_script does a number of restart
attempts, and then fails, but will be retried every 15s by the
surrounding `process_loop`. Previously, it would merely have looped
forever inside maybe_restart_mirroring_script.
Three loops are intentionally left as infinite `while True` loops,
that merely cap their backoff at the default 90s. Their callers do
not expect, or have any way to handle more gracefully, a failure of
the expected-infinite-loop in `process_loop` or `zulip_to_zephyr`.
They maintain their previous behavior of retrying forever, albeit more
slowly.