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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asyncakinator-1.7.tar.gz.
File metadata
- Download URL: asyncakinator-1.7.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c83de25b5b17c5c31b8f21fd65dc63fabca0357b36ecde4757d7fc5abefd202
|
|
| MD5 |
aec8e7dcd75556f7b4a3d243cc798fcf
|
|
| BLAKE2b-256 |
3bd30bcdab1fa19b1e52100be370c722e167a2e62e14fef603f08c2c72a11508
|
File details
Details for the file asyncakinator-1.7-py3-none-any.whl.
File metadata
- Download URL: asyncakinator-1.7-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2ecd9e70f2c069eaae9a4580d733158d08d3fe807e51d223ebd651f0bfbce99
|
|
| MD5 |
9c790d572ef728ca333e8c4c0c273f1c
|
|
| BLAKE2b-256 |
85654f30d427bdb4c4472384d9a0fde97ef98538c6457004565eb62041873fee
|