Giter Site home page Giter Site logo

akinator.py's Introduction

Akinator-py

Python bindings for akinator-rs, a wrapper around the undocumented akinator API, made using pyo3

designed for easy implementation of an akinator game in code, providing a simple and easy to use API.

Installation

Prebuilt wheels are uploaded onto pypi, if you platform is supported, you can install with:

$ py -m pip install akinator.py

You can also build from source yourself if you have rust installed

Examples

  • refer to the tests for full examples on usage
  • Refer to the documentation here for more information

akinator.py's People

Contributors

cryptex-github avatar jay3332 avatar tom-the-bomb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

akinator.py's Issues

Cant change the Language of the Game

If you start a Game using akinator.Akinator(theme=akinator.Theme.Characters, language=akinator.Language.German, child_mode=True) the Language is still English and not German (same for the async version)

Error when multiple users use the akinator command [async]

Result: Akinator game errored out:
Failed to parse JSON: expected value at line 1 column 1

code:
async def answer(self, message: str, interaction: discord.Interaction):
try:
await self.aki.answer(Answer.from_str(message))
except NoMoreQuestions:
await self.win(interaction)
except TimeoutError:
await self.cancel("The connection to the Akinator servers was lost.")
except Exception as error:
await self.edit_or_send(
interaction, content=f"Akinator game errored out:\n{error}", embed=None
)
self.stop()

Expected result: should work fine when two different games are started.

also I would like to take this opportunity to suggest if you could use aiohttp sessions and also allow us to pass our own session into the AsyncAkinator class

There is an error when requesting en.akinator.com

An error occurred: HTTPSConnectionPool(host='en.akinator.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))

It seems like akinator implemented more aggressive security

RuntimeError: Failed to find the required information needed to start the game

Just imported the module and copied the test_sync.py code. Did not alter anything.

Traceback (most recent call last):
File "e:\test.py", line 53, in
test()
File "e:\test.py", line 17, in test
first_question = aki.start_game()
^^^^^^^^^^^^^^^^
RuntimeError: Failed to find the required information needed to start the game

Failed to parse JSON: expected value at line 1 column 1

Whenever I attempt to start the game by using aki.start_game(), I receive the following error message: Failed to parse JSON: expected value at line 1 column 1. This issue also persists when running the tests provided in this repository.

The complete error message is as follows:

Exception has occurred: ValueError
Failed to parse JSON: expected value at line 1 column 1
  File "H:\Sayoka\extensions\tmp.py", line 17, in test
    first_question = aki.start_game()
                     ^^^^^^^^^^^^^^^^
  File "H:\Sayoka\extensions\tmp.py", line 53, in <module>
    test()
ValueError: Failed to parse JSON: expected value at line 1 column 1

(This error occurs when running the test_sync.py file available in the akinator.py repository.)

invalid peer certificate: UnknownIssuer

When trying to use this Package, the following Error occurs:

RequestError: error sending request for url (https://en.akinator.com/): error trying to connect: invalid peer certificate contents: invalid peer certificate: UnknownIssuer
  File "H:\Sayoka\tmp.py", line 17, in test
    first_question = aki.start_game()
  File "H:\Sayoka\tmp.py", line 53, in <module>
    test()
RuntimeError: RequestError: error sending request for url (https://en.akinator.com/): error trying to connect: invalid peer certificate contents: invalid peer certificate: UnknownIssuer

This happens both in the sync and async version and in every language (at least in English and German)

AttributeError: 'NoneType' object has no attribute 'group'

i am having an issue in this library
in my previous code which i wrote 2-3 years ago,it gave this error

--> 162 region_info = self._auto_get_region(get_lang_and_theme (language) ["lang"], get_lang_and_theme(language) ["theme"])

163 self.uri, self.server region_info["uri"], region_info["server"]

165 self.child_mode child_mode

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\akinator\akinator.py:117, in Akinator._auto_get_region(self, 1 ang, theme)

114 r requests.get("https://" + uri, verify=False)

116 match server_regex.search(r.text)

--> 117 parsed = json.loads(match.group().split("'arrUrl Themes ToPlay', ")[-1])

AttributeError: 'NoneType' object has no attribute 'group'

then i uninstalled the library and reinstalled it to be upto date with new version but it gave this error

now it gives the same error as jkace21 mentioned

Failed to find the required information needed to start the game

i think that the match.group() has some sort of abnormality in it and as you said they could have changed something , i think this is something where the changes have been made
or auto_get_region() could also have been changed.

Continue upon wrong guess.

Idk if I don't know this, but to be able to get the first_guess, it seems like you need to use aki.win(), which seems to end the game.

Is there any way to make it so that it asks if the answer is correct (after 80% progression), if answered with yes, it ends it, if not, it continues from WHERE IT LEFT (NOT restart), and reduces the progression. I want the usual things (The description, Name of the object/animal/character, and a picture of it) to be accessible as the first_guess without finishing the game. Thank you.

If you explain me if theres a method to do it, or if not, if you could add it, I would be very thankful!

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.