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.CantGoBackAnyFurther:
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.2.tar.gz
(10.0 kB
view hashes)
Built Distribution
Close
Hashes for asyncakinator-1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2032647379993fe7e2cbb0c15ab19b99abecde36cd50cf9b0ec2f83c3e5226ea |
|
MD5 | ae2810a946e37bd60992aa0cd2f8cb1c |
|
BLAKE2b-256 | 16a6bb3a6ccd39520cbdb3c98fe7e9990eecdde49888c4f544652e96946b6f12 |