An async API wrapper for Akinator, written in Python.
Project description
An async API wrapper for the online game, Akinator, written in Python.
Akinator is a web-based game which tries to determine what character you are thinking of by asking a series of questions.
Installing
To install, just run the following command:
python3 -m pip install -U asyncakinator
Requirements
Python ≥3.9
requests
aiohttp
Usually, pip will handle these for you.
Quick Examples
Here’s a quick little example of the library being used to make a simple, text-based Akinator game:
import akinator
import asyncio
aki = akinator.Akinator(
language=akinator.Language.ENGLISH,
theme=akinator.Theme.ANIMALS,
)
async def main():
question = await aki.start()
while aki.progression <= 80:
a = input(f"{question}\n\t")
if a == "b":
try:
question = await aki.back()
except akinator.CanNotGoBack:
continue
else:
try:
question = await aki.answer(akinator.Answer.from_str(a))
except akinator.InvalidAnswer:
print("Invalid answer. Please try again.\n")
continue
await aki.win()
correct = input(
f"You are thinking of {aki.first_guess.name} ({aki.first_guess.description}). "
f"Am I correct?\n{aki.first_guess.absolute_picture_path}\n\t"
)
if akinator.Answer.from_str(correct) == akinator.Answer.YES:
print("Nice.")
else:
print("Maybe next time.")
await aki.close()
asyncio.run(main())
Documentation
Documention can be found here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asyncakinator-1.5.tar.gz
(10.2 kB
view hashes)
Built Distribution
Close
Hashes for asyncakinator-1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77ac05e8b9bdc52115af64b1a86c09a6569ff2722ac8edf2ae601e6d84be4563 |
|
MD5 | 7666d47c3d9906ca29470d242cbc1050 |
|
BLAKE2b-256 | afa153a7bc6307edfb3397352c8683ca589df48a1128a7bbe3e771774e2cf2d0 |