Skip to content

Commit

Permalink
Edit locales, docstrings and repo info.
Browse files Browse the repository at this point in the history
  • Loading branch information
blvdek committed Jul 9, 2024
1 parent d0955f5 commit 6de7da4
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 80 deletions.
75 changes: 15 additions & 60 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,45 @@
<!-- omit in toc -->
# Contributing to nc_tg_bot

First off, thanks for taking the time to contribute! ❤️

All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉

> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
> - Star the project
> - Tweet about it
> - Refer this project in your project's readme
> - Mention the project at local meetups and tell your friends/colleagues
Contributions are welcome! Please see the [Table of Contents](#table-of-contents) for details on how to contribute.

<!-- omit in toc -->
## Table of Contents

- [I Have a Question](#i-have-a-question)
- [I Want To Contribute](#i-want-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Your First Code Contribution](#your-first-code-contribution)

## Code of Conduct

This project and everyone participating in it is governed by the
[nc_tg_bot Code of Conduct](https://github.com/blvdek/nc_tg_bot/blob/main/.github/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code.

## I Have a Question

Before you ask a question, it is best to search for existing [Issues](https://github.com/blvdek/nc_tg_bot/issues) and [Discussions](https://github.com/blvdek/nc_tg_bot/discussions) that might help you. In case you have found a suitable issue or discussion and still need clarification, you can write your question in there. It is also advisable to search the internet for answers first.

If you then still feel the need to ask a question and need clarification, we recommend the following:

- Open an [Issue](https://github.com/blvdek/nc_tg_bot/issues/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions, depending on what seems relevant.
- Provide context and project/platform versions as needed.

## I Want To Contribute

### Reporting Bugs

<!-- omit in toc -->
#### Before Submitting a Bug Report

A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.

- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions.
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/blvdek/nc_tg_botissues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
- Collect information about the bug.

<!-- omit in toc -->
#### How Do I Submit a Good Bug Report?

We use GitHub issues to track bugs and errors. If you run into an issue with the project:

- Make sure you are using the latest version.
- Determine if your bug is really a bug and not an error on your side.
- Check for existing bug reports and internet discussions.
- Open an [Issue](https://github.com/blvdek/nc_tg_bot/issues/new?template=BUG_REPORT.md).
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.
- Provide a clear description of the expected and actual behavior.
- Describe the reproduction steps and provide context and version information.

### Your First Code Contribution

### Suggesting Enhancements

This section guides you through submitting an enhancement suggestion for nc_tg_bot, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.

<!-- omit in toc -->
#### Before Submitting an Enhancement

- Make sure that you are using the latest version.
- Find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/blvdek/nc_tg_bot/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.

<!-- omit in toc -->
#### How Do I Submit a Good Enhancement Suggestion?

Enhancement suggestions are tracked as [GitHub issues](https://github.com/blvdek/nc_tg_bot/issues). We have a template for enhancement suggestions that you can use as a guide. You can access it [here](https://github.com/blvdek/nc_tg_bot/issues/new?template=FEATURE_REQUEST.md).

- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.s
- **Explain why this enhancement would be useful** to most nc_tg_bot users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
1. Fork the repository.
2. Create a new branch.
3. Clone your forked repository.
4. Set the current working directory to the root folder of the cloned repository.

### Your First Code Contribution

> 💡 Remember that nc_tg_bot is built on top of [aiogram](https://github.com/aiogram/aiogram) and [nc_py_api](https://github.com/cloud-py-api/nc_py_api) libraries, so integrating new features with these libraries is pretty easy.
1. `Fork` this repository
2. Create a `branch`
3. `Clone` your nc_tg_bot fork.
Expand All @@ -112,6 +66,7 @@ pre-commit install
docker compose -f docker-compose.build.yaml up
```
- Or without docker compose:

* Make migrations:
```bash
make migrate
Expand Down
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@

## 🤖 About Nextcloud Telegram Bot

This Telegram bot simplifies the process of interacting with Nextcloud, allowing users to easily share files without navigating the Nextcloud interface directly.
This Telegram bot simplifies the process of interacting with Nextcloud, allowing users to easily share files without navigating the Nextcloud interface directly. It also provides the following functionalities:

- File management: users can navigate through the file hierarchy and manage files and folders.
- Trash bin management: users can restore or delete files from the trash bin.
- Search by name: users can search for files by their name.

Much more can be easily implemented using the nc_py_api and aigoram libraries.


## ❓Motivation

I created a Telegram bot to simplify sharing memes on Nextcloud for myself and friends. It provides a user-friendly interface for efficient communication and collaboration. The project streamlines the sharing process and enhances efficiency. This experience will be valuable in future projects involving external service integration with Telegram.
I created a Telegram bot to simplify sharing memes on Nextcloud for myself and friends. It provides a user-friendly interface for efficient communication and collaboration. The project streamlines the sharing process and enhances efficiency. This experience will be valuable in my future projects involving external service integration with Telegram.


## 🚀 How to Use
Expand Down Expand Up @@ -107,11 +114,13 @@ To launch the bot you only need a token bot, database, Redis and Nextcloud setti

To use the Nextcloud Telegram bot with Nextcloud, you can create a Docker Compose file that runs on the same Docker network as Nextcloud. This allows the bot to communicate with Nextcloud internally.

To do this, you need to set the NC__PROTOCOL and NC__HOST environment variables in your Docker Compose file. These variables are used for internal communication between the bot and Nextcloud.
To do this, you need to set the NC__PROTOCOL, NC__HOST and NC__PORT environment variables in your Docker Compose file or .env. These variables are used for internal communication between bot and Nextcloud.

If the internal and external host and port are different, you can set the NC__EXT_HOST and NC__EXT_PORT variables. These variables are used for the external access link that the bot will send.
If the internal and external host are different, you can set the NC__OVERWRITE__PROTOCOL, NC__OVERWRITE__HOST and NC__OVERWRITE__PORT variables. These variables are used for the external access link that the bot will send.

If your NC__PROTOCOL and NC__HOST are already accessible from outside, you don't need to specify NC__EXT_HOST and NC__EXT_PORT. In this case, the bot will use NC__PROTOCOL and NC__HOST as the external access points.
If your NC__PROTOCOL, NC__HOST and NC__PORT are already accessible from outside, you don't need to specify NC__OVERWRITE__PROTOCOL, NC__OVERWRITE__HOST and NC__OVERWRITE__PORT. In this case, the bot will use NC__PROTOCOL, NC__HOST and NC__PORT as the external access points.

> 💡For example, you set the parameters of the docker internal network for NC__HOST and other default variables, then links of the following type will be created: http://nextcloud:80/... The user will not be able to open such links in browser, but if you specify OVERWRITE, the host will be replaced with OVERWRITE and the links will look like, for example: https://exmaple.com:80/... and the user will already be able to open such links in his browser.
Here's an example of how you can configure this in your Docker Compose file:

Expand Down Expand Up @@ -197,6 +206,11 @@ networks:


## ⭐ Support
If you find this project useful, you can support it in the following ways:

- [🌟 Star](https://github.com/blvdek/nc_tg_bot/stargazers) the repository.
- [💬 Contribute](https://github.com/blvdek/nc_tg_bot/blob/main/.github/CONTRIBUTING.md) to the project.
- [📣 Share](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Fblvdek%2Fnc_tg_bot&text=Nextcloud%20Telegram%20Bot) this project on social media.


## ❗ More information
Expand Down
5 changes: 4 additions & 1 deletion bot/core/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
storage backend and integrating with the Telegram API.
"""

from collections.abc import Callable
from typing import Any, cast

from aiogram import Bot, Dispatcher
from aiogram.client.default import DefaultBotProperties
from aiogram.client.session.aiohttp import AiohttpSession
Expand Down Expand Up @@ -42,4 +45,4 @@
else MemoryStorage()
)

dp = Dispatcher(storage=_storage, _session_maker=session_maker)
dp = Dispatcher(storage=_storage, _session_maker=cast(Callable[[], Any], session_maker))
2 changes: 1 addition & 1 deletion bot/filters/only_private_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class OnlyPrivateFilter(BaseFilter):
"""Filter to check if the event is a private message or a callback query in a private chat."""
"""Filter to check if the event is a message in a private chat."""

async def __call__(self, event: TelegramObject, i18n: I18nContext) -> bool:
"""Check chat is private."""
Expand Down
6 changes: 2 additions & 4 deletions bot/locales/en/deafult.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ help =
<b>Before starting to work with the bot, you need to go through authentication, enter /auth.</b> The site will open inside Telegram if the protocol is secure, otherwise, you will need to manually copy the link and open it in a browser to go through authentication. The time for authentication is limited, about which will be said in the authentication message.
<b>Safety</b>
You can use the bot in various chats, but keep in mind that other chat users will see the contents of your folders and various file information that may be confidential. But only the user who called the menu message can press the menu buttons.
---
After going through authentication, you will get the main menu with various possibilities:
Expand All @@ -31,6 +27,8 @@ help =
<u>{ fsnode-download-button }:</u> After pressing, the bot will send you a message with the attached file as a document. If the file size exceeds the set limit in the bot settings (20MB by default), then a link to the file will be sent, which will be valid for 8 hours. Only files, but not directories, can be downloaded.
<u>{ fsnode-new-button }:</u> Open the file creation menu where you can upload something to Nextcloud or create a folder.
<u>{ fsnode-upload-button }:</u> After pressing, the bot switches to waiting mode for the files you want to upload. Send the files, but keep in mind that only documents will be uploaded. When you finish sending files or change your mind, press the "{ stop-button }" button to return to the file management menu. Then, you will receive a new menu with an updated list of files inside the directory, where the new folder will appear. If you decide not to create a folder, press the "{ cancel-button }".
<u>{ fsnode-mkdir-button }:</u> Бот перейдет в режим ожидания названия папки. После отправки вами названия папки, папка будет создана и вам придет новое меню управления файлом с обновленным списком файлов внутри директории, где и появится новая папка. Если вы передумали создавать папку, то нажмите кнопку "{ cancel-button }".
Expand Down
2 changes: 1 addition & 1 deletion bot/locales/en/fsnode.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ fsnode-delete-button = 🔴 Delete
fsnode-download-button = ⬇️ Download
fsnode-new-button = 🆕 New
fsnode-upload-button = ⬆️ Upload
fsnode-mkdir-button = 🆕 Create folder
fsnode-mkdir-button = 📁 Create folder
fsnode-pag-back-button = ⬅️
fsnode-pag-next-button = ➡️
8 changes: 3 additions & 5 deletions bot/locales/ru/deafult.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ help =
<b>Прежде, чем начать работу с ботом, вам необходимо пройти авторизацию, для этого введите /auth.</b> Сайт откроется внутри телеграмма, если протокол защищенный, в ином случае вам нужно вручную скопировать ссылку и открыть ее в браузере, чтобы пройти авторизацию. Время на авторизацию ограничено, о чем будет сказано в сообщении авторизации.
<b>Безопасность</b>
Вы можете использовать бота в различных чатах, но учитывайте, что остальные пользователи чата увидят содержимое ваших папок и различную информацию о файлах, которая может быть конфиденциальной. Но нажимать на кнопки меню может только тот пользователь, который вызвал сообщение с этим меню.
---
После прохождения авторизации у вас появится главное меню с разными возможностями:
Expand All @@ -31,6 +27,8 @@ help =
<u>{ fsnode-download-button }:</u> После нажатия, бот вам отправит сообщение с прикрепленным файлов в виде документа. Если размер файла превышает заданный лимит в настройках бота (20Мб по умолчанию), то отправиться ссылка на файл, которая будет действительная в течение 8 часов. Скачать можно только файлы, но не директории.
<u>{ fsnode-new-button }:</u> Вызвать меню создани файла, в котором можно что-либо загрузить в Nextcloud или создать папку.
<u>{ fsnode-upload-button }:</u> После нажатия бот переходит в режим ожидания файлов, которые вы хотите загрузить. Отправьте файлы, но учитываете, что будут загружены только файлы, отправленные в формате документа. Когда вы закончили отправлять файлы или передумали, нажмите кнопку "{ stop-button }", чтобы вернуться в режим меню управления файлом. После, вам придет новое меню с обновленным списком файлов внутри директории.
<u>{ fsnode-mkdir-button }:</u> Бот перейдет в режим ожидания названия папки. После отправки вами названия папки, папка будет создана и вам придет новое меню управления файлом с обновленным списком файлов внутри директории, где и появится новая папка. Если вы передумали создавать папку, то нажмите кнопку "{ cancel-button }".
Expand Down Expand Up @@ -65,7 +63,7 @@ help =
<b>Open Source</b>
Этот бот является проектом с открыт исходным кодом. Вы можете поучаствовать в разработке.
Этот бот является проектом с открытым исходным кодом. Вы можете поучаствовать в разработке.
<i><a href="https://github.com/blvdek/nc_tg_bot">Исходный код</a></i>
Expand Down
2 changes: 1 addition & 1 deletion bot/middlewares/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async def get_locale(self, event_from_user: TgUser | None = None) -> str:
msg = "Event object must have the 'from_user' attribute."
raise ValueError(msg)
if event_from_user.language_code is None:
msg = ""
msg = "Telegram 'User' must have the 'language_code' attribute."
raise ValueError(msg)
return event_from_user.language_code

Expand Down
10 changes: 9 additions & 1 deletion docker-compose.build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
services:
nextcloud:
image: nextcloud
restart: always
ports:
- 8080:80
volumes:
- nc-data:/var/www/html

redis:
image: redis:alpine
restart: on-failure
Expand Down Expand Up @@ -26,4 +34,4 @@ services:
volumes:
redis-data:
db-data:
nc-data:
nc-data:
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ services:
- db
volumes:
redis-data:
db-data:
db-data:
nc-data:

0 comments on commit 6de7da4

Please sign in to comment.