def send(self, channel: Union[Channel, str], text: str, **kwargs): channel_id = id_for_channel(channel) if 'attachments' in kwargs and kwargs['attachments'] is not None: kwargs['attachments'] = extract_json(kwargs['attachments']) if 'blocks' in kwargs and kwargs['blocks'] is not None: kwargs['blocks'] = extract_json(kwargs['blocks']) if 'ephemeral_user' in kwargs and kwargs['ephemeral_user'] is not None: ephemeral_user_id = id_for_user(kwargs['ephemeral_user']) del kwargs['ephemeral_user'] return LowLevelSlackClient.get_instance( ).web_client.chat_postEphemeral(channel=channel_id, user=ephemeral_user_id, text=text, **kwargs) else: return LowLevelSlackClient.get_instance( ).web_client.chat_postMessage(channel=channel_id, text=text, **kwargs)
def send_dm(self, user: Union[User, str], text: str, **kwargs): user_id = id_for_user(user) dm_channel_id = self.open_im(user_id) return LowLevelSlackClient.get_instance().web_client.chat_postMessage( channel=dm_channel_id, text=text, as_user=True, **kwargs)
def open_im(self, user: Union[User, str]) -> str: user_id = id_for_user(user) response = LowLevelSlackClient.get_instance( ).web_client.conversations_open(users=user_id) return response['channel']['id']
def react(self, channel: Union[Channel, str], ts: str, emoji: str): channel_id = id_for_channel(channel) return LowLevelSlackClient.get_instance().web_client.reactions_add( name=emoji, channel=channel_id, timestamp=ts)
def channels(self) -> Dict[str, Channel]: return LowLevelSlackClient.get_instance().channels
def users(self) -> Dict[str, User]: return LowLevelSlackClient.get_instance().users
def bot_info(self) -> Dict[str, str]: return LowLevelSlackClient.get_instance().bot_info