Commit graph

905 commits

Author SHA1 Message Date
Steve Howell 8295d6775d Extract contrib_bots/bot_lib.py from run.py.
Splitting out some of the bot functions into a library
will make it easier for heavily customized bots to have
their own version of run.py, instead of the shared one
that we use for everyone now.  If they use bot_lib.py
directly, they will still most likely conform to
the "Handler" interface as long as they call
run_message_handler_for_bot.

Most bots should continue to use contrib_bots/run.py
for now.
2017-01-14 12:44:50 -08:00
Sampriti Panda 16b1be15c0 urls: Move /messages/render to POST endpoint 2017-01-13 16:11:51 -08:00
Robert Hönig a7f3b4d1d1 Remove superfluous comment in triage_message(). (#3291) 2017-01-13 10:21:45 -08:00
Juan Verhook e104225a2c interactive bots: Create your own virtual assistant 2017-01-13 07:22:04 -08:00
Rafid Aslam 229471c70f Change error handling in get_subscribers() in Zulip API client.
Fixes #3281.
2017-01-13 07:14:50 -08:00
Maydha K 105b0ab0dc interactive bots: Create tic-tac-toe bot. 2017-01-12 17:26:19 -08:00
Jackson 75a9101f30 interactive bots: Add FourSquare bot and documentation. 2017-01-12 16:51:13 -08:00
Rafid Aslam 6972ce61c8 Move endpoints to use stream_id instead of stream_name in their URLs
- Change `stream_name` into `stream_id` on some API endpoints that use
`stream_name` in their URLs to prevent confusion of `views` selection.

For example:
If the stream name is "foo/members", the URL would be trigger
"^streams/(?P<stream_name>.*)/members$" and it would be confusing because
we intend to use the endpoint with "^streams/(?P<stream_name>.*)$" regex.

All stream-related endpoints now use stream id instead of stream name,
except for a single endpoint that lets you convert stream names to stream ids.

See https://github.com/zulip/zulip/issues/2930#issuecomment-269576231

- Add `get_stream_id()` method to Zulip API client, and change
`get_subscribers()` method to comply with the new stream API
(replace `stream_name` with `stream_id`).

Fixes #2930.
2017-01-12 15:23:31 -08:00
royabouhamad 0e26a0bb3b Interactive bots: Create a thesaurus bot. 2017-01-12 13:07:12 -08:00
Robert Hönig 72486f6371 Fix virtual_fs bot trying to read a directory
This commit prevents the bot from crashing when a command
like 'fs read /home' is entered. Instead, an error is
displayed.
2017-01-12 09:16:17 -08:00
JefftheBest1 7bfaeec54c Fixed typos with receive 2017-01-12 04:52:44 -08:00
JefftheBest1 5e95dc3bdc Fixed typos with threshold. 2017-01-12 04:50:20 -08:00
JefftheBest1 c7a0b9e575 Fixed a typo in zulip_change_commit.py 2017-01-12 04:49:47 -08:00
Vamshi Balanaga 87aa2c5b3b docs: improve docs for contrib_bots. 2017-01-11 16:32:02 -08:00
Yago González 0b765c0370 integrations: Add code for OpenShift. 2017-01-11 16:23:11 -08:00
Robert Hönig a93c0b8f15 Terminate run.py without throwing tracebacks.
Pressing control-c while run.py is being executed has terminated the
script, but threw an ugly traceback. To signal the user that his
method of exit was appropriate, we handle control-c calling exit(0).
2017-01-11 15:25:20 -08:00
Robert Hönig a62a89bca4 Rename the RestrictedClient class to BotHandlerApi
As a first step into restructuring the run.py layout to support a
worker and an API-wrapper class, we rename the RestrictedClient
class appropriately.
2017-01-11 15:25:20 -08:00
Robert Hönig b97411afe6 Hide 'client' and 'rate_limit' from 'contrib_bots' bots.
'contribot_bots' should only provide a restricted access to the
client API, yet 'client' and 'rate_limit were fully exposed. While
not fully restricting access to those objects, this commits hides
them with prepending underscores.
2017-01-11 15:25:20 -08:00
Yago González cb6ae09bc8 api: Support file uploads to the API.
Now, the `Client.do_api_query()` method supports sending files to the
API.

This has allowed the implementation of a new method,
`Client.upload_file(file)`.  It simply uploads the file set in the
parameter, and returns the API's response (that includes the URI).

Despite the fact that `do_api_query()` supports multiple files as
parameters, `upload_file()` doesn't, because right now the API isn't
capable of managing more than a file in the same request.
2017-01-10 17:46:00 -08:00
Tim Abbott a792ecd025 contrib_bots: Fix lint error in rate limiting code. 2017-01-10 15:10:17 -08:00
Robert Hönig 26fa2a5fc5 Add a rate limit for bots in contrib_bots
To prevent bots from accidently entering an infinite message loop,
where they send messages as a reacting to their own messages,
this commit adds the RateLimit class to run.py. It specifies how
many messages can be sent in a given time interval. If this rate
is exceeded, run.py exits with an error.
Fixes #3210.
2017-01-10 13:42:40 -08:00
Uma 775df0f30a Improved 'readme.md' file in contrib_bots/lib 2017-01-10 07:03:57 -08:00
Tim Abbott 58a5de0377 lint: Fix % comprehensions being used without a tuple. 2017-01-09 11:45:11 -08:00
Tommy Ip d5690c80c9 bots: Fix bare except clause. 2017-01-09 00:39:33 +00:00
Tommy Ip 3cea2b5f1c contrib_bots: Fix bare except clause. 2017-01-08 16:25:22 -08:00
Tommy Ip 6302f0d645 bots: Fix bare except clause. 2017-01-08 16:25:22 -08:00
Tommy Ip 39d7db40b3 bots: Fix bare except clause. 2017-01-08 16:25:22 -08:00
Tim Abbott 35149e83de contrib_bots: Wrap CommuteBot docs. 2017-01-05 14:58:06 -08:00
andrewallen00 3574017297 interactive bots: Create yoda translator bot 2017-01-05 11:24:24 -08:00
AZtheAsian 082fbf631f mypy: Add annotations to api/integrations/asana/zulip_asana_mirror. 2017-01-05 11:08:21 -08:00
ausDensk 8d603a4489 mypy: Annotate /api/integrations/rss/rss-bot.
With a few tweaks by tabbott.
2017-01-04 22:42:11 -08:00
Tim Abbott bb5abd971a zulip_codebase_mirror: Move Text/six imports after sys.path changes. 2017-01-03 20:24:03 -08:00
AZtheAsian 9efe608203 mypy: Annotate api/integrations/codebase/zulip_codebase_mirror. 2017-01-03 20:23:06 -08:00
Tim Abbott ce94c09da7 zulip_basecamp_mirror: Move some imports after sys.path updates. 2017-01-03 18:36:12 -08:00
Jackson 777fca09d3 mypy: Add annotations to api/integrations/basecamp/zulip_basecamp_mirror 2017-01-03 18:34:26 -08:00
Jackson 630ee0be92 Clean PUT /users to POST /users 2017-01-03 15:40:00 -08:00
Jackson 3504396179 mypy: Annotate api/integrations/hg/zulip-changegroup.py 2017-01-03 11:44:43 -08:00
Sampriti Panda 1010927188 mypy: Annotate api/integrations/twitter/twitter-search-bot 2017-01-02 08:01:37 -08:00
Jackson 3f8f4dc616 mypy: Annotate api/integrations/trac/zulip_trac.py 2016-12-30 20:05:14 -08:00
Tommy Ip 7f123585a2 mypy: Annotate *api/integrations/perforce/zulip_change-commit.py*. 2016-12-30 15:19:34 -08:00
Vamshi Balanaga 88bdcd61b8 Update Google Calendar Integration.
Update integration to use the latest Google API client.
Move Google Account authorization code to a separate file.
Move relevant files from 'bots/' to 'api/integrations/google/'.
Add documentation for integration.
2016-12-30 12:01:31 -08:00
Tim Abbott b352dc85f0 bots: Move gcal-bot into official API release. 2016-12-30 12:01:31 -08:00
Joshua Pan f9104fb7e4 mypy: Get rid of six.moves.configparser and add appropriate classes. 2016-12-30 11:41:17 -08:00
lonerz 6b52b51db6 mypy: Annotate api/integrations/twitter/twitter-bot 2016-12-30 11:40:45 -08:00
Robert Hönig a86066c386 interactive bots: Create converter bot. 2016-12-29 19:28:35 +01:00
Yago González f563654377 interactive bots: Use dev API when in a dev setup.
Now the development API (which is inside the repo, api/) is used when the envionment is a development one.

Credits to Steve Howell (@showell) for the instructions on how to fix this.
2016-12-28 19:25:56 -08:00
Tommy Ip 04f7fe14fa mypy: Annotate *api/integrations/nagios/nagios-notify-zulip*. 2016-12-28 15:44:47 -08:00
Tommy Ip cb98dd411e mypy: Annotate *api/integrations/svn/post-commit*. 2016-12-28 08:54:53 -08:00
Tim Abbott adc678a3ab bots: Fix jabber_mirror_backend annotations.
mypy was super confused because the name "zulip" was both an import
and a global variable in the file.
2016-12-27 21:39:32 -08:00
Tim Abbott 8148b580ca lint: Fix pep-8 rules on recently added files. 2016-12-27 20:16:23 -08:00