twitter leaks for mao
This commit is contained in:
1 parent
becfa5a568
commit
58f46611a6
3 files changed
+16
-5
No files matched your search
@@ -11,9 +11,11 @@ TELEGRAM_GROUP_ID="yo telegram group id here"
|
|||||||
#twitter things
|
#twitter things
|
||||||
TWITTER_RSS_URL="yo nitter id here"
|
TWITTER_RSS_URL="yo nitter id here"
|
||||||
TWITTER_DISCORD_WEBHOOK="yo discord twitter channel 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 stats voice channel
|
||||||
STRINOVA_STAT_CHANNEL_ID="yo strinova stat channel here"
|
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)
|
#me (for purging and other owner only things)
|
||||||
OWNER_ID="your discord servers owner id here"
|
OWNER_ID="your discord servers owner id here"
|
||||||
|
|||||||
@@ -37,11 +37,18 @@ twitter = TwitterRSSForwarder(
|
|||||||
webhook_url=os.getenv('TWITTER_DISCORD_WEBHOOK'),
|
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
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f'✅ {bot.user} is online!')
|
print(f'✅ {bot.user} is online!')
|
||||||
asyncio.create_task(forwarder.start())
|
asyncio.create_task(forwarder.start())
|
||||||
asyncio.create_task(twitter.start())
|
asyncio.create_task(twitter.start())
|
||||||
|
asyncio.create_task(twitter_mao.start())
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
async with bot:
|
async with bot:
|
||||||
@@ -65,6 +72,7 @@ async def main():
|
|||||||
finally:
|
finally:
|
||||||
await forwarder.stop()
|
await forwarder.stop()
|
||||||
twitter.stop()
|
twitter.stop()
|
||||||
|
twitter_mao.stop()
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logging.getLogger('httpx').setLevel(logging.WARNING)
|
logging.getLogger('httpx').setLevel(logging.WARNING)
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import asyncio
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import feedparser
|
import feedparser
|
||||||
|
|
||||||
POLL_INTERVAL = 1800 # 30 minutes
|
POLL_INTERVAL = 300 # 5 minutes
|
||||||
GUID_FILE = 'data/last_tweet.txt'
|
GUID_FILE = 'data/last_tweet.txt'
|
||||||
|
|
||||||
class TwitterRSSForwarder:
|
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.rss_url = rss_url
|
||||||
self.webhook_url = webhook_url
|
self.webhook_url = webhook_url
|
||||||
|
self.guid_file = guid_file
|
||||||
self.last_guid = None
|
self.last_guid = None
|
||||||
self._running = False
|
self._running = False
|
||||||
|
|
||||||
@@ -32,13 +33,13 @@ class TwitterRSSForwarder:
|
|||||||
print('twitter rss forwarder stopped')
|
print('twitter rss forwarder stopped')
|
||||||
|
|
||||||
def _load_last_guid(self):
|
def _load_last_guid(self):
|
||||||
if os.path.exists(GUID_FILE):
|
if os.path.exists(self.guid_file):
|
||||||
with open(GUID_FILE, 'r') as f:
|
with open(self.guid_file, 'r') as f:
|
||||||
self.last_guid = f.read().strip() or None
|
self.last_guid = f.read().strip() or None
|
||||||
|
|
||||||
def _save_last_guid(self):
|
def _save_last_guid(self):
|
||||||
os.makedirs('data', exist_ok=True)
|
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 '')
|
f.write(self.last_guid or '')
|
||||||
|
|
||||||
async def _poll(self):
|
async def _poll(self):
|
||||||
|
|||||||
Reference in new issue
Block a user