def check_feed(): FEED = feedparser.parse(feed_url) entry = FEED.entries[0] if entry.id != db.get_link(feed_url).link: # ↓ Edit this message as your needs. message = "/torrent " f"{entry.link}" try: app.send_message(log_channel, message) db.update_link(feed_url, entry.id) except FloodWait as e: print(f"FloodWait: {e.x} seconds") sleep(e.x) except Exception as e: print(e)
def check_feed(): FEED = feedparser.parse(feed_url) entry = FEED.entries[0] if entry.id != db.get_link(feed_url).link: # ↓ Edit this message as your needs. message = f"**{entry.title}**\n```{entry.link}```" try: app.send_message(log_channel, message) db.update_link(feed_url, entry.id) except FloodWait as e: print(f"FloodWait: {e.x} seconds") sleep(e.x) except Exception as e: print(e) else: print(f"Checked RSS FEED: {entry.id}")
def check_feed(): FEED = feedparser.parse(feed_url) entry = FEED.entries[0] if entry.id != db.get_link(feed_url).link: # ↓ Edit this message as your needs. dt = parser.parse(entry.published) published = dt.astimezone(tz.gettz('Asia/Kolkata')) date = published.strftime(fmt) message = f"**{entry.title}**\n```{entry.link}```\n**{date}**" try: app.send_message(log_channel, message) db.update_link(feed_url, entry.id) except FloodWait as e: print(f"FloodWait: {e.x} seconds") sleep(e.x) except Exception as e: print(e) else: print(f"Checked RSS FEED: {entry.id}")
log_channel = "-1001363921137" # Telegram Channel ID where the bot is added and have write permission. You can use group ID too. check_interval = 5 # Check Interval in seconds. max_instances = 5 # Max parallel instance to be used. if os.environ.get( "ENV" ): # Add a ENV in Environment Variables if you wanna configure the bot via env vars. api_id = os.environ.get("APP_ID") api_hash = os.environ.get("API_HASH") feed_url = os.environ.get("FEED_URL") bot_token = os.environ.get("BOT_TOKEN") log_channel = int(os.environ.get("LOG_CHANNEL", None)) check_interval = int(os.environ.get("INTERVAL", 5)) max_instances = int(os.environ.get("MAX_INSTANCES", 5)) if db.get_link(feed_url) == None: db.update_link(feed_url, "*") app = Client(":memory:", api_id=api_id, api_hash=api_hash, bot_token=bot_token) def check_feed(): FEED = feedparser.parse(feed_url) entry = FEED.entries[0] if entry.id != db.get_link(feed_url).link: # ↓ Edit this message as your needs. message = f"**{entry.title}**\n```{entry.link}```" try: app.send_message(log_channel, message) db.update_link(feed_url, entry.id) except FloodWait as e: print(f"FloodWait: {e.x} seconds")