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