Beispiel #1
0
 def rooms_info(self, room_id=None, room_name=None):
     """Retrieves the information about the room."""
     if room_id is not None:
         return self.call_api_get("rooms.info", roomId=room_id)
     if room_name is not None:
         return self.call_api_get("rooms.info", roomName=room_name)
     raise RocketMissingParamException("room_id or roomName required")
Beispiel #2
0
 def groups_delete(self, room_id=None, group=None, **kwargs):
     """Delete a private group."""
     if room_id:
         return self.__call_api_post("groups.delete", roomId=room_id, kwargs=kwargs)
     elif group:
         return self.__call_api_post("groups.delete", roomName=group, kwargs=kwargs)
     else:
         raise RocketMissingParamException("roomId or group required")
Beispiel #3
0
 def groups_members(self, room_id=None, group=None, **kwargs):
     """Lists all group users."""
     if room_id:
         return self.__call_api_get("groups.members", roomId=room_id, kwargs=kwargs)
     elif group:
         return self.__call_api_get("groups.members", roomName=group, kwargs=kwargs)
     else:
         raise RocketMissingParamException("roomId or group required")
Beispiel #4
0
 def channels_add_owner(self, room_id, user_id=None, username=None, **kwargs):
     """Gives the role of owner for a user in the current channel."""
     if user_id:
         return self.__call_api_post('channels.addOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
     elif username:
         return self.__call_api_post('channels.addOwner', roomId=room_id, username=username, kwargs=kwargs)
     else:
         raise RocketMissingParamException('userID or username required')
Beispiel #5
0
 def groups_info(self, room_id=None, room_name=None, **kwargs):
     """GRetrieves the information about the private group, only if you’re part of the group."""
     if room_id:
         return self.__call_api_get("groups.info", roomId=room_id, kwargs=kwargs)
     elif room_name:
         return self.__call_api_get("groups.info", roomName=room_name, kwargs=kwargs)
     else:
         raise RocketMissingParamException("roomId or roomName required")
Beispiel #6
0
 def users_info(self, user_id=None, username=None, **kwargs):
     """Gets a user’s information, limited to the caller’s permissions."""
     if user_id:
         return self.__call_api_get('users.info', userId=user_id, kwargs=kwargs)
     elif username:
         return self.__call_api_get('users.info', username=username, kwargs=kwargs)
     else:
         raise RocketMissingParamException('userID or username required')
Beispiel #7
0
 def users_create_token(self, user_id=None, username=None, **kwargs):
     """Create a user authentication token."""
     if user_id:
         return self.__call_api_post('users.createToken', userId=user_id, kwargs=kwargs)
     elif username:
         return self.__call_api_post('users.createToken', username=username, kwargs=kwargs)
     else:
         raise RocketMissingParamException('userID or username required')
Beispiel #8
0
 def chat_post_message(self, text, room_id=None, channel=None, **kwargs):
     """Posts a new chat message."""
     if room_id:
         return self.__call_api_post('chat.postMessage', roomId=room_id, text=text, kwargs=kwargs)
     elif channel:
         return self.__call_api_post('chat.postMessage', channel=channel, text=text, kwargs=kwargs)
     else:
         raise RocketMissingParamException('roomId or channel required')
Beispiel #9
0
 def users_get_avatar(self, user_id=None, username=None, **kwargs):
     """Gets the URL for a user’s avatar."""
     if user_id:
         return self.__call_api_get('users.getAvatar', userId=user_id, kwargs=kwargs)
     elif username:
         return self.__call_api_get('users.getAvatar', username=username, kwargs=kwargs)
     else:
         raise RocketMissingParamException('userID or username required')
Beispiel #10
0
 def users_reset_avatar(self, user_id=None, username=None, **kwargs):
     """Reset a user’s avatar"""
     if user_id:
         return self.__call_api_post('users.resetAvatar', userId=user_id, kwargs=kwargs)
     elif username:
         return self.__call_api_post('users.resetAvatar', username=username, kwargs=kwargs)
     else:
         raise RocketMissingParamException('userID or username required')
 async def rooms_info(self, room_id=None, room_name=None):
     """Retrieves the information about the room."""
     if room_id is not None:
         return await self.__call_api_get('rooms.info', roomId=room_id)
     elif room_name is not None:
         return await self.__call_api_get('rooms.info', roomName=room_name)
     else:
         raise RocketMissingParamException('roomId or roomName required')
Beispiel #12
0
 def users_get_presence(self, user_id=None, username=None, **kwargs):
     """Gets the online presence of the a user."""
     if user_id:
         return self.__call_api_get('users.getPresence', userId=user_id, kwargs=kwargs)
     elif username:
         return self.__call_api_get('users.getPresence', username=username, kwargs=kwargs)
     else:
         raise RocketMissingParamException('userID or username required')
Beispiel #13
0
 def im_counters(self, room_id=None, user_name=None, **kwargs):
     """Gets counters of direct messages."""
     if room_id:
         return self.__call_api_get("im.counters", roomId=room_id, kwargs=kwargs)
     elif user_name:
         return self.__call_api_get("im.counters", username=user_name, kwargs=kwargs)
     else:
         raise RocketMissingParamException("roomId or username required")
Beispiel #14
0
 def im_files(self, room_id=None, user_name=None, **kwargs):
     """Retrieves the files from a direct message."""
     if room_id:
         return self.__call_api_get("im.files", roomId=room_id, kwargs=kwargs)
     elif user_name:
         return self.__call_api_get("im.files", username=user_name, kwargs=kwargs)
     else:
         raise RocketMissingParamException("roomId or username required")
Beispiel #15
0
 def channels_info(self, room_id=None, channel=None, **kwargs):
     """Gets a channel’s information."""
     if room_id:
         return self.__call_api_get("channels.info", roomId=room_id, kwargs=kwargs)
     elif channel:
         return self.__call_api_get("channels.info", roomName=channel, kwargs=kwargs)
     else:
         raise RocketMissingParamException("roomId or channel required")
Beispiel #16
0
    def im_messages(self, room_id=None, username=None, **kwargs):
        """Retrieves direct messages from the server by username"""
        if room_id:
            return self.__call_api_get("im.messages", roomId=room_id, args=kwargs)

        if username:
            return self.__call_api_get("im.messages", username=username, args=kwargs)

        raise RocketMissingParamException("roomId or username required")
Beispiel #17
0
 def groups_files(self, room_id=None, room_name=None, **kwargs):
     """Retrieves the files from a private group."""
     if room_id:
         return self.__call_api_get("groups.files", roomId=room_id, kwargs=kwargs)
     elif room_name:
         return self.__call_api_get(
             "groups.files", roomName=room_name, kwargs=kwargs
         )
     else:
         raise RocketMissingParamException("roomId or room_name required")
Beispiel #18
0
 def groups_roles(self, room_id=None, room_name=None, **kwargs):
     """Lists all user’s roles in the private group."""
     if room_id:
         return self.__call_api_get("groups.roles", roomId=room_id, kwargs=kwargs)
     elif room_name:
         return self.__call_api_get(
             "groups.roles", roomName=room_name, kwargs=kwargs
         )
     else:
         raise RocketMissingParamException("roomId or room_name required")
Beispiel #19
0
 def channels_delete(self, room_id=None, channel=None, **kwargs):
     """Delete a public channel."""
     if room_id:
         return self.call_api_post("channels.delete",
                                   roomId=room_id,
                                   kwargs=kwargs)
     if channel:
         return self.call_api_post("channels.delete",
                                   roomName=channel,
                                   kwargs=kwargs)
     raise RocketMissingParamException("room_id or channel required")
Beispiel #20
0
 def groups_moderators(self, room_id=None, group=None, **kwargs):
     """Lists all moderators of a group."""
     if room_id:
         return self.call_api_get("groups.moderators",
                                  roomId=room_id,
                                  kwargs=kwargs)
     if group:
         return self.call_api_get("groups.moderators",
                                  roomName=group,
                                  kwargs=kwargs)
     raise RocketMissingParamException("roomId or group required")
Beispiel #21
0
 def rooms_favorite(self, room_id=None, room_name=None, favorite=True):
     """Favorite or unfavorite room."""
     if room_id is not None:
         return self.call_api_post(
             "rooms.favorite", roomId=room_id, favorite=favorite
         )
     if room_name is not None:
         return self.call_api_post(
             "rooms.favorite", roomName=room_name, favorite=favorite
         )
     raise RocketMissingParamException("room_id or roomName required")
Beispiel #22
0
 def channels_moderators(self, room_id=None, channel=None, **kwargs):
     """Lists all moderators of a channel."""
     if room_id:
         return self.call_api_get("channels.moderators",
                                  roomId=room_id,
                                  kwargs=kwargs)
     if channel:
         return self.call_api_get("channels.moderators",
                                  roomName=channel,
                                  kwargs=kwargs)
     raise RocketMissingParamException("room_id or channel required")
Beispiel #23
0
 def channels_counters(self, room_id=None, room_name=None, **kwargs):
     """Gets counters for a channel."""
     if room_id:
         return self.call_api_get("channels.counters",
                                  roomId=room_id,
                                  kwargs=kwargs)
     if room_name:
         return self.call_api_get("channels.counters",
                                  roomName=room_name,
                                  kwargs=kwargs)
     raise RocketMissingParamException("room_id or room_name required")
Beispiel #24
0
 def channels_files(self, room_id=None, room_name=None, **kwargs):
     """Retrieves the files from a channel."""
     if room_id:
         return self.call_api_get("channels.files",
                                  roomId=room_id,
                                  kwargs=kwargs)
     if room_name:
         return self.call_api_get("channels.files",
                                  roomName=room_name,
                                  kwargs=kwargs)
     raise RocketMissingParamException("room_id or room_name required")
Beispiel #25
0
 def channels_roles(self, room_id=None, room_name=None, **kwargs):
     """Lists all user’s roles in the channel."""
     if room_id:
         return self.call_api_get("channels.roles",
                                  roomId=room_id,
                                  kwargs=kwargs)
     if room_name:
         return self.call_api_get("channels.roles",
                                  roomName=room_name,
                                  kwargs=kwargs)
     raise RocketMissingParamException("room_id or room_name required")
 def channels_members(self, room_id=None, channel=None, **kwargs):
     """Lists all channel users."""
     if room_id:
         return self.__call_api_get('channels.members',
                                    roomId=room_id,
                                    kwargs=kwargs)
     elif channel:
         return self.__call_api_get('channels.members',
                                    roomName=channel,
                                    kwargs=kwargs)
     else:
         raise RocketMissingParamException('roomId or channel required')
 def channels_delete(self, room_id=None, channel=None, **kwargs):
     """Delete a public channel."""
     if room_id:
         return self.__call_api_post('channels.delete',
                                     roomId=room_id,
                                     kwargs=kwargs)
     elif channel:
         return self.__call_api_post('channels.delete',
                                     roomName=channel,
                                     kwargs=kwargs)
     else:
         raise RocketMissingParamException('roomId or channel required')
 async def channels_files(self, room_id=None, room_name=None, **kwargs):
     """Retrieves the files from a channel."""
     if room_id:
         return await self.__call_api_get('channels.files',
                                          roomId=room_id,
                                          kwargs=kwargs)
     elif room_name:
         return await self.__call_api_get('channels.files',
                                          roomName=room_name,
                                          kwargs=kwargs)
     else:
         raise RocketMissingParamException('roomId or room_name required')
 async def channels_roles(self, room_id=None, room_name=None, **kwargs):
     """Lists all user’s roles in the channel."""
     if room_id:
         return await self.__call_api_get('channels.roles',
                                          roomId=room_id,
                                          kwargs=kwargs)
     elif room_name:
         return await self.__call_api_get('channels.roles',
                                          roomName=room_name,
                                          kwargs=kwargs)
     else:
         raise RocketMissingParamException('roomId or room_name required')
 async def rooms_favorite(self,
                          room_id=None,
                          room_name=None,
                          favorite=True):
     """Favorite or unfavorite room."""
     if room_id is not None:
         return await self.__call_api_post('rooms.favorite',
                                           roomId=room_id,
                                           favorite=favorite)
     elif room_name is not None:
         return await self.__call_api_post('rooms.favorite',
                                           roomName=room_name,
                                           favorite=favorite)
     else:
         raise RocketMissingParamException('roomId or roomName required')