sl.keys.append(('-', None))
sl.keys.append(('+', None))
sl.keys.append(('Q', 'Quit'))
+ elif self.mode == 'list_users':
+ if isinstance(self, UserInfoFile):
+ sl.keys.append(('I', 'List Followers'))
+ sl.keys.append(('O', 'List Followed'))
+ if isinstance(self, StatusInfoFile):
+ sl.keys.append(('F', 'List Favouriters'))
+ sl.keys.append(('B', 'List Boosters'))
+ sl.keys.append(('Q', 'Quit'))
else:
if self.linepos >= len(self.lines):
sl.keys.append(('-', 'Up'))
# sl.keys.append(('E', 'Examine'))
if isinstance(self, UserInfoFile):
sl.keys.append(('P', 'Posts'))
+ sl.keys.append(('L', 'List'))
+ if isinstance(self, StatusInfoFile):
+ sl.keys.append(('L', 'List'))
if self.items_are_statuses:
sl.keys.append(('F', 'Fave'))
sl.keys.append(('^B', 'Boost'))
def __init__(self, cc, feed, title):
super().__init__(cc, client.Notification, feed, title)
+class UserListFile(ObjectFile):
+ items_are_statuses = False
+ items_have_authors = True
+ def __init__(self, cc, feed, title):
+ super().__init__(cc, client.UserListEntry, feed, title)
+
class StatusInfoFile(ObjectFile):
items_are_statuses = True
items_have_authors = True
def __init__(self, cc, postid):
title = text.ColouredString(f"Information about post {postid}", 'H')
self.data = cc.get_status_by_id(postid)
+ self.postid = postid
super().__init__(
cc, lambda x,cc:x, client.StatusInfoFeed(cc, self.data), title)
+ def handle_key(self, ch):
+ if self.mode == 'normal' and ch in {'l', 'L'}:
+ self.mode = 'list_users'
+ elif self.mode == 'list_users' and ch in {'f', 'F'}:
+ feed = client.UserListFeed(self.cc,
+ f"statuses/{self.postid}/favourited_by")
+ title = text.ColouredString(
+ f"Users who favourited post {self.postid}", 'H')
+ self.chain_to(UserListFile(self.cc, feed, title))
+ elif self.mode == 'list_users' and ch in {'b', 'B'}:
+ feed = client.UserListFeed(self.cc,
+ f"statuses/{self.postid}/reblogged_by")
+ title = text.ColouredString(
+ f"Users who boosted post {self.postid}", 'H')
+ self.chain_to(UserListFile(self.cc, feed, title))
+ elif self.mode == 'list_users':
+ self.mode = 'normal'
+ else:
+ return super().handle_key(ch)
+
class UserInfoFile(ObjectFile):
items_are_statuses = False
items_have_authors = True
def __init__(self, cc, account):
self.account = account
+ self.account_id = account['id']
name = cc.fq(account['acct'])
title = text.ColouredString(f"Information about user {name}", 'H')
super().__init__(
def handle_key(self, ch):
if self.mode == 'normal' and ch in {'p', 'P'}:
- feed = client.UserStatusesFeed(self.cc, self.account['id'])
+ feed = client.UserStatusesFeed(self.cc, self.account_id)
name = self.cc.fq(self.account['acct'])
title = text.ColouredString(f"Posts from user {name}", 'H')
self.chain_to(StatusFile(self.cc, feed, title))
+ elif self.mode == 'normal' and ch in {'l', 'L'}:
+ self.mode = 'list_users'
+ elif self.mode == 'list_users' and ch in {'i', 'I'}:
+ feed = client.UserListFeed(self.cc,
+ f"accounts/{self.account_id}/followers")
+ name = self.cc.fq(self.account['acct'])
+ title = text.ColouredString(f"Users who follow {name}", 'H')
+ self.chain_to(UserListFile(self.cc, feed, title))
+ elif self.mode == 'list_users' and ch in {'o', 'O'}:
+ feed = client.UserListFeed(self.cc,
+ f"accounts/{self.account_id}/following")
+ name = self.cc.fq(self.account['acct'])
+ title = text.ColouredString(f"Users who {name} follows", 'H')
+ self.chain_to(UserListFile(self.cc, feed, title))
+ elif self.mode == 'list_users':
+ self.mode = 'normal'
else:
return super().handle_key(ch)