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")
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")
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")
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')
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")
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')
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')
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')
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')
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')
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')
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")
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")
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")
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")
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")
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")
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")
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")
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")
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")
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")
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")
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')