class InfiniteCraft
InfiniteCraft
Initialize an Infinite Craft session.
Attributes
discoveries
(list
[
Element
]
): List of Element
objects that have been discovered.
closed
(bool
| None
): Whether the Infinite Craft session is closed or not.
None
if session has not been started.
Arguments
api_url
(str
, optional): The API URL to contact.
Defaults to
"https://neal.fun/api/infinite-craft"
api_rate_limit
(int
, optional): The requests per minute the API can handle before ratelimiting. 0
if you want no ratelimit.
Must be greater than or equal to 0
.
Defaults to
400
requests per minute
manual_control
(bool
, optional): Manually control InfiniteCraft
.
start
()
and InfiniteCraft
.
stop
()
.
Useful when using async with
multiple times.
Defaults to
False
discoveries_storage
(str
, optional): Path to discoveries storage JSON.
Defaults to
"discoveries.json"
encoding
(str
, optional): Encoding to use while reading or saving json files.
Defaults to
"utf-8"
do_reset
(bool
, optional): Whether to reset the discoveries storage JSON and emoji cache JSON.
Defaults to
False
headers
(dict
, optional): Headers to send to the API.
Defaults to
{}
element_cls
(Element
, optional): Class to be used for creating elements.
NOTE: Must be a subclass of Element
.
Defaults to
Element
logger
(class
, optional): An initialized logger class or module with methods info
, warn
, error
, fatal
, and debug
to use for logging.
Defaults to a custom logger
Logger
debug
(bool
, optional): Whether to send debug logs.
This sets the current logger
to Logger
(
log_level
=
5
)
.
Only works when bool
(
logger
)
is False
or when the custom logger is used.
Defaults to
False
async def ping
()
-> float
ping
()
-> float
Ping the API with a simple pair request and return the latency.
Returns
float
: The latency in seconds.
async def start
()
start
()
Start the InfiniteCraft
session.
Raises
RuntimeError
: Raises when session is closed or has already started.
async def close
()
close
()
Start the InfiniteCraft
session.
Raises
RuntimeError
: Raises when session has not been started or is already closed.
async def stop
()
stop
()
async def pair
()
-> Element
pair
()
-> Element
Pair two elements and return the resulting element.
Arguments
first
(Element
): The first element.
Required
second
(Element
): The second element.
Required
store
(bool
, optional): Whether to store the result Element
to self
.
discoveries
.
Defaults to
True
Raises
TypeError
: If first
or second
is not an instance of Element
.
Returns
Element
: The resulting element as an Element
object or an Element
with all attributes as None
if they could not be paired.
async def merge
()
merge
()
async def combine
()
combine
()
def get_discoveries
()
-> Element
, None
get_discoveries
()
-> Element
, None
Get a list
containing all discovered elements fetched from the discoveries.json
file.
Arguments
set_value
(bool
, optional): Whether to set the value for the self
.
discoveries
attribute after getting it.
Defaults to
None
check
(Callable
[[
Element
],
bool
]
, optional): A callable functions that accepts an argument for element
and returns a bool to whether add the element or not.
Defaults to
None
Returns
list
[
Element
]
: The list
containing every Element
discovered.
def get_discovery
()
-> Element
, None
get_discovery
()
-> Element
, None
Get a discovered Element
from self
.
discoveries
.
Arguments
name
(str
): Name of element to get.
Required
from_file
(bool
, optional): Whether to check the discoveries JSON file for the element.
Defaults to
False
Returns
Element
| None
: The discovered Element
or None
if it wasn't discovered.
@staticmethod
def reset
()
reset
()
Reset the discoveries.json
file to its initial state.
This is a @staticmethod
, hence it can be used using InfiniteCraft.reset()
without initialising the class.
Last updated