예제 #1
0
 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)
예제 #2
0
    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)
예제 #3
0
 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']
예제 #4
0
 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)
예제 #5
0
 def channels(self) -> Dict[str, Channel]:
     return LowLevelSlackClient.get_instance().channels
예제 #6
0
 def users(self) -> Dict[str, User]:
     return LowLevelSlackClient.get_instance().users
예제 #7
0
 def bot_info(self) -> Dict[str, str]:
     return LowLevelSlackClient.get_instance().bot_info