Anders Kaseorg
aeb89bcae5
ruff: Enable lots of rules.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-11 16:16:17 -08:00
Anders Kaseorg
5e708e3661
ruff: Fix N803 Argument name should be lowercase.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-30 11:44:10 -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
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
6cb1d5f775
mypy: Enable explicit-override error.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 14:03:17 -07:00
Anders Kaseorg
e747d3b712
mypy: Enable no_implicit_reexport.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 13:38:57 -07:00
Anders Kaseorg
8eb3d4e1e2
Upgrade requirements.
...
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
PIG208
05b9850ba3
api: Fetch server_settings when initializing Client.
...
We store the information about the version of the server and the feature
level for transparent compatibility handling.
2021-10-13 09:26:56 -07:00
Anders Kaseorg
d32d442c44
Upgrade mypy to 0.910.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 20:19:05 -07:00
Anders Kaseorg
626359596e
Replace typing.Text with str.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 20:07:35 -07:00
Anders Kaseorg
e8bb65b188
tests: Replace deprecated assertRaisesRegexp with assertRaisesRegex.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-24 17:20:53 -07:00
PIG208
285a946a1f
bot_server: Add support for running botserver from bots registry.
2021-07-29 11:08:33 -07:00
PIG208
a87303beb1
zulip_botserver: Fix path finding for external bots.
...
The previous implementation to locate the `bot_dir` is unfortunately
wrong as it doesn't work with the external custom bots.
2021-07-22 11:14:52 +08:00
PIG208
9ce7c52a10
pyupgrade: Reformat with --py36-plus.
...
This includes mainly fixes of string literals using f-strings or
.format(...), as well as unpacking of list comprehensions.
2021-06-02 18:45:57 -07:00
PIG208
6f3f9bf7e4
black: Reformat without skipping string normalization.
2021-06-02 18:45:57 -07:00
PIG208
fba21bb00d
black: Reformat skipping string normalization.
2021-06-02 18:45:57 -07:00
PIG208
5580c68ae5
isort: Reformat using isort.
2021-06-02 18:45:57 -07:00
Anders Kaseorg
30f241a126
mypy: Remove unused type: ignore comments.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-04 15:09:58 -08:00
Ganesh Pawar
44b6fd395a
tests: Fix tests failing on Windows.
...
Tests were failing on Windows since paths are case-insensitive on it.
This uses pathlib library to compare paths on all platforms.
Fixes #651
2021-03-04 11:28:35 -08:00
LoopThrough-i-j
1fb3d529a9
zulip-bots: Set bot_handler
type to BotHandler
.
...
- Set `bot_handler` type to `BotHandler`.
- Fix mypy issues in improperly typed variables, params and returns.
Fixes part of #639
2021-03-03 13:31:50 -08:00
LoopThrough-i-j
bcf183d2b1
zulip-botserver: Allow passing config via JSON formatted environment variable.
...
Fixes #485 .
Co-authored-by: Alex Vandiver <alexmv@zulip.com>
2021-01-07 00:31:26 -08:00
Anders Kaseorg
6f40bcf745
cleanup: Fix whitespace around parameter equals.
...
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 20:31:14 -07:00
Anders Kaseorg
e30b3b094b
Modernize legacy Python 2 syntax with pyupgrade.
...
Generated by `pyupgrade --py3-plus --keep-percent-format` followed by
manual indentation fixes.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 15:04:36 -07:00
Rohitt Vashishtha
74d902d14f
botserver: Allow importing custom bot modules.
...
We can now specify path to a bot's python file as the ini section
header in the botserver's config file. For example:
[~/Documents/helloworld.py]
email=a@b.com
key=XXXX
site=https://b.com
token=XXXX
2019-09-03 13:27:21 -07:00
Rohitt Vashishtha
cb183fef4c
botserver: Add tests for reading config section by bot name.
2018-07-27 13:43:42 -04:00
Robert Hönig
3ddc8f9b5d
botserver: Make bot-name-not-found error more user-friendly.
...
Previously, when a bot name wasn't found, the Botserver threw
an ImportError with an error message. This results in an
intimidating traceback which is in most cases not helpful to
the user. This commit replaces the ImportError with sys.exit.
2018-06-04 10:14:17 -07:00
Robert Hönig
3d05b88cc2
botserver: Rename zulip-bot-server to zulip-botserver.
...
This is consistent with the correct prose "Botserver"
(instead of "Bot-server").
2018-06-04 10:14:17 -07:00
Robert Hönig
f4e0808a87
botserver: Validate token before accepting message.
...
Previously, the botserver would accept any message sent
to it. This was a security hazard, since an attacker could
impersonate arbitrary users with arbitrary messages. We only
want the Zulip instance where a bot is registered to be able
to send out messages for that bot. To do this, this commits
adds a check for the security token associated with each
outgoing webhook bot. For each bot, its token is stored in
the botserverrc file. The server sends the token along with
each message.
2018-05-30 09:37:33 -04:00
Robert Hönig
762118bbea
Rename flaskbotrc to botserverrc.
2018-05-29 10:19:50 +02:00
Robert Hönig
e6ef34a964
botserver: Strip messages like we do in zulip-run-bot.
...
Previously, messages weren't stripped at all. This
caused most bots to break and send replies similar to
"I didn't understand your command". Nobody noticed,
because the tests were only validating that replies
were sent, but not the content in them. Thus, this
commit also adds tests to avoid further regressions.
2018-05-29 10:05:19 +02:00
Robert Hönig
f1bcf3b9a4
botserver: Remove redundant message check.
...
Previously, the botserver `handle_bot` routine did two checks
on an incoming message:
* First, it checked if the bot email matches
an email in the flaskbotrc.
* Second, it checked if the bot name that corresponds to an email
has a lib module loaded. However, this must be the case, because
all lib modules for all emails are loaded on initialization. Thus,
this commit removes the second check.
2018-05-29 09:52:14 +02:00
Robert Hönig
5c062cee0d
botserver: Verify bot response.
...
This allows for more realistic testing.
2018-05-28 11:13:56 -07:00
Robert Hönig
4285cef29c
assert_bot_server_response: Mock ExternalBotHandler.
2018-05-28 11:13:56 -07:00
Robert Hönig
27938a926b
Rename assert_bot_server_response param message
to event
.
...
It's an event, not a message.
2018-05-28 11:13:56 -07:00
Robert Hönig
48f2c2ae36
Remove default value from assert_bot_server_response message
parameter.
...
This is the first step in validating the bot responses for the
botserver. The default value for `message` was nonsense and
wouldn't trigger a bot in real life. Additionally, we'll want
each test to use a proper message tailored to the test. Thus,
this commit removes a 'default' message alltogether.
2018-05-28 11:13:55 -07:00
Robert Hönig
6a8cb2965c
zulip_botserver: Handle all requests from the root / endpoint.
...
Previously, the Botserver determined which bot to run by dispatching on
a unique URL endpoint /bots/<botname> for each bot.
Now, instead, the Botserver determines which bot to run by the section
header of the bot in the flaskbotrc.
2018-05-28 15:09:39 +02:00
dkvasov
79899dba30
zulip_botserver: More test cases.
2018-05-17 09:43:00 -07:00
dkvasov
fe801d08eb
zulip_botserver: Add test for config parsing.
2018-05-17 09:42:52 -07:00
dkvasov
40785d3116
zulip_botserver: Add test for default input parameters.
2018-05-17 09:40:44 -07:00
dkvasov
a06fb98f21
zulip_bots and zulip_botserver: Extract common function.
2018-05-17 17:35:09 +03:00
dkvasov
86ab26d2ba
zulip_botserver: Get rid of last global variable.
2018-05-16 10:58:09 -07:00
dkvasov
b06ebdecef
zulip_botserver: Add option to test third party configs
2018-05-16 10:50:43 -07:00
dkvasov
d3b99959c6
zulip_botserver: Add test to check two bots working together.
2018-05-16 10:50:43 -07:00
dkvasov
2de862cdcd
zulip_botserver/tests: Reformat input to make them more readable.
2018-05-16 10:50:43 -07:00
dkvasov
7bbc81edbd
zulip_botserver: Get rid of unused input parameter: use load_lib_modules func for loading modules in tests.
2018-05-16 10:50:43 -07:00
dkvasov
ce95f9f4d5
zulip_bots and zulip_botserver: Remove unused imports.
2018-05-16 10:50:43 -07:00
dkvasov
a8665aaac8
zulip_botserver: Add option to set third party configs for bots.
2018-05-16 10:50:43 -07:00
Guitar1st
f90913d54c
zulip_botserver: Get rid of some global variables.
2018-05-15 12:32:57 -07:00
Tim Abbott
5ef224f2a2
zulip_botserver: Eliminate the bots_config global variable.
...
It's easy to just pass it around to the one function that needs it.
2018-05-15 12:32:44 -07:00