diff --git a/credentials_test.env b/credentials_test.env index 49f38a7..3981a82 100644 --- a/credentials_test.env +++ b/credentials_test.env @@ -11,9 +11,11 @@ TELEGRAM_GROUP_ID="yo telegram group id here" #twitter things TWITTER_RSS_URL="yo nitter id here" TWITTER_DISCORD_WEBHOOK="yo discord twitter channel here" +TWITTER_DISCORD_WEBHOOK_MAO="yo discord twitter channel here for mao server" #strinova stats voice channel STRINOVA_STAT_CHANNEL_ID="yo strinova stat channel here" +STRINOVA_STAT_CHANNEL_ID_MAO="yo strinova stat channel here for mao server" #me (for purging and other owner only things) OWNER_ID="your discord servers owner id here" diff --git a/main.py b/main.py index 76b75bc..96634e1 100644 --- a/main.py +++ b/main.py @@ -37,11 +37,18 @@ twitter = TwitterRSSForwarder( webhook_url=os.getenv('TWITTER_DISCORD_WEBHOOK'), ) +twitter_mao = TwitterRSSForwarder( + rss_url=os.getenv('TWITTER_RSS_URL'), + webhook_url=os.getenv('TWITTER_DISCORD_WEBHOOK_MAO'), + guid_file='data/last_tweet_mao.txt', +) + @bot.event async def on_ready(): print(f'✅ {bot.user} is online!') asyncio.create_task(forwarder.start()) asyncio.create_task(twitter.start()) + asyncio.create_task(twitter_mao.start()) async def main(): async with bot: @@ -65,6 +72,7 @@ async def main(): finally: await forwarder.stop() twitter.stop() + twitter_mao.stop() logging.basicConfig(level=logging.INFO) logging.getLogger('httpx').setLevel(logging.WARNING) diff --git a/twitterbridge/rss.py b/twitterbridge/rss.py index 71ae69e..0e0d534 100644 --- a/twitterbridge/rss.py +++ b/twitterbridge/rss.py @@ -4,13 +4,14 @@ import asyncio import aiohttp import feedparser -POLL_INTERVAL = 1800 # 30 minutes +POLL_INTERVAL = 300 # 5 minutes GUID_FILE = 'data/last_tweet.txt' class TwitterRSSForwarder: - def __init__(self, rss_url, webhook_url): + def __init__(self, rss_url, webhook_url, guid_file='data/last_tweet.txt'): self.rss_url = rss_url self.webhook_url = webhook_url + self.guid_file = guid_file self.last_guid = None self._running = False @@ -32,13 +33,13 @@ class TwitterRSSForwarder: print('twitter rss forwarder stopped') def _load_last_guid(self): - if os.path.exists(GUID_FILE): - with open(GUID_FILE, 'r') as f: + if os.path.exists(self.guid_file): + with open(self.guid_file, 'r') as f: self.last_guid = f.read().strip() or None def _save_last_guid(self): os.makedirs('data', exist_ok=True) - with open(GUID_FILE, 'w') as f: + with open(self.guid_file, 'w') as f: f.write(self.last_guid or '') async def _poll(self):