mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
Fediverse: Add @status.
This commit is contained in:
parent
4e74c6dbb3
commit
2c9e6544f5
@ -337,6 +337,19 @@ class Fediverse(callbacks.PluginRegexp):
|
||||
)
|
||||
)
|
||||
|
||||
@wrap(["url"])
|
||||
def status(self, irc, msg, args, url):
|
||||
"""<url>
|
||||
|
||||
Shows the content of the status at <url>.
|
||||
"""
|
||||
try:
|
||||
status = ap.get_resource_from_url(url)
|
||||
except ap.ActivityPubError as e:
|
||||
irc.error(_("Could not get status: %s") % e.args[0], Raise=True)
|
||||
|
||||
irc.reply(self._format_status(irc, msg, status))
|
||||
|
||||
|
||||
Class = Fediverse
|
||||
|
||||
|
@ -277,6 +277,28 @@ class FediverseTestCase(ChannelPluginTestCase):
|
||||
"Error: Unknown user @nonexistinguser@example.org.",
|
||||
)
|
||||
|
||||
def testStatus(self):
|
||||
expected_requests = [
|
||||
(STATUS_URL, STATUS_DATA),
|
||||
(ACTOR_URL, ACTOR_DATA),
|
||||
]
|
||||
|
||||
with self.mockRequests(expected_requests):
|
||||
self.assertResponse(
|
||||
"status https://example.org/users/someuser/statuses/1234",
|
||||
"\x02someuser (@someuser@example.org)\x02: "
|
||||
+ "@ FirstAuthor I am replying to you",
|
||||
)
|
||||
|
||||
def testStatusError(self):
|
||||
expected_requests = [(STATUS_URL, utils.web.Error("blah"))]
|
||||
|
||||
with self.mockRequests(expected_requests):
|
||||
self.assertResponse(
|
||||
"status https://example.org/users/someuser/statuses/1234",
|
||||
"Error: Could not get status: blah",
|
||||
)
|
||||
|
||||
def testStatuses(self):
|
||||
expected_requests = [
|
||||
(HOSTMETA_URL, HOSTMETA_DATA),
|
||||
|
Loading…
Reference in New Issue
Block a user