gather-client-ws


Namegather-client-ws JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/pyanderson/gather-client-ws
SummaryGather WebSocket service client
upload_time2023-03-20 02:40:04
maintainer
docs_urlNone
authorAnderson de Sousa Lima
requires_python
licenseMIT
keywords gather gather-town websocket
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Gather WebSocket Client
=======================

Installation
------------

::

   pip install gather-client-ws

Documentation
-------------

Auth
~~~~

Generate your ``API_KEY`` here: https://gather.town/apiKeys

Basic Usage
~~~~~~~~~~~

.. code:: python

   import asyncio

   from gather_client_ws import GatherClient


   async def producer(client):
       await client.set_text_status("new status text")
       await client.set_emoji_status("😁")


   async def main():
       client = GatherClient(api_key=API_KEY, space_id=SPACE_ID)
       await client.run(producer)


   asyncio.run(main())

   # Output
   [2023-03-19 22:44:57,340][INFO] Connected to wss://engine-a00a0.aaa0-.prod.do.gather.town:443/
   [2023-03-19 22:44:57,637][INFO] Connected as user USER_ID

Server response callback
~~~~~~~~~~~~~~~~~~~~~~~~

A callback function can be defined, this function will receive the
``client`` and the ``ServerClientBatch`` message:

.. code:: python

   ...

   async def callback(client, server_response):
       for event in server_response.events:
           print(event.WhichOneof("event"))


   async def producer(client):
       await asyncio.sleep(30)  # hold the connection for 30 seconds


   async def main():
       client = GatherClient(api_key=API_KEY, space_id=SPACE_ID, callback=callback)
       await client.run(producer)


   asyncio.run(main())

   # Expected output
   [2023-03-19 22:56:33,840][INFO] Connected to wss://engine-a00a0.aaa0-.prod.do.gather.town:443/
   [2023-03-19 22:56:34,351][INFO] Connected as user USER_ID
   transactionStatus
   transactionStatus
   serverHeartbeat
   serverHeartbeat
   serverHeartbeat

Logger level
~~~~~~~~~~~~

It is possible to define the client log level.

.. code:: python

   import logging

   ...

   async def main():
       client = GatherClient(api_key=API_KEY, space_id=SPACE_ID, log_level=logging.DEBUG)
       await client.run(producer)


   asyncio.run(main())

   # Output
   [2023-03-19 23:01:08,274][INFO] Connected to wss://engine-a00a0.aaa0-a.prod.do.gather.town:443/
   [2023-03-19 23:01:08,581][INFO] Connected as user USER_ID
   [2023-03-19 23:01:08,582][DEBUG] Receiving messages        
   [2023-03-19 23:01:08,582][DEBUG] Heartbeat sent            
   [2023-03-19 23:01:08,743][DEBUG] Message received: events {
     transactionStatus {
       txnId: 3675756270
       succeeded: true  
     }                  
   }                    
   events {             
     transactionStatus {
       txnId: 226152914
       succeeded: true
     }
   }

   [2023-03-19 23:01:18,514][DEBUG] Message received: events {                                   
     serverHeartbeat {                                                                           
       lastRTT: 4240423196                                                                       
     }                                                                                           
   }

Actions
~~~~~~~

Listing the available actions:

.. code:: python

   ...
   print(client.available_actions)
   # Output
   ['client_heartbeat', 'client_backup_heartbeat', 'update_subscriptions', 'move', 'set_affiliation', 'set_status', 'spotlight', 'ring', 'ban', 'kick', 'set_impassable', 'chat', 'interact', 'enter_whisper', 'leave_whisper', 'set_emoji_status', 'actively_speaking', 'set_name', 'set_text_status', 'teleport', 'exit', 'enter', 'set_work_condition', 'respawn', 'spawn', 'ghost', 'init', 'set_outfit_string', 'shoot_confetti', 'set_event_status', 'set_in_conversation', 'set_current_desk', 'set_current_area', 'set_image_pointer', 'set_go_kart_id', 'map_set_dimensions', 'map_set_collisions', 'map_set_background_image_path', 'map_set_foreground_image_path', 'map_set_sprites', 'map_set_spawns', 'map_set_spaces', 'map_set_portals', 'map_set_announcer', 'map_set_assets', 'map_set_objects', 'map_set_name', 'map_set_mute_on_entry', 'map_set_use_drawn_b_g', 'map_set_walls', 'map_set_floors', 'map_set_areas', 'map_add_object', 'map_delete_object', 'map_set_spawn', 'set_is_alone', 'map_set_mini_map_image_path', 'map_set_enabled_chats', 'map_set_description', 'map_set_decoration', 'map_set_tutorial_tasks', 'play_sound', 'map_set_script', 'set_is_mobile', 'set_screen_pointer', 'set_emote_v2', 'set_focus_mode_end_time', 'map_delete_object_by_id', 'custom_action', 'block', 'set_item_string', 'trigger_item', 'notify', 'set_follow_target', 'request_to_lead', 'enter_portal', 'set_manual_video_src', 'set_subtitle', 'player_updates_session', 'map_move_object', 'chat_message_updated', 'fx_shake_object', 'fx_shake_camera', 'register_command', 'send_command', 'speaker_updates_session', 'add_inventory_item', 'remove_inventory_item', 'set_vehicle_id', 'set_speed_modifier', 'high_five', 'update_space_items', 'stop_sound', 'hip_to_be_square', 'craft', 'trigger_inventory_item', 'set_allow_screen_pointer', 'precompute_enter', 'request_mute', 'set_desk_info', 'map_set_nooks', 'request_to_join_nook', 'update_nook_permission', 'wave', 'set_pronouns', 'set_title', 'set_timezone', 'set_phone', 'set_description', 'set_profile_image_url', 'set_personal_image_url', 'set_away', 'set_city', 'set_country', 'set_start_date', 'start_recording']

Accessing the basic documentation of each action:

.. code:: python

   ...
   print(client.set_text_status.__doc__)
   # Output
   set_text_status
   Args:
           text_status (str)
           target_id (str)

OR

.. code:: python

   help(client.craft)
   # Output
   Help on method method in module gather_client_ws.actions:

   async method(*args, **kwargs) method of gather_client_ws.client.GatherClient instance
       craft
       Args:
               inputs (InputsEntry)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pyanderson/gather-client-ws",
    "name": "gather-client-ws",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "gather,gather-town,websocket",
    "author": "Anderson de Sousa Lima",
    "author_email": "anderson.sl93@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1f/37/9969ec45059436fcdb425182e3c8236a9bd8ff02aa169cb9537d32844d86/gather-client-ws-0.0.2.tar.gz",
    "platform": null,
    "description": "Gather WebSocket Client\n=======================\n\nInstallation\n------------\n\n::\n\n   pip install gather-client-ws\n\nDocumentation\n-------------\n\nAuth\n~~~~\n\nGenerate your ``API_KEY`` here: https://gather.town/apiKeys\n\nBasic Usage\n~~~~~~~~~~~\n\n.. code:: python\n\n   import asyncio\n\n   from gather_client_ws import GatherClient\n\n\n   async def producer(client):\n       await client.set_text_status(\"new status text\")\n       await client.set_emoji_status(\"\ud83d\ude01\")\n\n\n   async def main():\n       client = GatherClient(api_key=API_KEY, space_id=SPACE_ID)\n       await client.run(producer)\n\n\n   asyncio.run(main())\n\n   # Output\n   [2023-03-19 22:44:57,340][INFO] Connected to wss://engine-a00a0.aaa0-.prod.do.gather.town:443/\n   [2023-03-19 22:44:57,637][INFO] Connected as user USER_ID\n\nServer response callback\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nA callback function can be defined, this function will receive the\n``client`` and the ``ServerClientBatch`` message:\n\n.. code:: python\n\n   ...\n\n   async def callback(client, server_response):\n       for event in server_response.events:\n           print(event.WhichOneof(\"event\"))\n\n\n   async def producer(client):\n       await asyncio.sleep(30)  # hold the connection for 30 seconds\n\n\n   async def main():\n       client = GatherClient(api_key=API_KEY, space_id=SPACE_ID, callback=callback)\n       await client.run(producer)\n\n\n   asyncio.run(main())\n\n   # Expected output\n   [2023-03-19 22:56:33,840][INFO] Connected to wss://engine-a00a0.aaa0-.prod.do.gather.town:443/\n   [2023-03-19 22:56:34,351][INFO] Connected as user USER_ID\n   transactionStatus\n   transactionStatus\n   serverHeartbeat\n   serverHeartbeat\n   serverHeartbeat\n\nLogger level\n~~~~~~~~~~~~\n\nIt is possible to define the client log level.\n\n.. code:: python\n\n   import logging\n\n   ...\n\n   async def main():\n       client = GatherClient(api_key=API_KEY, space_id=SPACE_ID, log_level=logging.DEBUG)\n       await client.run(producer)\n\n\n   asyncio.run(main())\n\n   # Output\n   [2023-03-19 23:01:08,274][INFO] Connected to wss://engine-a00a0.aaa0-a.prod.do.gather.town:443/\n   [2023-03-19 23:01:08,581][INFO] Connected as user USER_ID\n   [2023-03-19 23:01:08,582][DEBUG] Receiving messages        \n   [2023-03-19 23:01:08,582][DEBUG] Heartbeat sent            \n   [2023-03-19 23:01:08,743][DEBUG] Message received: events {\n     transactionStatus {\n       txnId: 3675756270\n       succeeded: true  \n     }                  \n   }                    \n   events {             \n     transactionStatus {\n       txnId: 226152914\n       succeeded: true\n     }\n   }\n\n   [2023-03-19 23:01:18,514][DEBUG] Message received: events {                                   \n     serverHeartbeat {                                                                           \n       lastRTT: 4240423196                                                                       \n     }                                                                                           \n   }\n\nActions\n~~~~~~~\n\nListing the available actions:\n\n.. code:: python\n\n   ...\n   print(client.available_actions)\n   # Output\n   ['client_heartbeat', 'client_backup_heartbeat', 'update_subscriptions', 'move', 'set_affiliation', 'set_status', 'spotlight', 'ring', 'ban', 'kick', 'set_impassable', 'chat', 'interact', 'enter_whisper', 'leave_whisper', 'set_emoji_status', 'actively_speaking', 'set_name', 'set_text_status', 'teleport', 'exit', 'enter', 'set_work_condition', 'respawn', 'spawn', 'ghost', 'init', 'set_outfit_string', 'shoot_confetti', 'set_event_status', 'set_in_conversation', 'set_current_desk', 'set_current_area', 'set_image_pointer', 'set_go_kart_id', 'map_set_dimensions', 'map_set_collisions', 'map_set_background_image_path', 'map_set_foreground_image_path', 'map_set_sprites', 'map_set_spawns', 'map_set_spaces', 'map_set_portals', 'map_set_announcer', 'map_set_assets', 'map_set_objects', 'map_set_name', 'map_set_mute_on_entry', 'map_set_use_drawn_b_g', 'map_set_walls', 'map_set_floors', 'map_set_areas', 'map_add_object', 'map_delete_object', 'map_set_spawn', 'set_is_alone', 'map_set_mini_map_image_path', 'map_set_enabled_chats', 'map_set_description', 'map_set_decoration', 'map_set_tutorial_tasks', 'play_sound', 'map_set_script', 'set_is_mobile', 'set_screen_pointer', 'set_emote_v2', 'set_focus_mode_end_time', 'map_delete_object_by_id', 'custom_action', 'block', 'set_item_string', 'trigger_item', 'notify', 'set_follow_target', 'request_to_lead', 'enter_portal', 'set_manual_video_src', 'set_subtitle', 'player_updates_session', 'map_move_object', 'chat_message_updated', 'fx_shake_object', 'fx_shake_camera', 'register_command', 'send_command', 'speaker_updates_session', 'add_inventory_item', 'remove_inventory_item', 'set_vehicle_id', 'set_speed_modifier', 'high_five', 'update_space_items', 'stop_sound', 'hip_to_be_square', 'craft', 'trigger_inventory_item', 'set_allow_screen_pointer', 'precompute_enter', 'request_mute', 'set_desk_info', 'map_set_nooks', 'request_to_join_nook', 'update_nook_permission', 'wave', 'set_pronouns', 'set_title', 'set_timezone', 'set_phone', 'set_description', 'set_profile_image_url', 'set_personal_image_url', 'set_away', 'set_city', 'set_country', 'set_start_date', 'start_recording']\n\nAccessing the basic documentation of each action:\n\n.. code:: python\n\n   ...\n   print(client.set_text_status.__doc__)\n   # Output\n   set_text_status\n   Args:\n           text_status (str)\n           target_id (str)\n\nOR\n\n.. code:: python\n\n   help(client.craft)\n   # Output\n   Help on method method in module gather_client_ws.actions:\n\n   async method(*args, **kwargs) method of gather_client_ws.client.GatherClient instance\n       craft\n       Args:\n               inputs (InputsEntry)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Gather WebSocket service client",
    "version": "0.0.2",
    "split_keywords": [
        "gather",
        "gather-town",
        "websocket"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a2d3c5b81aa5bee234feddfd76fd8c330642447b26916706cdfcfd3848efa320",
                "md5": "5f4d0ca41fe7209231930726feb844db",
                "sha256": "4153431d3ee07b5972ed3b8493dbe3d7dc9d126fbab4e71530f8cfcc25069513"
            },
            "downloads": -1,
            "filename": "gather_client_ws-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5f4d0ca41fe7209231930726feb844db",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 34248,
            "upload_time": "2023-03-20T02:40:02",
            "upload_time_iso_8601": "2023-03-20T02:40:02.395917Z",
            "url": "https://files.pythonhosted.org/packages/a2/d3/c5b81aa5bee234feddfd76fd8c330642447b26916706cdfcfd3848efa320/gather_client_ws-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f379969ec45059436fcdb425182e3c8236a9bd8ff02aa169cb9537d32844d86",
                "md5": "93ae77cdda5afc9cfa8d6a69e53f8aa6",
                "sha256": "834fe6179a1f4bbcfe103cac4ea5f94826856c81c115a262007461bab749e91c"
            },
            "downloads": -1,
            "filename": "gather-client-ws-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "93ae77cdda5afc9cfa8d6a69e53f8aa6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 35951,
            "upload_time": "2023-03-20T02:40:04",
            "upload_time_iso_8601": "2023-03-20T02:40:04.732005Z",
            "url": "https://files.pythonhosted.org/packages/1f/37/9969ec45059436fcdb425182e3c8236a9bd8ff02aa169cb9537d32844d86/gather-client-ws-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-20 02:40:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "pyanderson",
    "github_project": "gather-client-ws",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "gather-client-ws"
}
        
Elapsed time: 0.04405s