Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Talk Bot API #97

Merged
merged 20 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 45 additions & 17 deletions .github/workflows/analysis-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ jobs:
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
php occ config:system:set loglevel --value=1 --type=integer
php occ config:system:set debug --value=true --type=boolean
php occ config:system:set allow_local_remote_servers --value true
php -S localhost:8080 &

- name: Checkout NcPyApi
Expand Down Expand Up @@ -136,7 +135,7 @@ jobs:
cd ..
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
-e --force-scopes
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
Expand All @@ -160,7 +159,14 @@ jobs:

- name: Generate coverage report
working-directory: nc_py_api
run: coverage run --data-file=.coverage.ci -m pytest && coverage combine && coverage xml && coverage html
run: |
coverage run --data-file=.coverage.talk_bot tests/_talk_bot.py &
echo $! > /tmp/_talk_bot.pid
coverage run --data-file=.coverage.ci -m pytest
kill -15 $(cat /tmp/_talk_bot.pid)
timeout 3m tail --pid=$(cat /tmp/_talk_bot.pid) -f /dev/null
coverage run --data-file=.coverage.at_the_end -m pytest tests/_tests_at_the_end.py
coverage combine && coverage xml && coverage html

- name: HTML coverage to artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -258,7 +264,6 @@ jobs:
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
php occ config:system:set loglevel --value=1
php occ config:system:set debug --value=true --type=boolean
php occ config:system:set allow_local_remote_servers --value true
php -S localhost:8080 &

- name: Checkout NcPyApi
Expand Down Expand Up @@ -290,7 +295,7 @@ jobs:
cd ..
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
-e --force-scopes
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
Expand All @@ -314,7 +319,14 @@ jobs:

- name: Generate coverage report
working-directory: nc_py_api
run: coverage run --data-file=.coverage.ci -m pytest && coverage combine && coverage xml && coverage html
run: |
coverage run --data-file=.coverage.talk_bot tests/_talk_bot.py &
echo $! > /tmp/_talk_bot.pid
coverage run --data-file=.coverage.ci -m pytest
kill -15 $(cat /tmp/_talk_bot.pid)
timeout 3m tail --pid=$(cat /tmp/_talk_bot.pid) -f /dev/null
coverage run --data-file=.coverage.at_the_end -m pytest tests/_tests_at_the_end.py
coverage combine && coverage xml && coverage html

- name: HTML coverage to artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -399,7 +411,6 @@ jobs:
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
php occ config:system:set loglevel --value=1 --type=integer
php occ config:system:set debug --value=true --type=boolean
php occ config:system:set allow_local_remote_servers --value true
php -S localhost:8080 &

- name: Checkout NcPyApi
Expand Down Expand Up @@ -429,14 +440,17 @@ jobs:
cd ..
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
-e --force-scopes
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null

- name: Generate coverage report
working-directory: nc_py_api
run: coverage run --data-file=.coverage.ci -m pytest && coverage combine && coverage xml && coverage html
run: |
coverage run --data-file=.coverage.ci -m pytest
coverage run --data-file=.coverage.at_the_end -m pytest tests/_tests_at_the_end.py
coverage combine && coverage xml && coverage html
env:
SKIP_NC_CLIENT_TESTS: 1

Expand Down Expand Up @@ -519,7 +533,6 @@ jobs:
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
./occ config:system:set loglevel --value=0 --type=integer
./occ config:system:set debug --value=true --type=boolean
./occ config:system:set allow_local_remote_servers --value true
./occ app:enable notifications
php -S localhost:8080 &

Expand Down Expand Up @@ -549,7 +562,7 @@ jobs:
cd ..
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"port\":$APP_PORT,\"protocol\":\"http\",\"system_app\":1}" \
-e --force-scopes
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
Expand All @@ -571,7 +584,14 @@ jobs:

- name: Generate coverage report
working-directory: nc_py_api
run: coverage run --data-file=.coverage.ci -m pytest && coverage combine && coverage xml && coverage html
run: |
coverage run --data-file=.coverage.talk_bot tests/_talk_bot.py &
echo $! > /tmp/_talk_bot.pid
coverage run --data-file=.coverage.ci -m pytest
kill -15 $(cat /tmp/_talk_bot.pid)
timeout 3m tail --pid=$(cat /tmp/_talk_bot.pid) -f /dev/null
coverage run --data-file=.coverage.at_the_end -m pytest tests/_tests_at_the_end.py
coverage combine && coverage xml && coverage html

- name: HTML coverage to artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -655,7 +675,6 @@ jobs:
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
./occ config:system:set loglevel --value=0 --type=integer
./occ config:system:set debug --value=true --type=boolean
./occ config:system:set allow_local_remote_servers --value true
./occ app:enable notifications
php -S localhost:8080 &

Expand Down Expand Up @@ -685,7 +704,10 @@ jobs:

- name: Generate coverage report
working-directory: nc_py_api
run: coverage run -m pytest && coverage xml && coverage html
run: |
coverage run -m pytest
coverage run --data-file=.coverage.at_the_end -m pytest tests/_tests_at_the_end.py
coverage combine && coverage xml && coverage html
env:
SKIP_AE_TESTS: 1
NPA_NC_CERT: ''
Expand Down Expand Up @@ -761,7 +783,6 @@ jobs:
--admin-user admin --admin-pass ${{ env.NC_AUTH_PASS }}
./occ config:system:set loglevel --value=0 --type=integer
./occ config:system:set debug --value=true --type=boolean
./occ config:system:set allow_local_remote_servers --value true
./occ app:enable notifications
php -S localhost:8080 &

Expand Down Expand Up @@ -795,7 +816,7 @@ jobs:
cd ..
php occ app_ecosystem_v2:daemon:register manual_install "Manual Install" manual-install 0 0 0
php occ app_ecosystem_v2:app:register $APP_ID manual_install --json-info \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\"]},\"protocol\":\"http\",\"port\":$APP_PORT,\"system_app\":1}" \
"{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_name\":\"manual_install\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"host\":\"localhost\",\"scopes\":{\"required\":[\"SYSTEM\", \"FILES\", \"FILES_SHARING\"],\"optional\":[\"USER_INFO\", \"USER_STATUS\", \"NOTIFICATIONS\", \"WEATHER_STATUS\", \"TALK\", \"TALK_BOT\"]},\"protocol\":\"http\",\"port\":$APP_PORT,\"system_app\":1}" \
-e --force-scopes
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
Expand All @@ -818,7 +839,14 @@ jobs:

- name: Generate coverage report
working-directory: nc_py_api
run: coverage run --data-file=.coverage.ci -m pytest && coverage combine && coverage xml && coverage html
run: |
coverage run --data-file=.coverage.talk_bot tests/_talk_bot.py &
echo $! > /tmp/_talk_bot.pid
coverage run --data-file=.coverage.ci -m pytest
kill -15 $(cat /tmp/_talk_bot.pid)
timeout 3m tail --pid=$(cat /tmp/_talk_bot.pid) -f /dev/null
coverage run --data-file=.coverage.at_the_end -m pytest tests/_tests_at_the_end.py
coverage combine && coverage xml && coverage html
env:
NPA_TIMEOUT: None
NPA_TIMEOUT_DAV: None
Expand Down
29 changes: 29 additions & 0 deletions .run/TalkBot.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TalkBot" type="PythonConfigurationType" factoryName="Python">
<module name="nc_py_api" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="APP_ID" value="talk_bot" />
<env name="APP_PORT" value="9032" />
<env name="APP_SECRET" value="12345" />
<env name="APP_VERSION" value="1.0.0" />
<env name="NEXTCLOUD_URL" value="http://nextcloud.local/index.php" />
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/examples/as_app/talk_bot/src/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [0.0.41 - 2023-08-25]

### Added

- Nextcloud Talk API for bots + example

## [0.0.40 - 2023-08-22]

### Added
Expand Down
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@ Python library that provides a robust and well-documented API that allows develo
* **Easy**: Designed to be easy to use with excellent documentation.

### Capabilities
| **_Capability_** | Nextcloud 26 | Nextcloud 27 | Nextcloud 28 |
|------------------|:------------:|:------------:|:------------:|
| Filesystem* | ✅ | ✅ | ✅ |
| Shares | ✅ | ✅ | ✅ |
| Users & Groups | ✅ | ✅ | ✅ |
| User status | ✅ | ✅ | ✅ |
| Weather status | ✅ | ✅ | ✅ |
| Notifications | ✅ | ✅ | ✅ |
| Nextcloud Talk | ❌ | ❌ | ❌ |
| Text Provider** | ❌ | ❌ | ❌ |
| **_Capability_** | Nextcloud 26 | Nextcloud 27 | Nextcloud 28 |
|-------------------|:------------:|:------------:|:------------:|
| Filesystem* | ✅ | ✅ | ✅ |
| Shares | ✅ | ✅ | ✅ |
| Users & Groups | ✅ | ✅ | ✅ |
| User status | ✅ | ✅ | ✅ |
| Weather status | ✅ | ✅ | ✅ |
| Notifications | ✅ | ✅ | ✅ |
| Nextcloud Talk | ❌ | ❌ | ❌ |
| Talk Bot API** | N/A | ✅ | ✅ |
| Text Processing** | N/A | ❌ | ❌ |
| SpeechToText** | N/A | ❌ | ❌ |

&ast;missing `Trash bin` and `File version` support.<br>
&ast;&ast;available only for NextcloudApp

### Differences between the Nextcloud and NextcloudApp classes

The **Nextcloud** class functions as a standard NextCloud client,
The **Nextcloud** class functions as a standard Nextcloud client,
enabling you to make API requests using a username and password.

On the other hand, the **NextcloudApp** class is designed for creating applications for Nextcloud.<br>
Expand All @@ -66,7 +68,8 @@ You can support us in several ways:
- [Documentation](https://cloud-py-api.github.io/nc_py_api/)
- [First steps](https://cloud-py-api.github.io/nc_py_api/FirstSteps.html)
- [More APIs](https://cloud-py-api.github.io/nc_py_api/MoreAPIs.html)
- [Writing a simple Nextcloud application](https://cloud-py-api.github.io/nc_py_api/NextcloudApp.html)
- [Writing a simple Nextcloud Application](https://cloud-py-api.github.io/nc_py_api/NextcloudApp.html)
- [Using Nextcloud Talk Bot API in Application](https://cloud-py-api.github.io/nc_py_api/NextcloudTalkBot.html)
- [Writing a Nextcloud System Application](https://cloud-py-api.github.io/nc_py_api/NextcloudSysApp.html)
- [Examples](https://github.com/cloud-py-api/nc_py_api/tree/main/examples)
- [Contribute](https://github.com/cloud-py-api/nc_py_api/blob/main/.github/CONTRIBUTING.md)
Expand Down
4 changes: 4 additions & 0 deletions docs/NextcloudTalkBot.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Nextcloud Talk Bot API in Application
=====================================

to-do
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

html_theme_options = {
"display_version": True,
"logo_only": True,
}

# If true, `todos` produce output. Else they produce nothing.
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Have a great time with Python and Nextcloud!
FirstSteps
MoreAPIs
NextcloudApp
NextcloudTalkBot
NextcloudSysApp
Options
reference/index.rst
Expand Down
11 changes: 11 additions & 0 deletions docs/reference/Talk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Talk API
:members:
:inherited-members:

.. autoclass:: nc_py_api.talk.TalkMessage
:members:
:inherited-members:

.. autoclass:: nc_py_api.talk._TalkAPI
:members:

Expand Down Expand Up @@ -48,3 +52,10 @@ Talk API
.. autoclass:: nc_py_api.talk.BreakoutRoomStatus
:members:
:undoc-members:

.. autoclass:: nc_py_api.talk.BotInfo
:members:
:inherited-members:

.. autoclass:: nc_py_api.talk.BotInfoBasic
:members:
17 changes: 17 additions & 0 deletions docs/reference/TalkBot.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.. py:currentmodule:: nc_py_api

Talk Bot API
------------

.. autoclass:: nc_py_api.talk_bot.TalkBotMessage
:members:
:undoc-members:

.. autoclass:: nc_py_api.talk_bot.TalkBot
:members:

.. autoclass:: nc_py_api.talk_bot.ObjectContent
:members:
:undoc-members:

.. autofunction:: nc_py_api.talk_bot.get_bot_secret
1 change: 1 addition & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Reference
ExApp
Exceptions
Talk
TalkBot
Session
2 changes: 1 addition & 1 deletion examples/as_app/skeleton/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.4-slim-bookworm
FROM python:3.11-slim-bookworm

COPY requirements.txt /
ADD /src/ /app/
Expand Down
10 changes: 10 additions & 0 deletions examples/as_app/talk_bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.11-alpine

COPY requirements.txt /
ADD /src/ /app/

RUN \
python3 -m pip install -r requirements.txt && rm -rf ~/.cache && rm requirements.txt

WORKDIR /app
ENTRYPOINT ["python3", "main.py"]
Loading