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
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.
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
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.
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.
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.