initial commit

This commit is contained in:
2019-01-11 22:16:01 +03:00
commit 24c5f2fcf6
312 changed files with 186972 additions and 0 deletions

24
feeds/tasks.py Normal file
View File

@@ -0,0 +1,24 @@
from django.utils import timezone
from telebot import TeleBot
from config.celery import app
@app.task()
def execute_feed(feed_pk):
from feeds.models import Feed
try:
feed = Feed.objects.get(pk=feed_pk)
if not feed.lock:
feed.lock = True
feed.save()
bot = TeleBot('450146961:AAFcb9tyIiKAi6BHR1ZYfWuTEkYjhO3xEFE')
feed.last_id = feed.config.execute(bot, feed.chat_id, feed.last_id)
feed.last_check = timezone.now()
feed.save()
finally:
feed.lock = False
feed.save()