add feed modules
This commit is contained in:
17
feeds/modules/dank_memes.py
Normal file
17
feeds/modules/dank_memes.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import requests
|
||||
from telebot import TeleBot
|
||||
|
||||
from feeds.models import FeedModuleConfig
|
||||
|
||||
|
||||
class DankMemesFeedModuleConfig(FeedModuleConfig):
|
||||
MODULE_NAME = 'Dank memes (Reddit)'
|
||||
|
||||
def execute(self, bot: TeleBot, 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']:
|
||||
if p['kind'] == 't3' and 'post_hint' in p['data'] and p['data']['post_hint'] == 'image':
|
||||
p = p['data']
|
||||
bot.send_photo(chat_id, p['url'])
|
||||
break
|
Reference in New Issue
Block a user