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:
# MacOS/Linux
python3 -m pip install -U asyncakinator
# Windows
py -3 -m pip install -U asyncakinator
Requirements
Python ≥3.9
aiohttp
Documentation
Documention can be found here.
Quick Examples
Here’s a quick little example of the library being used to make a simple, text-based Akinator game:
import asyncio
from asyncakinator import (
Akinator,
Answer,
CanNotGoBack,
InvalidAnswer,
Language,
NoMoreQuestions,
Theme
)
game = Akinator(
language=Language.ENGLISH,
theme=Theme.ANIMALS,
)
async def main():
question = await game.start()
while game.progression <= 80:
print(question)
user_input = input("Answer: ")
try:
answer = Answer.from_str(user_input)
except InvalidAnswer:
print("Invalid answer")
continue
try:
question = await game.answer(answer)
except CanNotGoBack:
print("This is the first question, you can't go back.")
continue
except NoMoreQuestions:
break
await game.win()
correct = input(
f"You are thinking of {game.first_guess.name} ({game.first_guess.description}). "
f"Am I correct?\n{game.first_guess.absolute_picture_path}\n---\nAnswer: "
)
if Answer.from_str(correct) == Answer.YES:
print("Nice.")
else:
print("Maybe next time.")
await game.close()
asyncio.run(main())
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.6.tar.gz
(14.1 kB
view details)
Built Distribution
File details
Details for the file asyncakinator-1.6.tar.gz
.
File metadata
- Download URL: asyncakinator-1.6.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dd0f1d69415631b5b2f7178bcf4e8a001443cf4fc228a04561fb34f54c00ea6 |
|
MD5 | 3812a9c004dac00e0c6956f447a9be95 |
|
BLAKE2b-256 | 57cad9fb6f07d9e50f9a2dcaf4eaf9dab11b29b01fdaadce42e6ed1c0a6e66a6 |
File details
Details for the file asyncakinator-1.6-py3-none-any.whl
.
File metadata
- Download URL: asyncakinator-1.6-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33907a9da9143736ea3773770f144f51625dc89b4ac4d7203a6c54599dde817a |
|
MD5 | 3091efd8a06dab4104410b45be4e2c8f |
|
BLAKE2b-256 | 247277ce92ebda44f462f41d251b3e787b67501b6e7f0659539ff878da0529e6 |