move feeds to ptb

This commit is contained in:
2021-03-20 16:21:13 +03:00
parent b35d2ca251
commit e72cb9a453
12 changed files with 38 additions and 52 deletions

View File

@@ -1,5 +1,5 @@
import requests
from telebot import TeleBot
from telegram import Bot
from feeds.models import FeedModuleConfig
@@ -7,7 +7,7 @@ from feeds.models import FeedModuleConfig
class DankMemesFeedModuleConfig(FeedModuleConfig):
MODULE_NAME = 'Dank memes (Reddit)'
def execute(self, bot: TeleBot, chat_id, last_id):
def execute(self, bot: Bot, chat_id, last_id):
posts = requests.get('https://www.reddit.com/r/dankmemes/top.json?sort=top&t=hour',
headers={'User-agent': 'bakatrouble FeedBot 0.1'}).json()
for p in posts['data']['children']:

View File

@@ -1,5 +1,5 @@
from django.db import models
from telebot import TeleBot
from telegram import Bot
from feeds.models import FeedModuleConfig
@@ -9,6 +9,6 @@ class EchoFeedModuleConfig(FeedModuleConfig):
MODULE_NAME = 'Echo'
def execute(self, bot: TeleBot, chat_id, last_id):
def execute(self, bot: Bot, chat_id, last_id):
bot.send_message(chat_id, self.message)
yield None

View File

@@ -1,8 +1,7 @@
import re
from datetime import datetime
import feedparser
from telebot import TeleBot
from telegram import Bot
from telegram.constants import MAX_CAPTION_LENGTH
from feeds.models import FeedModuleConfig
@@ -16,7 +15,7 @@ CAPTION_NEWLINE_RE = re.compile(r'(\w*<p>|</p>\w*){1,2}')
class NerfNowFeedModuleConfig(FeedModuleConfig):
MODULE_NAME = 'NerfNow.com'
def execute(self, bot: TeleBot, chat_id, last_id):
def execute(self, bot: Bot, chat_id, last_id):
if last_id is None:
last_id = ''

View File

@@ -1,5 +1,5 @@
import requests
from telebot import TeleBot
from telegram import Bot
from feeds.models import FeedModuleConfig
@@ -7,7 +7,7 @@ from feeds.models import FeedModuleConfig
class ShittyWatercolourFeedModuleConfig(FeedModuleConfig):
MODULE_NAME = 'Shitty Watercolour (Reddit)'
def execute(self, bot: TeleBot, chat_id, last_id):
def execute(self, bot: Bot, chat_id, last_id):
if last_id is None:
last_id = 0

View File

@@ -1,16 +1,12 @@
import json
import os
import re
from tempfile import TemporaryDirectory
import sentry_sdk
from django.db import models
from djconfig import config
from telebot import TeleBot
from telebot.types import InputMediaPhoto, InputMediaVideo
from bs4 import BeautifulSoup
import requests
from PIL import Image
from telegram import Bot
from feeds.models import FeedModuleConfig
@@ -20,7 +16,7 @@ class TapasFeedModuleConfig(FeedModuleConfig):
MODULE_NAME = 'Tapas.io comic'
def execute(self, bot: TeleBot, chat_id, last_id):
def execute(self, bot: Bot, chat_id, last_id):
config._reload_maybe()
if last_id is None:

View File

@@ -2,8 +2,7 @@ import sentry_sdk
import twitter
from django.db import models
from djconfig import config
from telebot import TeleBot
from telebot.types import InputMediaPhoto, InputMediaVideo
from telegram import Bot, InputMediaPhoto, InputMediaVideo
from feeds.models import FeedModuleConfig
@@ -13,7 +12,7 @@ class TwitterFeedModuleConfig(FeedModuleConfig):
MODULE_NAME = 'Twitter feed'
def execute(self, bot: TeleBot, chat_id, last_id):
def execute(self, bot: Bot, chat_id, last_id):
config._reload_maybe()
if last_id is None:

View File

@@ -1,8 +1,7 @@
import sentry_sdk
from django.db import models
from djconfig import config
from telebot import TeleBot
from telebot.types import InputMediaPhoto
from telegram import Bot, InputMediaPhoto
from vk_api import VkApi
from vk_api.audio import VkAudio
@@ -18,7 +17,7 @@ class VKFeedModuleConfig(FeedModuleConfig):
MODULE_NAME = 'VK feed'
def execute(self, bot: TeleBot, chat_id, last_id):
def execute(self, bot: Bot, chat_id, last_id):
config._reload_maybe()
if last_id is None:

View File

@@ -1,13 +1,8 @@
import logging
import os
import tempfile
import requests
import sentry_sdk
from django.db import models
from djconfig import config
from telebot import TeleBot
from telebot.types import InputMediaPhoto
from telegram import Bot
from vk_api import VkApi
from vk_api.audio import VkAudio
@@ -21,7 +16,7 @@ class VKMusicFeedModuleConfig(FeedModuleConfig):
MODULE_NAME = 'VK music'
def execute(self, bot: TeleBot, chat_id, last_id):
def execute(self, bot: Bot, chat_id, last_id):
config._reload_maybe()
if last_id is None:

View File

@@ -1,6 +1,6 @@
import requests
from django.db import models
from telebot import TeleBot
from telegram import Bot
from feeds.models import FeedModuleConfig
@@ -10,7 +10,7 @@ class WPComicFeedModuleConfig(FeedModuleConfig):
MODULE_NAME = 'WordPress comic'
def execute(self, bot: TeleBot, chat_id, last_id):
def execute(self, bot: Bot, chat_id, last_id):
if last_id is None:
last_id = 0