aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_api.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-10-14 21:42:28 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit2bf006184804104afe13bb11901c0d8674c3a1e2 (patch)
tree2c58b64361eb94567b7d9b4922bb9eb8647a3cbf /slack/slack_api.py
parent300845598e26b0441afcd719a5b9e3af3e3aa45b (diff)
downloadwee-slack-2bf006184804104afe13bb11901c0d8674c3a1e2.tar.gz
Support adding and removing reactions
Diffstat (limited to 'slack/slack_api.py')
-rw-r--r--slack/slack_api.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/slack/slack_api.py b/slack/slack_api.py
index 7fff321..784bea6 100644
--- a/slack/slack_api.py
+++ b/slack/slack_api.py
@@ -26,6 +26,7 @@ if TYPE_CHECKING:
from slack_api.slack_users_prefs import SlackUsersPrefsGetResponse
from slack_edgeapi.slack_usergroups_info import SlackEdgeUsergroupsInfoResponse
from slack_edgeapi.slack_users_search import SlackUsersSearchResponse
+ from typing_extensions import Literal, assert_never
from slack.slack_conversation import SlackConversation
from slack.slack_workspace import SlackWorkspace
@@ -317,3 +318,27 @@ class SlackApi(SlackApiCommon):
if response["ok"] is False:
raise SlackApiError(self.workspace, method, response, params)
return response
+
+ async def reactions_change(
+ self,
+ conversation: SlackConversation,
+ ts: SlackTs,
+ name: str,
+ change_type: Literal["+", "-"],
+ ):
+ method = (
+ "reactions.add"
+ if change_type == "+"
+ else "reactions.remove"
+ if change_type == "-"
+ else assert_never(change_type)
+ )
+ params: Params = {
+ "channel": conversation.id,
+ "timestamp": ts,
+ "name": name,
+ }
+ response: SlackGenericResponse = await self._fetch(method, params)
+ if response["ok"] is False:
+ raise SlackApiError(self.workspace, method, response, params)
+ return response