From ebc18cf2aa3d486b744bceba1ae1479672b8bddd Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Thu, 11 Jan 2024 13:49:46 +0000 Subject: snippet for pleroma emoji react --- api_ext.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 api_ext.py diff --git a/api_ext.py b/api_ext.py new file mode 100644 index 0000000..15d37e2 --- /dev/null +++ b/api_ext.py @@ -0,0 +1,23 @@ +from mastodon.versions import _DICT_VERSION_INSTANCE, _DICT_VERSION_ACTIVITY, _DICT_VERSION_ACCOUNT, _DICT_VERSION_EMOJI, _DICT_VERSION_ANNOUNCEMENT +from mastodon.errors import MastodonIllegalArgumentError, MastodonNotFoundError +from mastodon.utility import api_version +from mastodon.compat import urlparse + +from mastodon.internals import Mastodon as Internals +from mastodon.types import Instance, InstanceV2, NonPaginatableList, Activity, Nodeinfo, AttribAccessDict, Rule, Announcement, CustomEmoji, Account, IdType + +from typing import Union, Optional + +class Mastodon(Internals): + def post_reaction_create(self, statusid: str, reaction: str): + """ + Add a reaction to an announcement. `reaction` can either be a unicode emoji + or the name of one of the instances custom emoji. + + Will throw an API error if the reaction name is not one of the allowed things + or when trying to add a reaction that the user has already added (adding a + reaction that a different user added is legal and increments the count). + """ + id = self.__unpack_id(id) + self.__api_request('PUT', f'/api/v1/pleroma/statuses/{id}/reactions/{reaction}') + -- cgit v1.2.3-70-g09d2