Skip to content

Commit

Permalink
add handler for file uploads in slack connector, update async test ru…
Browse files Browse the repository at this point in the history
…nner plugin, update documentation parser (#2020)

* add handler for file uploads in slack connector

* fix file handler test, limit pytest-asyncio<0.22.0

* use wrapper for now, figure out how to test

* remove breakpoint

* fix filename access

* no BytesIO wrap

* remove deprecated file upload parameter

* try to add thread_ts if configured for thread reply

* test suite runs with anyio now

* more test updates for anyio

* remove unnecessary pytest option for old plugins

* more anyio updates

* more anyio updates, linter fixes

* flake8 linter fix

* try placing anyio fixture right in test context

* update docgen to use myst parser and syntax

* fix cli docgen, sphin_click not supported by myst yet

* try updating .readthedocs.yaml config

* need to have a tools section

* rtd specifies separate steps for python version and actions

* try stringy python version

* no more doc warnings

* try mocking the close call in the ws response

* make side_effect iterable

* remove bad test, try to make file upload use thread_ts
  • Loading branch information
pmaresca committed Apr 25, 2024
1 parent e2ffb0c commit 9b6c9e6
Show file tree
Hide file tree
Showing 87 changed files with 941 additions and 1,004 deletions.
6 changes: 5 additions & 1 deletion .readthedocs.yml
@@ -1,7 +1,11 @@
version: 2

build:
os: ubuntu-20.04
tools:
python: "3.8"

python:
version: 3.8
install:
- method: pip
path: .
Expand Down
2 changes: 1 addition & 1 deletion docs/cli.md
Expand Up @@ -8,7 +8,7 @@ $ opsdroid start

## Reference

```eval_rst
```{eval-rst}
.. click:: opsdroid.cli:cli
:prog: opsdroid
:show-nested:
Expand Down
40 changes: 19 additions & 21 deletions docs/conf.py
Expand Up @@ -4,9 +4,6 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

from recommonmark.parser import CommonMarkParser
from recommonmark.transform import AutoStructify

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -37,6 +34,25 @@
"sphinx.ext.intersphinx",
"sphinx_click.ext",
"sphinx_autodoc_typehints",
"myst_parser",
]

myst_enable_extensions = [
"amsmath",
"attrs_inline",
"attrs_block",
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
"html_admonition",
"html_image",
"linkify",
"replacements",
"smartquotes",
"strikethrough",
"substitution",
"tasklist",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -73,21 +89,3 @@
}

autodoc_mock_imports = ["jwt", "motor"]

# -- Recommonmark ------------------------------------------------------------

github_doc_root = "https://github.com/readthedocs/recommonmark/tree/master/docs"


def setup(app):
app.add_config_value(
"recommonmark_config",
{
"url_resolver": lambda url: github_doc_root + url,
"auto_toc_tree_section": "Contents",
},
True,
)
app.add_transform(AutoStructify)
app.add_source_suffix(".md", "markdown")
app.add_source_parser(CommonMarkParser)
19 changes: 8 additions & 11 deletions docs/configuration.md
@@ -1,7 +1,6 @@
# Configuration

```eval_rst
.. contents::
```{contents}
```

## Config file
Expand Down Expand Up @@ -74,11 +73,10 @@ Opsdroid comes with some built-in connectors out of the box. A connector is a mo

The built-in connectors are:

```eval_rst
.. toctree::
:maxdepth: 2
```{toctree}
:maxdepth: 2
connectors/index
connectors/index
```

_Note: More connectors will be added as built-in connectors into the opsdroid core over time._
Expand Down Expand Up @@ -122,11 +120,10 @@ Skills can store data in opsdroid's "memory", this is a dictionary which can be

The built-in databases are:

```eval_rst
.. toctree::
:maxdepth: 2
```{toctree}
:maxdepth: 2
databases/index
databases/index
```

_Config options of the databases themselves differ between databases. See the database documentation for details._
Expand Down Expand Up @@ -493,7 +490,7 @@ web:
allow-headers:
- X-Token
```

(module-options)=
## Module options

### Install Location
Expand Down
23 changes: 13 additions & 10 deletions docs/connectors/custom.md
@@ -1,26 +1,29 @@
## Creating a custom connector
# Creating a custom connector

## Connectors
Connectors are a class which extends the base opsdroid Connector. The class has three mandatory methods, `connect`, `listen` and `respond`. There are also some default values you can override with the `__init__` function, just be sure you are setting everything that the default init sets.

#### configuration (property)
(configuration)=
### configuration (property)
*configuration* is a class property of Connector. It's used to access the config parameters of a Connector. This can be used to retrieve specific parameters of a connector from `configuration.yaml`.

#### connect
connect is a method which connects to a specific chat service

### Methods
## Methods

### connect
connect is a method which connects to a specific chat service

#### listen
### listen
*listen* uses the open connection to the chat service and retrieves messages from it. Each message is formatted into an opsdroid Message object and then parsed. This method should block the thread with an infinite loop but use `await` commands when getting new messages and parsing with opsdroid. This allows the [event loop](https://docs.python.org/3/library/asyncio-eventloop.html) to hand control of the thread to a different function while we are waiting.

#### user_typing
### user_typing
*user_typing* triggers the event message *user is typing* if the connector allows it. This method uses a parameter `trigger` that takes in a boolean value to trigger the event on/off.

#### disconnect
### disconnect
*disconnect* there is also an optional disconnect method that will be called upon shutdown of opsdroid. This can be used to perform any disconnect operations for the connector.


### Handling Events
## Handling Events

Opsdroid supports different types of events, which can both be sent and received via connectors, for more information on the different types of events see the [events documentation](../skills/events.md).

Expand Down Expand Up @@ -93,5 +96,5 @@ class MyConnector(Connector):
```

---
You might also be interested in reading the [configuration reference - Connector Modules](../configuration.md#connector-modules) in the documentation.
You might also be interested in reading the [configuration reference - Connector Modules](../configuration.md "Connector Modules") in the documentation.
*If you need help or if you are unsure about something join our* [matrix channel](https://app.element.io/#/room/#opsdroid-general:matrix.org) *and ask away! We are more than happy to help you.*
115 changes: 46 additions & 69 deletions docs/connectors/github.md
Expand Up @@ -49,12 +49,12 @@ _*Note:* You should add a secure secret when setting up your webhook, this will
- "Pull request review"
- "Pull request review comment"
- "Push"

_*Note:* You should add a secure secret when setting up your webhook, this will allow opsdroid to confirm that the event received is authentic and came from GitHub._

## Configuration

#### Github app
### Github app

```yaml
connectors:
Expand All @@ -65,7 +65,7 @@ connectors:
secret: <webhook secret>
```

#### Webhook method
### Webhook method

```yaml
connectors:
Expand All @@ -77,114 +77,91 @@ connectors:

## Reference

```eval_rst
.. autoclass:: opsdroid.connector.github.ConnectorGitHub
:members:
```{autoclass} opsdroid.connector.github.ConnectorGitHub
:members:
```

## Events Reference

```eval_rst
.. autoclass:: opsdroid.connector.github.events.IssueCreated
:members:
```{autoclass} opsdroid.connector.github.events.IssueCreated
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.IssueClosed
:members:
```{autoclass} opsdroid.connector.github.events.IssueClosed
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.IssueCommented
:members:
```{autoclass} opsdroid.connector.github.events.IssueCommented
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.Push
:members:
```{autoclass} opsdroid.connector.github.events.Push
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PROpened
:members:
```{autoclass} opsdroid.connector.github.events.PROpened
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PRReopened
:members:
```{autoclass} opsdroid.connector.github.events.PRReopened
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PREdited
:members:
```{autoclass} opsdroid.connector.github.events.PREdited
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PRMerged
:members:
```{autoclass} opsdroid.connector.github.events.PRMerged
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PRClosed
:members:
```{autoclass} opsdroid.connector.github.events.PRClosed
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PRReviewSubmitted
:members:
```{autoclass} opsdroid.connector.github.events.PRReviewSubmitted
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PRReviewEdited
:members:
```{autoclass} opsdroid.connector.github.events.PRReviewEdited
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PRReviewDismissed
:members:
```{autoclass} opsdroid.connector.github.events.PRReviewDismissed
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PRReviewCommentCreated
:members:
```{autoclass} opsdroid.connector.github.events.PRReviewCommentCreated
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PRReviewCommentEdited
:members:
```{autoclass} opsdroid.connector.github.events.PRReviewCommentEdited
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.PRReviewCommentDeleted
:members:
```{autoclass} opsdroid.connector.github.events.PRReviewCommentDeleted
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.Labeled
:members:
```{autoclass} opsdroid.connector.github.events.Labeled
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.Unlabeled
:members:
```{autoclass} opsdroid.connector.github.events.Unlabeled
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.CheckStarted
:members:
```{autoclass} opsdroid.connector.github.events.CheckStarted
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.CheckCompleted
:members:
```{autoclass} opsdroid.connector.github.events.CheckCompleted
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.CheckPassed
:members:
```{autoclass} opsdroid.connector.github.events.CheckPassed
:members:
```

```eval_rst
.. autoclass:: opsdroid.connector.github.events.CheckFailed
:members:
```{autoclass} opsdroid.connector.github.events.CheckFailed
:members:
```

0 comments on commit 9b6c9e6

Please sign in to comment.