Created
November 26, 2022 23:59
-
-
Save dieseltravis/3f972fb7d53192e5d124af9e904a22f9 to your computer and use it in GitHub Desktop.
TimelineListener class using StreamListener from Mastodon.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from mastodon import Mastodon, StreamListener | |
# etc... | |
class TimelineListener(StreamListener): | |
def __init__(self): | |
print("Listener created.") | |
def on_notification(self, notification): | |
print("Notification: " + notification['type']) | |
if notification['type'] == 'follow': | |
on_follow(_client, notification['account']) | |
def on_update(self, update): | |
print("Update: " + update['visibility']) | |
if update['visibility'] == 'public': | |
on_timeline(_client, update) | |
if update['visibility'] == 'direct': | |
on_message(_client, update) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment