def __init__(self, client):
super().__init__(client, "timelines/home", {})
+class PublicTimelineFeed(IncrementalServerFeed):
+ def __init__(self, client, local):
+ super().__init__(client, "timelines/public", {
+ 'local': {False:"false", True:"true"}[local]
+ })
+
class MentionsFeed(IncrementalServerFeed):
def __init__(self, client):
super().__init__(client, "notifications", {"types[]":['mention']},
'exclude_reblogs': not include_boosts,
})
+class HashtagStatusesFeed(IncrementalServerFeed):
+ def __init__(self, client, hashtag):
+ super().__init__(client, f"timelines/tag/{hashtag}", {})
+
class UserListFeed(IncrementalServerFeed):
def __init__(self, client, url):
super().__init__(client, url, {})
'H', text.ColouredString("Home timeline",
"K ")))
self.items.append(text.BlankLine())
+ self.items.append(text.MenuKeypressLine(
+ 'P', text.ColouredString("Public timeline (all servers)",
+ "K ")))
+ self.items.append(text.MenuKeypressLine(
+ 'L', text.ColouredString("Local public timeline (this server)",
+ "K ")))
+ self.items.append(text.MenuKeypressLine(
+ '#', text.ColouredString("Timeline for a #hashtag",
+ " K ")))
+ self.items.append(text.BlankLine())
self.items.append(text.MenuKeypressLine(
'C', text.ColouredString("Compose a post",
"K ")))
self.push_to(self.cc.home_timeline)
elif ch in {'c', 'C'}:
self.push_to(self.cc.get_composer())
+ elif ch in {'p', 'P'}:
+ feed = client.PublicTimelineFeed(self.cc, local=False)
+ title = text.ColouredString("Public timeline <P>",
+ "HHHHHHHHHHHHHHHHHHHKH")
+ self.push_to(StatusFile(self.cc, feed, title))
+ elif ch in {'l', 'L'}:
+ feed = client.PublicTimelineFeed(self.cc, local=True)
+ title = text.ColouredString("Local public timeline <L>",
+ "HHHHHHHHHHHHHHHHHHHHHHHHHKH")
+ self.push_to(StatusFile(self.cc, feed, title))
+ elif ch in {'#'}:
+ self.push_to(BottomLinePrompt(
+ self.cc, self.got_hashtag_to_view,
+ "View feed for hashtag: "))
else:
return super().handle_key(ch)
+ def got_hashtag_to_view(self, tag):
+ tag = tag.strip().lstrip("@")
+ if tag == "":
+ return
+
+ feed = client.HashtagStatusesFeed(self.cc, tag)
+ title = text.ColouredString(
+ f"Posts mentioning hashtag #{tag}", 'H')
+ self.push_to(StatusFile(self.cc, feed, title))
+
class EscMenu(Menu):
def __init__(self, cc):
super().__init__(cc)