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.
It adds a react() function that allows a bot to react to a message in lib.py.
It adds an example of the use of react() function and its test.
The changes are in the following files:
- lib.py
- helloworld.py
- tests/test_lib.py
- test_lib.py
Previously, if a bot was accidentally added to a group PM, we would
have no option but to leave that conversation because the bot would
reply to all the messages sent in that conversation. This also has
potential to cause infinite loops in case two bots are added to a
group PM since they could keep on replying to each other's messages.
Fixes#551.
The origin of this line seems like an arbitary decision when writing the
wikipedia bot in ad25f27853. Removing self
doesn't have any other significance, and not making any changes to the
recipient list helps with https://github.com/zulip/zulip/issues/14228.
Fixes#552.
Flake8 combines pycodestyle with pyflakes and automatically gives us
support for noqa comments, parallelism, configuration files, plugins,
and easy editor integration.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>