halcy / Mastodon.py

Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
MIT License
867 stars 150 forks source link

Unable to view direct messages. #329

Closed rdearman closed 1 year ago

rdearman commented 1 year ago

I am able to get everything on the timeline, but can't seem to return direct messages. I have been searching the API documentation, but there doesn't appear to be any function or method that is obvious to me. Any assistance would be appreciated. My function currently looks like this:

def get_direct_messages(mastodon):                                                                           
    # Get all status messages from the user's timeline                                                       
    statuses = mastodon.timeline()                                                                           
    print(statuses)                                                                                          
    # Filter the status messages to only include direct messages                                             
    direct_messages = [status for status in statuses if status["visibility"] == "direct"]                    

    print (direct_messages)                                                                                  

    return direct_messages      

This will print out all the messages on the timeline, so I know the connection and everything is valid, but I'm just not doing something right. print(statuses) shows timeline messages only, so I am sure this isn't the right way to access direct messages.

rdearman commented 1 year ago

I should have been using conversations() not timeline().

Closed, user error.