Example #1
0
async def mentions() -> None:
    """
    Respond to any mentions requesting sauce lookups
    Returns:
        None
    """
    while True:
        try:
            # Mentions
            await twitter.check_mentions()
            await asyncio.sleep(mentioned_interval)
        except Exception:
            log.exception("An unknown error occurred while checking mentions")
            await asyncio.sleep(60.0)
Example #2
0
async def monitored() -> None:
    """
    Query monitored accounts for sauce lookups
    Returns:
        None
    """
    while True:
        try:
            # Monitored accounts
            await twitter.check_monitored()
            await asyncio.sleep(monitored_interval)
        except Exception:
            log.exception(
                "An unknown error occurred while checking monitored accounts")
            await asyncio.sleep(60.0)
Example #3
0
async def search() -> None:
    """
    Perform a search query for our monitored key-phrase and respond to any applicable posts
    Returns:
        None
    """
    while True:
        try:
            # Search query
            await twitter.check_query()
            await asyncio.sleep(search_interval)
        except Exception:
            log.exception(
                "An unknown error occurred while executing a search query")
            await asyncio.sleep(60.0)
Example #4
0
async def cleanup() -> None:
    """
    Purge stale cache entries from the database and display some general analytics
    Returns:
        None
    """
    while True:
        try:
            # Cache purging
            stale_count = TweetCache.purge()
            print(
                f"\nPurging {stale_count:,} stale cache entries from the database"
            )

            # Sauce analytics
            sauce_count = TweetSauceCache.sauce_count(900)
            print(f"We've processed {sauce_count:,} new sauce queries!")

            await asyncio.sleep(900.0)
        except Exception:
            log.exception(
                "An unknown error occurred while performing cleanup tasks")
            await asyncio.sleep(300.0)