Implement Telegram notifications

Some refactoring
This commit is contained in:
Kumi 2020-12-29 17:26:48 +01:00
parent 52d86d0bc6
commit 64a757b2de
146 changed files with 359 additions and 13 deletions

View file

@ -34,4 +34,14 @@ The application is then available at [http://localhost:8000/].
If you want to make your Kumify instance available through a network, you will need to set up something like gunicorn and nginx. How this works is beyond the scope of this document. To prepare your static files for this, make sure ```STATIC_ROOT``` is set to the correct location in localsettings.py if you don't use S3, then run:
```python3 manage.py collectstatic```
```python3 manage.py collectstatic```
### Cron job
In order to use scheduled tasks, you need to make sure that the ```/cron/``` endpoint is called at regular intervals. Every five minutes should work fine. Use a command like ```curl http://localhost:8000/cron/```, for example.
### Telegram webhook
If you wish to receive incoming messages through the Telegram gateway, your server must be reachable from the Internet. Configure a public IP/domain name as well as an HTTPS certificate, then run:
```python3 manage.py telegramwebhook```

0
cronhandler/__init__.py Normal file
View file

3
cronhandler/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
cronhandler/apps.py Normal file
View file

@ -0,0 +1,5 @@
from django.apps import AppConfig
class CronhandlerConfig(AppConfig):
name = 'cronhandler'

3
cronhandler/models.py Normal file
View file

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
cronhandler/signals.py Normal file
View file

@ -0,0 +1,3 @@
from django.dispatch import Signal
cron = Signal()

3
cronhandler/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

9
cronhandler/urls.py Normal file
View file

@ -0,0 +1,9 @@
from .views import CronHandlerView
from django.urls import path
app_name = "cron"
urlpatterns = [
path('', CronHandlerView.as_view(), name="cronhandler"),
]

8
cronhandler/views.py Normal file
View file

@ -0,0 +1,8 @@
from django.views.generic import View
from django.http import HttpResponse
from .signals import cron
class CronHandlerView(View):
def get(self, *args, **kwargs):
return HttpResponse()

Some files were not shown because too many files have changed in this diff Show more