Session¶
-
class
pykollib.Session(db_file=None)¶ This class represents a user’s session with The Kingdom of Loathing.
-
adventure(location_id, choices={}, combat=None)¶ Run adventure in a location
Warning
This method is experimental
- Parameters
location_id (
int) – The id of the location to visitchoices (
Union[Dict[str,int],Callable[[str],int]]) – Either a dictionary of choices to make, or a callable that can make that decisioncombat (
Optional[Callable]) – A function that carries out combat
-
get_profile()¶ Return information from the player’s profile
- Return type
Dict[str,Any]
-
get_status()¶ Load the current username, user_id, pwd and rollover time into the state
-
get_user_id()¶ Returns the current player’s user id
- Return type
Optional[int]
-
get_username()¶ Returns the current player’s username
- Return type
Optional[str]
-
join_clan(id=None, name=None)¶ Join a clan. Either id or name must be specified.
- Parameters
id (
Optional[int]) – id of the clan to joinname (
Optional[str]) – Name of the clan to join
- Return type
bool
-
login(username, password, server_number=0, stealth=True)¶ Perform a KoL login given a username and password. A server number may also be specified to ensure that the user logs in using that particular server. This can be helpful if the user continues to be redirected to a server that is down.
- Parameters
username (
str) – Your usernamepassword (
str) – Your passwordserver_number (
int) – Which server number to usestealth (
bool) – Whether to announce your login
- Return type
bool
-
logout()¶ ” Performs a logut request, closing the session.
-
request(url, method='POST', parse=<function Session.<lambda>>, pwd=False, ajax=False, json=False, **kwargs)¶ Make an HTTP request. This is mostly proxied through to ClientRequest
- Parameters
url (
str) – URL to request. If no host is specified, the current KoL server URL is used.method (
str) – HTTP method to useparse (
Callable[…,Any]) – Parse function to attach to the ClientResponsepwd (
bool) – Whether to inject the pwd into the requestajax (
bool) – Whether to inject the necessary ajax params into the requestjson (
bool) – Whether to parse the response as JSON instead of HTML
- Return type
ClientResponse
-