Merge branch 'master' of git://github.com/bbonf/fediplay into bbonf-master

This commit is contained in:
Matt Behrens 2018-10-22 19:11:13 -04:00
commit 6fd3e94a4b

View file

@ -13,6 +13,8 @@ from fediplay.queue import Queue
Mastodon = mastodon.Mastodon Mastodon = mastodon.Mastodon
LISTEN_TO_HASHTAG = 'fediplay'
def api_base_url(instance): def api_base_url(instance):
'''Create an API base url from an instance name.''' '''Create an API base url from an instance name.'''
@ -41,7 +43,7 @@ class StreamListener(mastodon.StreamListener):
return return
tags = extract_tags(status) tags = extract_tags(status)
if 'fediplay' in tags: if LISTEN_TO_HASHTAG in tags:
links = extract_links(status) links = extract_links(status)
for link in links: for link in links:
try: try:
@ -83,6 +85,8 @@ def stream(instance, users, client_id, client_secret, access_token, cache_dir='.
users = [normalize_username(user, instance) for user in users] users = [normalize_username(user, instance) for user in users]
listener = StreamListener(Queue(cache_dir), instance, users) listener = StreamListener(Queue(cache_dir), instance, users)
click.echo('==> Streaming from {}'.format(instance)) click.echo('==> Streaming from {}'.format(instance))
for t in client.timeline_hashtag(LISTEN_TO_HASHTAG, limit=1):
listener.on_update(t)
client.stream_user(listener) client.stream_user(listener)
def extract_tags(toot): def extract_tags(toot):