Commit graph

1921 commits

Author SHA1 Message Date
Rhea Parekh e638cdd4a9 bots: Add proper error handling for trivia bot. 2018-06-04 06:51:35 -04:00
Rhea Parekh f276e46890 bots: Add tests for trivia_quiz bot 2018-06-04 05:59:10 -04:00
Steve Howell 9096dd2918 [wip] Create trivia quiz bot. 2018-06-04 05:59:10 -04:00
Steve Howell 93661db0d1 bots: Print send_message errors for dev debugging. 2018-06-04 05:59:10 -04:00
Steve Howell fcd39204a9 bots: Pass through widget_content if passed in. 2018-06-04 05:59:10 -04:00
novokrest 488dcb4219 beeminder: Check auth_token in initialize by idempotent request.
Change checking auth_token in `initialize` method by calling
request to get user's information instead of calling POST request
which modifies progress of user's goal.
2018-06-03 22:17:01 -07:00
novokrest 229f62a483 lib: Read bot's config file by ConfigParser.read_file method.
This was introduced in the refactor in
a8665aaac8.

The correct function taking an open file handle is read_file, not read().

Fixes #414.
2018-06-02 10:32:40 -07:00
neiljp (Neil Pilgrim) 363720e908 matrix bridge: Add main() function to enable installation. 2018-06-02 09:26:40 -07:00
novokrest dc83d9e468 beeminder: Remove duplicated try-except in initialize method.
Remove duplicated try-except in `initialize` method because
ConnectionError is already catched in `get_beeminder_response` method.
2018-06-02 12:01:20 +03:00
novokrest f3d2d3a01e beeminder: Add tests for valid messages. 2018-06-02 12:01:20 +03:00
novokrest d68a19f2dc beeminder: Rename test test_normal to test_message_with_value_and_comment. 2018-06-02 11:10:41 +03:00
neiljp (Neil Pilgrim) 2b86b9f488 xkcd bot: Update bot & tests to use bot identity functionality. 2018-05-31 06:10:50 -04:00
neiljp (Neil Pilgrim) f15356c4c8 wikipedia bot: Update bot & tests to use bot identity functionality. 2018-05-31 06:10:50 -04:00
neiljp (Neil Pilgrim) 56c59d915a bots: Support determining bot runtime identity.
This improves the ability of a bot to specify how to mention it,
which varies at run-time depending upon the identity used to run it;
this is commonly used in many bot help commands.
2018-05-31 06:10:50 -04:00
neiljp (Neil Pilgrim) 4c8d86c1d9 bot lib tests: Move tests of bot library to tests/.
This makes it clearer which files are for writing bot tests
vs tests of the infrastructure.
2018-05-30 18:29:47 -07:00
Tim Abbott 9e6b4edee6 integrations: Remove slack import script.
This was migrated to the Zulip server project some time ago.
2018-05-30 16:10:22 -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
neiljp (Neil Pilgrim) efe5b04374 salesforce: Minor improvements; imports & types. 2018-05-30 07:11:16 -04:00
neiljp (Neil Pilgrim) 8f0b9adb70 trello: Remove extra newlines & spaces in code and tests. 2018-05-30 07:11:16 -04:00
neiljp (Neil Pilgrim) 4f224b5dbc trello: Simplify message & response handling. 2018-05-30 07:11:16 -04:00
neiljp (Neil Pilgrim) 8e1d4f524b baremetrics: Remove extra newlines & spaces in code and tests. 2018-05-30 07:11:16 -04:00
neiljp (Neil Pilgrim) b51b6d0361 baremetrics: Simplify response generation. 2018-05-30 07:11:16 -04:00
neiljp (Neil Pilgrim) 016011437e baremetrics: Simplify core handler code. 2018-05-30 07:11:16 -04:00
neiljp (Neil Pilgrim) ce4404b9db idonethis: Remove extra newlines in code & tests.
Also rename list_steams -> list_teams.
2018-05-30 07:11:16 -04:00
neiljp (Neil Pilgrim) 9b782e8357 idonethis: Improve typing & note unused function. 2018-05-30 07:11:16 -04:00
neiljp (Neil Pilgrim) dbe44a2774 idonethis: Remove unreachable code & simplify response generation.
Also remove unnecessary import.
2018-05-30 07:11:16 -04:00
neiljp (Neil Pilgrim) 4e19a7716d mypy: Avoid 'Any' for message in bots.
Also remove a few unnecessary typing imports.
2018-05-30 07:11:16 -04:00
novokrest 7a95c31162 mercurial: Rename hook file to zulip_changegroup.py.
Rename hook file from 'zulip-changegroup.py'
to 'zulip_changegroup.py' for importing as module.
2018-05-29 11:45:56 -07:00
novokrest 9b9070808f mercurial: Update changegroup hook according to new mercurial API.
Fixes #322
2018-05-29 11:45:56 -07:00
Tim Abbott d14a025ff9 provision: Make the source line stand out more. 2018-05-29 11:32:45 -07:00
Tim Abbott 6ca216024f matrix: Fix typo in requirements.txt. 2018-05-29 11:05:01 -07:00
Robert Hönig 8e653fe064 linter: Add rule to favor Botserver over botserver or bot server. 2018-05-29 10:59:15 +02:00
Robert Hönig 64a1306e39 Consistently use Botserver instead of botserver or bot server. 2018-05-29 10:58:37 +02:00
Robert Hönig 762118bbea Rename flaskbotrc to botserverrc. 2018-05-29 10:19:50 +02:00
Robert Hönig 3859bef05f botserver: Make handle_bot logic more concise. 2018-05-29 10:05:32 +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
Robert Hönig 6249df0ad7 bots: Don't run tests for monkeytestit bot.
The monkeytestit tests fail on Python3.4 because
one of their dependencies only works on Python3.5.
This is a hotfix to make builds pass again. We'll
want to find a proper way of Python version conditional
bot test execution.
2018-05-28 13:43:15 +02:00
Robert Hönig 47c879407c monkeytestit bot tests: Import bot class inside test.
We need to import the bot class inside the tests, so
we are able to temporarily resolve problems with the
bot class by simply skipping the test. It also makes
the code look nicer.
2018-05-28 13:43:15 +02:00
Robert Hönig a8045a8fa9 mypy: Fix paths to chessbot files. 2018-05-28 13:43:15 +02:00
neiljp (Neil Pilgrim) a178f93087 test-bots: Detect absent __init__.py & optionally exit. 2018-05-26 17:28:25 -07:00
neiljp (Neil Pilgrim) bda678344f test-bots: Extract common filter out of conditional. 2018-05-26 17:28:25 -07:00
neiljp (Neil Pilgrim) 210caa4a60 test-bots: Extract test discovery out of conditional.
This (re?)-enables exclusion of bot names from eg. `test-bots`.
2018-05-26 17:22:03 -07:00
neiljp (Neil Pilgrim) a5307b3771 test-bots: Use unused available_bots to discover tests. 2018-05-26 17:22:03 -07:00
neiljp (Neil Pilgrim) 76b2befb9b test-bots: Remove unused function parameter. 2018-05-26 17:22:03 -07:00