Skip to content

Commit

Permalink
Merge pull request #5 from AW1534/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AW1534 committed Feb 7, 2022
2 parents 0f5ef63 + d5f591a commit 23cbf97
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

release = config["version"]

ogp_site_url = "http://cry-vs-py.readthedocs.io/"
ogp_site_url = "https://cry-vs-py.readthedocs.io/"
ogp_type = "article"
ogp_custom_meta_tags = [
'<meta property="og:ignore_canonical" content="true" />',
Expand All @@ -37,6 +37,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#

html_theme = 'sphinx_book_theme'

# Add any paths that contain custom static files (such as style sheets) here,
Expand Down
7 changes: 4 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@


````{panels}
Modern ✨
**Modern ✨**
^^^
cry-vs.py is a modern library, with support for `async` and `await`.
---
Full API coverage 🔨
**Full API coverage 🔨**
^^^
built by a maintainer of [Crypto_Versus](https://github.com/ProtagonistsWasTaken/crypto_versus) itself, cry-vs.py supports the full API, implementing beta features as they are released.
---
Easy to use 📦
**Easy to use 📦**
^^^
cry-vs.py is a simple, easy to use library, with a simple API.
Expand Down
19 changes: 14 additions & 5 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

*this section is under construction, and isn't very good yet*

```{seealso}
If you are looking for the docs of the HTTP API, visit the [crypto-versus github page](https://github.com/ProtagonistsWasTaken/crypto_versus#readme)
```


```{note}
this guide will assume you have made a [`Client`](#Client) instance called `cry`
```

## Client

### Constructor parameters
Expand All @@ -17,17 +26,17 @@

| **Name** | **Parameters** | **Returns** | **Login required** | **Description** |
|------------------------|-----------------------------------------|-----------------------------|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| **Client.listen** | N/A | N/A | No | Should be used as a decorator. registers the function as an [event handler](#events). |
| **Client.login** | `username`, `password` *or* `API token` | N/A | No | Authenticates the client. this will also start the event loop so any code that needs to be done before this should be done in the on_ready event |
| **Client.game.action** | N/A | JSON (HTTP response object) | Yes | call the `/api/v0/dostuff` endpoint. that endpoint is temporary and so is this method. |
| **cry.listen** | N/A | N/A | No | Should be used as a decorator. registers the function as an [event handler](#events). |
| **cry.login** | `username`, `password` *or* `API token` | N/A | No | Authenticates the client. this will also start the event loop so any code that needs to be done before this should be done in the on_ready event |
| **cry.game.action** | N/A | JSON (HTTP response object) | Yes | call the `/api/v0/dostuff` endpoint. that endpoint is temporary and so is this method. |

### Exposed variables
*coming soon™*



## events
to create an event handler, just use the `@Client.listen` decorator. The client will automatically call the handler based on the function name.
to create an event handler, just use the `@cry.listen` decorator. The client will automatically call the handler based on the function name.
| **Name** | **Description** |
|----------------------|------------------------------------------------------------------------------------|
| **any_event** | Fired when any event is called | |
Expand All @@ -36,7 +45,7 @@ to create an event handler, just use the `@Client.listen` decorator. The client

## login parameters
````{tabbed} API Key
```python
```python
cry.login("key")
```
````
Expand Down
6 changes: 4 additions & 2 deletions src/cry_vs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import json
from .HTTPHelper import Socket


class Client:
class _Game:
def __init__(self, client):
Expand Down Expand Up @@ -95,9 +96,10 @@ def finish(r):
self.auth.token = self._Auth._Token(r.text, int(r.headers["Expire"]))
self.emitter = self.Emitter(funcs=self.funcs, client=self)
self.game = self._Game(self)
self.emitter.enqueue("on_ready", r.headers["Expire"]) # the user will most likely use this to start their code so ensure the client is ready to go before calling it
self.emitter.enqueue("on_ready", r.headers[
"Expire"]) # the user will most likely use this to start their code so ensure the client is ready to go before calling it

try: # test if the 3rd argument has been passed
try: # test if the 3rd argument has been passed
if args[2] == False:
logger.info(
"You have disabled the event loop. This means that you will not be able to use the client until you call the Client.emitter.queue() function, but the client will still work.")
Expand Down

0 comments on commit 23cbf97

Please sign in to comment.