get=lambda item: item['status'])
class UserStatusesFeed(IncrementalServerFeed):
- def __init__(self, client, account_id):
- super().__init__(client, f"accounts/{account_id}/statuses", {})
+ def __init__(self, client, account_id, include_boosts=True,
+ include_replies=True):
+ super().__init__(client, f"accounts/{account_id}/statuses", {
+ 'exclude_replies': not include_replies,
+ 'exclude_reblogs': not include_boosts,
+ })
class UserListFeed(IncrementalServerFeed):
def __init__(self, client, url):
sl.keys.append(('F', 'List Favouriters'))
sl.keys.append(('B', 'List Boosters'))
sl.keys.append(('Q', 'Quit'))
+ elif self.mode == 'list_posts':
+ if isinstance(self, UserInfoFile):
+ sl.keys.append(('A', 'All'))
+ sl.keys.append(('O', 'Original'))
+ sl.keys.append(('T', 'Top-level'))
+ sl.keys.append(('Q', 'Quit'))
else:
if self.linepos >= len(self.lines):
sl.keys.append(('-', 'Up'))
def handle_key(self, ch):
if self.mode == 'normal' and ch in {'p', 'P'}:
- feed = client.UserStatusesFeed(self.cc, self.account_id)
+ self.mode = 'list_posts'
+ elif self.mode == 'list_posts' and ch in {'a', 'A'}:
+ feed = client.UserStatusesFeed(
+ self.cc, self.account_id,
+ include_boosts=True, include_replies=True)
+ name = self.cc.fq(self.account['acct'])
+ title = text.ColouredString(f"All posts from user {name}", 'H')
+ self.chain_to(StatusFile(self.cc, feed, title))
+ elif self.mode == 'list_posts' and ch in {'o', 'O'}:
+ feed = client.UserStatusesFeed(
+ self.cc, self.account_id,
+ include_boosts=False, include_replies=True)
+ name = self.cc.fq(self.account['acct'])
+ title = text.ColouredString(f"Original posts from user {name}", 'H')
+ self.chain_to(StatusFile(self.cc, feed, title))
+ elif self.mode == 'list_posts' and ch in {'t', 'T'}:
+ feed = client.UserStatusesFeed(
+ self.cc, self.account_id,
+ include_boosts=False, include_replies=False)
name = self.cc.fq(self.account['acct'])
- title = text.ColouredString(f"Posts from user {name}", 'H')
+ title = text.ColouredString(
+ f"Top-level posts from user {name}", 'H')
self.chain_to(StatusFile(self.cc, feed, title))
+ elif self.mode == 'list_posts':
+ self.mode = 'normal'
+
elif self.mode == 'normal' and ch in {'l', 'L'}:
self.mode = 'list_users'
elif self.mode == 'list_users' and ch in {'i', 'I'}:
self.chain_to(UserListFile(self.cc, feed, title))
elif self.mode == 'list_users':
self.mode = 'normal'
+
else:
return super().handle_key(ch)