Utils#

Helper Functions#

Support functions for the Client methods.

yarsaw.format_joke()#

Support function for Client.get_joke(). Auto-format a joke. If its a single type of joke, it returns the joke itself. If its a two-part joke, it returns the setup and delivery, separated by a newline or a character you choose.

Parameters
  • joke (Joke) – The joke to format.

  • format_as (Optional[str]) – The format to use. Defaults to "{setup}\n{delivery}".

Returns

The formatted joke.

Return type

str

yarsaw.generate_uid()#

Support function for Client.get_ai_response(). Generates a random string of characters to be used as a unique identifier for a user.

Parameters
  • chars (Optional[int]) – The number of characters to generate. Defaults to 8.

  • letters (Optional[bool]) – Whether or not to include letters. Defaults to True.

  • special_chars (Optional[bool]) – Whether or not to include special characters. Defaults to False.

Returns

The generated UID.

Return type

str

Data Classes#

class yarsaw.APIInfo(requests_limit: int, requests_remaining: int, reset_time: int)#
class yarsaw.BotDetails(bot_name: str, bot_master: str, bot_age: str, bot_location: str, bot_company: str, bot_birth_year: str, bot_birth_date: str, bot_birth_place: str)#
class yarsaw.AIResponse(response: str, bot_details: yarsaw.data_classes.BotDetails, api_info: yarsaw.data_classes.APIInfo)#
class yarsaw.Joke(joke: str, tags: list, api_info: yarsaw.data_classes.APIInfo)#
class yarsaw.RedditPost(id: str, type: str, title: str, author: str, url: str, image: str, gallery: bool, text: str, thumbnail: str, subreddit: str, nsfw: bool, spoiler: bool, created_at: int, upvotes: int, downvotes: int, upvote_ratio: float, api_info: yarsaw.data_classes.APIInfo)#
class yarsaw.AnimalImage(images: list, api_info: yarsaw.data_classes.APIInfo)#
class yarsaw.AnimeGIF(title: str, thumbnail: str, image: str, api_info: yarsaw.data_classes.APIInfo)#
class yarsaw.CanvasResponse(base64: str, decoded_base64: str, api_info: yarsaw.data_classes.APIInfo)#
class yarsaw.Fact(fact: str, api_info: yarsaw.data_classes.APIInfo)#

Exceptions#

exception yarsaw.InvalidPlan#
exception yarsaw.InvalidAPIKey#
exception yarsaw.RateLimited#
exception yarsaw.BadGateway#

Documentation Last Updated on Mar 27, 2022