ai memory increased
This commit is contained in:
1 parent
6c77f14e42
commit
8b336ccced
6 files changed
+119
-33
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import os
|
||||
import aiohttp
|
||||
import feedparser
|
||||
from discord.ext import commands
|
||||
|
||||
class TwitterLeaks(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command()
|
||||
async def leaks(self, ctx):
|
||||
rss_url = os.getenv('TWITTER_RSS_URL')
|
||||
if not rss_url:
|
||||
return await ctx.reply('rss url not configured.')
|
||||
|
||||
try:
|
||||
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'}
|
||||
async with aiohttp.ClientSession(headers=headers) as session:
|
||||
async with session.get(rss_url) as resp:
|
||||
text = await resp.text()
|
||||
|
||||
feed = feedparser.parse(text)
|
||||
if not feed.entries:
|
||||
return await ctx.reply('no tweets found.')
|
||||
|
||||
response = "**Latest 5 Leaks:**\n"
|
||||
for entry in feed.entries[:5]:
|
||||
title = entry.get('title', '')
|
||||
link = entry.get('link', '')
|
||||
|
||||
if 'nitter.net' in link:
|
||||
link = link.replace('nitter.net', 'twitter.com').replace('#m', '')
|
||||
|
||||
response += f"\n{title}\n{link}\n"
|
||||
|
||||
await ctx.reply(response[:2000])
|
||||
except Exception as e:
|
||||
await ctx.reply(f'failed to fetch leaks: {e}')
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(TwitterLeaks(bot))
|
||||
Reference in new issue
Block a user