Skip to content

Commit 16e998f

Browse files
committed
Work around Misskey fork API diffs
1 parent 030f7b5 commit 16e998f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

nowplaying/social/misskey.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,18 @@ def post(self, text):
1313
self.client.notes_create(text = text)
1414

1515
def __str__(self):
16-
host = urlparse(self.client.meta()['uri']).hostname
17-
return f'Misskey (@{self.client.i()["username"]}@{host})'
16+
host = self.client.address
17+
user = self.user()
18+
if user is not None:
19+
return f'Misskey (@{user}@{host})'
20+
else:
21+
return f'Misskey ({host})'
22+
23+
def user(self):
24+
try:
25+
return self.client.i()["username"]
26+
except Exception as e:
27+
print(f'Failed to fetch username: {e}')
28+
print(
29+
'This tends to happen if the server uses',
30+
'a Misskey fork such as Foundkey.')

0 commit comments

Comments
 (0)