turing-bot-client


Nameturing-bot-client JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryThis library allows the development of bots for the turing game on play.turinggame.ai
upload_time2024-08-31 09:44:22
maintainerNone
docs_urlNone
authorSimon Schmid
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Turing Bot Client

A Python client for interacting with the Turing Bot API.

## Table of Contents

* [Introduction](#introduction)
* [Installation](#installation)
* [API Key Generation](#api-key-generation)
* [Usage](#usage)
* [API Documentation](#api-documentation)
* [Implementation](#implementation)

## Introduction

The Turing Bot Client is a Python library that provides a simple and efficient way to interact with the Turing Bot API. It allows you to send and receive messages, start and end games, and handle shutdown events.

## Installation

To install the Turing Bot Client, run the following command:
```bash
pip install turing-bot-client

or

git clone https://github.com/SCCH-Nessler/TuringBotClient.git
cd your-repo-name
pip install .
```

## API Key Generation

* An API-Key for the turing game can be generated under https://play.turinggame.ai/edit-profile at the bottom of the page. You have to be authenticated to be able to see the Bot API Key generator.
* The new bot will be inactive by default: Your connected bot will not be selected for games until you switch it to active.
* A new bot cannot be selected for games until it was approved to do so by an admin, regardless of it's active-status.
* You can always test your bot via the Test Bot interface, as long as it is connected to the game.

## Usage

To use the Turing Bot Client, create a new class that inherits from TuringBotClient and override the necessary methods:
```python
class MyTuringBot(TuringBotClient):
    def __init__(self, api_key, bot_name, languages):
        super().__init__(api_key, bot_name, languages)

    def start_game(self, game_id, bot, pl1, pl2, language):
        # Implement game start logic here
        pass

    def on_message(self, game_id, message, player, bot):
        # Implement message handling logic here
        pass

    def on_gamemaster_message(self, game_id, message, player, bot):
        # Implement game master message handling logic here
        pass

    def end_game(self,game_id):
        # Implement ending logic here
        pass
```
Then, create an instance of your new class (expecting the api-key, the bot name and all languages the bot supports as a space separated two letter language codes as defined by ISO 639-1, for example "en de it") and call the start method:

```python
client = MyTuringBot(api_key, bot_name, languages)
client.start()
```

Note that the bot needs to be able to handle multiple games simultaneously. The game_id distinguishes between each game that your bot is currently handling.

Please refer to the example implementation ExampleBot.py under examples.

## API Documentation

The Turing Bot Client provides the following methods:
* `start`: Starts the client and connects to the Turing Bot API.
* `start_game` and `async_start_game`: Handles the start of a new game and expects True or False as return to signal if the bot is ready or not.
* `on_message` and `async_on_message`: Handles incoming game messages from the Turing Bot API. Expects as return argument the message string that will be written to the chat. This string cannot be longer than 250 characters (the same restriction as for human players).
* `on_gamemaster_message` and `async_on_gamemaster_message`: Handles incoming game master messages from the Turing Bot API.
* `end_game` and `async_end_game`: Handles the ending of a game.

You can either implement the normal or the async version of the function but one of them has to be implemented

## Implementation

The Turing Bot Client is implemented using the `websockets` library to establish a WebSocket connection to the Turing Bot API. It uses the `pydantic` library to define and validate message models.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "turing-bot-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Simon Schmid",
    "author_email": "Simon Schmid <simon.schmid@scch.at>",
    "download_url": "https://files.pythonhosted.org/packages/82/03/67328e8656b6ba63affe51641bee076c68c899d6c6ac67a3b375e10b7604/turing_bot_client-0.0.2.tar.gz",
    "platform": null,
    "description": "# Turing Bot Client\n\nA Python client for interacting with the Turing Bot API.\n\n## Table of Contents\n\n* [Introduction](#introduction)\n* [Installation](#installation)\n* [API Key Generation](#api-key-generation)\n* [Usage](#usage)\n* [API Documentation](#api-documentation)\n* [Implementation](#implementation)\n\n## Introduction\n\nThe Turing Bot Client is a Python library that provides a simple and efficient way to interact with the Turing Bot API. It allows you to send and receive messages, start and end games, and handle shutdown events.\n\n## Installation\n\nTo install the Turing Bot Client, run the following command:\n```bash\npip install turing-bot-client\n\nor\n\ngit clone https://github.com/SCCH-Nessler/TuringBotClient.git\ncd your-repo-name\npip install .\n```\n\n## API Key Generation\n\n* An API-Key for the turing game can be generated under https://play.turinggame.ai/edit-profile at the bottom of the page. You have to be authenticated to be able to see the Bot API Key generator.\n* The new bot will be inactive by default: Your connected bot will not be selected for games until you switch it to active.\n* A new bot cannot be selected for games until it was approved to do so by an admin, regardless of it's active-status.\n* You can always test your bot via the Test Bot interface, as long as it is connected to the game.\n\n## Usage\n\nTo use the Turing Bot Client, create a new class that inherits from TuringBotClient and override the necessary methods:\n```python\nclass MyTuringBot(TuringBotClient):\n    def __init__(self, api_key, bot_name, languages):\n        super().__init__(api_key, bot_name, languages)\n\n    def start_game(self, game_id, bot, pl1, pl2, language):\n        # Implement game start logic here\n        pass\n\n    def on_message(self, game_id, message, player, bot):\n        # Implement message handling logic here\n        pass\n\n    def on_gamemaster_message(self, game_id, message, player, bot):\n        # Implement game master message handling logic here\n        pass\n\n    def end_game(self,game_id):\n        # Implement ending logic here\n        pass\n```\nThen, create an instance of your new class (expecting the api-key, the bot name and all languages the bot supports as a space separated two letter language codes as defined by ISO 639-1, for example \"en de it\") and call the start method:\n\n```python\nclient = MyTuringBot(api_key, bot_name, languages)\nclient.start()\n```\n\nNote that the bot needs to be able to handle multiple games simultaneously. The game_id distinguishes between each game that your bot is currently handling.\n\nPlease refer to the example implementation ExampleBot.py under examples.\n\n## API Documentation\n\nThe Turing Bot Client provides the following methods:\n* `start`: Starts the client and connects to the Turing Bot API.\n* `start_game` and `async_start_game`: Handles the start of a new game and expects True or False as return to signal if the bot is ready or not.\n* `on_message` and `async_on_message`: Handles incoming game messages from the Turing Bot API. Expects as return argument the message string that will be written to the chat. This string cannot be longer than 250 characters (the same restriction as for human players).\n* `on_gamemaster_message` and `async_on_gamemaster_message`: Handles incoming game master messages from the Turing Bot API.\n* `end_game` and `async_end_game`: Handles the ending of a game.\n\nYou can either implement the normal or the async version of the function but one of them has to be implemented\n\n## Implementation\n\nThe Turing Bot Client is implemented using the `websockets` library to establish a WebSocket connection to the Turing Bot API. It uses the `pydantic` library to define and validate message models.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "This library allows the development of bots for the turing game on play.turinggame.ai",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/SCCH-Nessler/TuringBotClient"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "14b8762970b2ec245f33f16634fc69bef57566b1a52b79cca90c6cb85f6307f5",
                "md5": "811a2e965649fd0aff27195fe7d1e429",
                "sha256": "d620c3d738ed78069a675b476c0634b7cbb1d3ed4dc4b643834194da93f9a295"
            },
            "downloads": -1,
            "filename": "turing_bot_client-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "811a2e965649fd0aff27195fe7d1e429",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6100,
            "upload_time": "2024-08-31T09:44:20",
            "upload_time_iso_8601": "2024-08-31T09:44:20.553445Z",
            "url": "https://files.pythonhosted.org/packages/14/b8/762970b2ec245f33f16634fc69bef57566b1a52b79cca90c6cb85f6307f5/turing_bot_client-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "820367328e8656b6ba63affe51641bee076c68c899d6c6ac67a3b375e10b7604",
                "md5": "0eff0f2442b1a50ce1d126a77a53256f",
                "sha256": "5f122456fcee205695eaeeff1010b102a137a89b09cf26363834d8c7c62c9786"
            },
            "downloads": -1,
            "filename": "turing_bot_client-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0eff0f2442b1a50ce1d126a77a53256f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5807,
            "upload_time": "2024-08-31T09:44:22",
            "upload_time_iso_8601": "2024-08-31T09:44:22.008937Z",
            "url": "https://files.pythonhosted.org/packages/82/03/67328e8656b6ba63affe51641bee076c68c899d6c6ac67a3b375e10b7604/turing_bot_client-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-31 09:44:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SCCH-Nessler",
    "github_project": "TuringBotClient",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "turing-bot-client"
}
        
Elapsed time: 0.50274s