-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from AW1534/dev
restructured docs
- Loading branch information
Showing
6 changed files
with
137 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,40 @@ | ||
# cry-vs | ||
An official API wrapper for [Crypto_Versus](https://github.com/ProtagonistsWasTaken/crypto_versus) | ||
*An official API wrapper for [Crypto_Versus](https://github.com/ProtagonistsWasTaken/crypto_versus)* | ||
|
||
## Installation | ||
Installation is simple. just run `$ python -m pip install cry_vs.py` in your terminal. | ||
|
||
## Usage | ||
```{note} | ||
This package is used in a way similar to [discord.py](https://pypi.org/project/discord.py/). if you know how to use discord.py, the following steps should be a cakewalk. | ||
``` | ||
````{panels} | ||
Modern ✨ | ||
^^^ | ||
cry-vs.py is a modern library, with support for `async` and `await`. | ||
--- | ||
### Initialization & logger setup | ||
First set up the logging module. this is not necessary because cry_vs will try to set up the logging module for you, but is highly recommended. | ||
```python | ||
import logging, sys | ||
logging.basicConfig(encoding="utf-8", stream=sys.stdout, level=logging.INFO) | ||
``` | ||
|
||
Next, import cry_vs's client class. | ||
|
||
```python | ||
from cry_vs.client import Client | ||
``` | ||
|
||
Once you have done that, you can create a client. | ||
|
||
```python | ||
cry = Client() | ||
``` | ||
|
||
while there are no required arguments, you can also pass in the other arguments. | ||
|
||
| **Name** | **Type** | **Default value** | **Description** | | ||
|--------------------|----------|------------------------|-----------------------------------------------------------------------------| | ||
| **host** | string | "cry-vs.herokuapp.com" | The url of the server you want to connect to. | | ||
| **port** | int | 80 | The port that the socket should listen to. | | ||
| **allow_unsecure** | bool | False | Whether to allow unsecure connections. | | ||
| **keep_alive** | bool | True | Whether to keep the client validated by automatically refreshing the token. | | ||
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. | ||
--- | ||
### events | ||
Now that you have a client, you can start listening to events. to do so, just make a function with the `@cry.listen` decorator. | ||
|
||
for example, if you want to listen to the `on_ready` event, you would do the following: | ||
```python | ||
@cry.listen | ||
async def on_ready(): | ||
print("on_ready has been called") | ||
``` | ||
|
||
you can add as many events as you want, and they depend on the name. (function must be asynchronous) | ||
| **Name** | **Description** | | ||
|----------------------|------------------------------------------------------------------------------------| | ||
| **any_event** | Fired when any event is called | | | ||
| **on_ready** | Fired when the event emitter is initialized (right after the client has logged in) | | ||
| **on_token_refresh** | Fired after the token has been refreshed | | ||
Easy to use 📦 | ||
^^^ | ||
cry-vs.py is a simple, easy to use library, with a simple API. | ||
*[here](https://github.com/ProtagonistsWasTaken/crypto_versus/example) is an example of an application using every feature, in just one short file* | ||
--- | ||
### finalize | ||
finally, you can call `cry.login()` to start the client. | ||
````{tabbed} API Key | ||
```python | ||
cry.login("key") | ||
``` | ||
```` | ||
Open source 🌐 | ||
^^^ | ||
Nothing spooky, nothing scary, cry-vs.py is open source, and licensed under a very open [license](https://github.com/ProtagonistsWasTaken/crypto_versus/LICENSE). | ||
````{tabbed} Username and Password | ||
```python | ||
cry.login("username", "password") | ||
``` | ||
```` | ||
```{warning} | ||
this will start the event loop, and will not return until the client is closed. any logic that needs to be done after this function should be done in the `on_ready` event. | ||
``` | ||
|
||
```{toctree} | ||
:hidden: | ||
reference.md | ||
intro.md | ||
``` | ||
|
||
|
||
<!-- footer gets added here for pypi version in setup.py--> | ||
```{toctree} | ||
:hidden: | ||
reference.md | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Starter Guide | ||
*How to get started with cry-vs.py* | ||
|
||
This is a short guide to help you get a project up and running. | ||
you should then go to the [API reference](/reference.md) to extend the functionality of your project. | ||
|
||
## Installation | ||
Installation is simple. just run `$ python -m pip install cry_vs.py` in your terminal. | ||
|
||
## Usage | ||
```{note} | ||
This package is used in a way similar to [discord.py](https://pypi.org/project/discord.py/). if you are familiar with it, the following steps should be a cakewalk. | ||
``` | ||
|
||
--- | ||
### Initialization & logger setup | ||
First set up the logging module. this is not necessary because cry_vs will try to set up the logging module for you, but is highly recommended. | ||
```python | ||
import logging, sys | ||
logging.basicConfig(encoding="utf-8", stream=sys.stdout, level=logging.INFO) | ||
``` | ||
|
||
Next, import cry_vs's client class. | ||
|
||
```python | ||
from cry_vs.client import Client | ||
``` | ||
|
||
Once you have done that, you can create a client. | ||
|
||
```python | ||
cry = Client() | ||
``` | ||
|
||
while there are no required arguments, you can also pass in the other arguments. | ||
|
||
| **Name** | **Type** | **Default value** | **Description** | | ||
|--------------------|----------|------------------------|-----------------------------------------------------------------------------| | ||
| **host** | string | "cry-vs.herokuapp.com" | The url of the server you want to connect to. | | ||
| **port** | int | 80 | The port that the socket should listen to. | | ||
| **allow_unsecure** | bool | False | Whether to allow unsecure connections. | | ||
| **keep_alive** | bool | True | Whether to keep the client validated by automatically refreshing the token. | | ||
|
||
|
||
--- | ||
### events | ||
Now that you have a client, you can start listening to events. to do so, just make a function with the `@cry.listen` decorator. | ||
|
||
for example, if you want to listen to the `on_ready` event, you would do the following: | ||
```python | ||
@cry.listen | ||
async def on_ready(): | ||
print("on_ready has been called") | ||
``` | ||
|
||
you can add as many events as you want, and they depend on the name. (function must be asynchronous) | ||
|
||
| **Name** | **Description** | | ||
|----------------------|------------------------------------------------------------------------------------| | ||
| **any_event** | Fired when any event is called | | | ||
| **on_ready** | Fired when the event emitter is initialized (right after the client has logged in) | | ||
| **on_token_refresh** | Fired after the token has been refreshed | | ||
|
||
--- | ||
### finalize | ||
finally, you can call `cry.login()` to start the client. | ||
|
||
````{tabbed} API Key | ||
```python | ||
cry.login("key") | ||
``` | ||
```` | ||
|
||
````{tabbed} Username and Password | ||
```python | ||
cry.login("username", "password") | ||
``` | ||
```` | ||
```{warning} | ||
this will start the event loop, and will not return until the client is closed. any logic that needs to be done after this function should be done in the `on_ready` event. | ||
``` | ||
|
||
|
||
<!-- footer gets added here for pypi version in setup.py--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters