Session¶
-
class
pyryver.ryver.
Ryver
(org: str = None, user: str = None, password: str = None, cache: Type[pyryver.cache_storage.AbstractCacheStorage] = None)¶ A Ryver session contains login credentials and organization information.
This is the starting point for any application using pyryver.
If the organization or username is not provided, it will be prompted using input(). If the password is not provided, it will be prompted using getpass().
The cache is used to load the chats data. If not provided, no caching will occur.
If a valid cache is provided, the chats data will be loaded in the constructor. Otherwise, it must be loaded through load_forums(), load_teams() and load_users() or load_chats().
Parameters: - org – Your organization’s name. (as seen in the URL)
- user – The username to authenticate with.
- password – The password to authenticate with.
- cache – The aforementioned cache.
-
get_chat
(**kwargs) → pyryver.objects.Chat¶ Get a specific forum/team/user.
If no query parameters are supplied, more than one query parameters are supplied or forums/teams/users are not loaded, raises
ValueError
.Allowed query parameters are:
- id
- jid
Returns none if not found.
-
async with
get_live_session
() → pyryver.ryver_ws.RyverWS¶ Get a live session.
The session is not started unless start() is called or if it is used as a context manager.
-
get_user
(**kwargs) → pyryver.objects.User¶ Get a specific user.
If no query parameters are supplied, more than one query parameters are supplied or users are not loaded, raises
ValueError
.Allowed query parameters are:
- id
- jid
- username
- display_name
Returns none if not found.
-
get_groupchat
(**kwargs) → pyryver.objects.GroupChat¶ Get a specific forum/team.
If no query parameters are supplied, more than one query parameters are supplied or forums/teams are not loaded, raises
ValueError
.Allowed query parameters are:
- id
- jid
- name
- nickname
Returns none if not found.
-
await
get_object
(obj_type: str, obj_id: int) → pyryver.objects.Object¶ Get an object from Ryver with a type and ID.
This method sends requests.
Parameters: - obj_type – The type of the object to retrieve, a constant beginning with
TYPE_
in pyryver.util. - obj_id – The object’s ID.
- obj_type – The type of the object to retrieve, a constant beginning with
-
await
get_info
() → Dict[str, Any]¶ Get organization and user info.
This method returns an assortment of info. It is currently the only way to get avatar URLs for users/teams/forums etc. The results (returned mostly verbatim from the Ryver API) include:
- Basic user info - contains avatar URLs (“me”)
- User UI preferences (“prefs”)
- Ryver app info (“app”)
- Basic info about all users - contains avatar URLs (“users”)
- Basic info about all teams - contains avatar URLs (“teams”)
- Basic info about all forums - contains avatar URLs (“forums”)
- All available commands (“commands”)
- “messages” and “prefixes”, the purpose of which are currently unknown.
This method sends requests.
-
async for notification in
get_notifs
(unread: bool = False, top: int = -1, skip: int = 0) → AsyncIterator[pyryver.objects.Notification]¶ Get all the user’s notifications.
This method sends requests.
Parameters: - unread – If True, only return unread notifications.
- top – Maximum number of results.
- skip – Skip this many results.
-
await
mark_all_notifs_read
() → int¶ Marks all the user’s notifications as read.
This method sends requests.
Returns how many notifications were marked as read.
-
await
mark_all_notifs_seen
() → int¶ Marks all the user’s notifications as seen.
This method sends requests.
Returns how many notifications were marked as seen.
-
await
upload_file
(filename: str, filedata: Any, filetype: str = None) → pyryver.objects.Storage¶ Upload a file to Ryver.
Although this method uploads a file, the returned object is an instance of Storage. Use Storage.get_file() to obtain the actual File object.
Parameters: - filename – The filename to send to Ryver. (this will show up in the UI if attached as an embed, for example)
- filedata – The file’s raw data, sent directly to
aiohttp.FormData.add_field()
.
-
await
load_chats
() → None¶ Load the data of all users/teams/forums.
This refreshes the cached data if a cache is supplied.
This method sends requests.
-
await
load_missing_chats
() → None¶ Load the data of all users/teams/forums if it does not exist.
Unlike load_chats(), this does not update the cache.
This method could send requests.
-
await
load_users
() → None¶ Load the data of all users.
This refreshes the cached data if a cache is supplied.
This method sends requests.
-
await
load_forums
() → None¶ Load the data of all forums.
This refreshes the cached data if a cache is supplied.
This method sends requests.
-
await
load_teams
() → None¶ Load the data of all teams.
This refreshes the cached data if a cache is supplied.
This method sends requests.
-
await
close
()¶ Close this session.