Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MastodonのストリーミングAPIを取得するサンプルスクリプト
from mastodon import Mastodon, StreamListener
mstdn = Mastodon(
client_id = 'YOUR_CLIENT_ID',
client_secret = 'YOUR_CLIENT_SECRET',
api_base_url = 'https://social.mikutter.hachune.net'
)
mstdn.log_in(
username = 'YOUR_ENAIL',
password = 'YOUR_PASSWORD',
scopes=['read', 'write'],
)
class MaStreamListener(StreamListener):
def on_update(self, status):
print "HOGE"
def on_notification(self, notification):
print "FUGA"
def on_delete(self, status_id):
print "PIYO"
def handle_heartbeat(self):
print "PING-PONG"
mstdn.user_stream(MaStreamListener(), async=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment