talkomatic.py
0.1.2
An easy-to-use Python versatile wrapper for the Talkomatic Bot interface ensuring best practices for making bots, and handling the REST API.
Loading...
Searching...
No Matches
me.py
Go to the documentation of this file.
1
from
requests
import
get
as
requests_get
2
3
from
dataclasses
import
dataclass
4
5
6
@dataclass
7
class
UserSession
:
8
"""
9
A class representing your current user session's information.
10
11
Args:
12
is_signed_in (bool): Whether the user is signed in.
13
username (str): The username of the user.
14
location (str): The location of the user.
15
user_id (str): The ID of the user.
16
"""
17
18
is_signed_in: bool
19
username: str |
None
20
location: str |
None
21
user_id: str |
None
22
23
24
@classmethod
25
def
get
(cls) -> "UserSession":
26
response = requests_get(
"https://classic.talkomatic.co/api/v1/me"
)
27
if
response.status_code != 200:
raise
RuntimeError(
"The talkomatic.co server is down."
)
28
data = response.json()
29
30
return
cls(
31
is_signed_in = data[
"isSignedIn"
],
32
username = data[
"username"
]
if
data[
"isSignedIn"
]
else
None
,
33
location = data[
"location"
]
if
data[
"isSignedIn"
]
else
None
,
34
user_id = data[
"userId"
]
if
data[
"isSignedIn"
]
else
None
35
)
36
37
__all__ = [
"UserSession"
]
talkomatic.api.v1.me.UserSession
Definition
me.py:7
talkomatic.api.v1.me.UserSession.get
"UserSession" get(cls)
Definition
me.py:25
talkomatic
api
v1
me.py
Generated by
1.13.2