move modules out
This commit is contained in:
parent
e7d9324df8
commit
b0d651ee92
@ -1,7 +1,7 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Feed, EchoFeedModuleConfig
|
||||
|
||||
from .models import Feed
|
||||
from feeds.modules.echo import EchoFeedModuleConfig
|
||||
|
||||
admin.site.register(Feed)
|
||||
admin.site.register(EchoFeedModuleConfig)
|
||||
|
18
feeds/migrations/0003_auto_20190119_0249.py
Normal file
18
feeds/migrations/0003_auto_20190119_0249.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.1.5 on 2019-01-19 02:49
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('feeds', '0002_feed_lock'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='feed',
|
||||
name='check_interval',
|
||||
field=models.DurationField(help_text='in seconds'),
|
||||
),
|
||||
]
|
@ -54,15 +54,3 @@ class FeedModuleConfig(models.Model):
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class EchoFeedModuleConfig(FeedModuleConfig):
|
||||
message = models.TextField()
|
||||
|
||||
MODULE_NAME = 'Echo'
|
||||
|
||||
def execute(self, bot: TeleBot, chat_id, last_id):
|
||||
bot.send_message(chat_id, self.message)
|
||||
|
||||
|
||||
FEED_MODULES = [EchoFeedModuleConfig]
|
||||
|
3
feeds/modules/__init__.py
Normal file
3
feeds/modules/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from .echo import EchoFeedModuleConfig
|
||||
|
||||
FEED_MODULES = [EchoFeedModuleConfig]
|
13
feeds/modules/echo.py
Normal file
13
feeds/modules/echo.py
Normal file
@ -0,0 +1,13 @@
|
||||
from django.db import models
|
||||
from telebot import TeleBot
|
||||
|
||||
from feeds.models import FeedModuleConfig
|
||||
|
||||
|
||||
class EchoFeedModuleConfig(FeedModuleConfig):
|
||||
message = models.TextField()
|
||||
|
||||
MODULE_NAME = 'Echo'
|
||||
|
||||
def execute(self, bot: TeleBot, chat_id, last_id):
|
||||
bot.send_message(chat_id, self.message)
|
@ -7,7 +7,8 @@ from django.views.generic import ListView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
|
||||
from cabinet.utils import CabinetViewMixin
|
||||
from feeds.models import Feed, FEED_MODULES
|
||||
from feeds.models import Feed
|
||||
from feeds.modules import *
|
||||
from feeds.utils import BaseFeedConfigView
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user