Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #3

Merged
merged 3 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Problems? Check out our [Discord Server](https://discord.gg/nBUqrWf).

- [Building your first bot](docs/BUILDING_A_BOT.md)
- [Contributing](docs/CONTRIBUTING.md)
<!-- - [Internals](docs/INTERNALS.md) -->
- [Internals](docs/INTERNALS.md)

## Contributing
Check our [Contributing Guidelines](docs/CONTRIBUTING.md) to get started! If you are here for the Discord API, please check our [Discord API Roadmap](docs/DISCORD_ROADMAP.md).
Expand Down
40 changes: 20 additions & 20 deletions docs/BUILDING_A_BOT.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ You can also initialize it by providing the token directly to `discord_init()`:
struct discord *client = discord_init(BOT_TOKEN);
```

### [discord\_config\_init()](https://cee-studio.github.io/orca/apis/discord.html?highlight=set_on_command#c.discord_config_init)
### discord\_config\_init()

`discord_config_init(char[])` : initialize the bot with a configuration file

Returns [struct discord](https://cee-studio.github.io/orca/apis/discord.html?highlight=set_on_command#c.discord): the bot client
Returns `struct discord`: the bot client

| Member Parameters | Description |
| :---------------- | :------------------------------ |
| char[] | the name of the bot config file |

## [discord\_init()](https://cee-studio.github.io/orca/apis/discord.html?highlight=set_on_command#c.discord_init)
## discord\_init()

`discord_init(char[])` : initialize the bot with a token

Returns [struct discord](https://cee-studio.github.io/orca/apis/discord.html?highlight=set_on_command#c.discord): the bot client
Returns `struct discord` the bot client

| Member Parameters | Description |
| :---------------- | :------------------- |
Expand All @@ -110,40 +110,40 @@ discord_set_on_command(client, "pong", &on_pong);
discord_run(client);
```

### [discord\_set\_on\_ready()](https://cee-studio.github.io/orca/apis/discord.html?highlight=set_on_command#c.discord_set_on_ready)
### discord\_set\_on\_ready()

`discord_set_on_ready(struct discord*, discord_on_idle*)`: calls `on_ready` callback when the connection is succesfully established

| Member Parameters | Description |
| :------------------------------------------------------------------------------------------- | :---------------------------------------------------- |
| [struct discord](https://cee-studio.github.io/orca/apis/discord.html#c.discord) | the client stucture |
| [discord\_on\_idle](https://cee-studio.github.io/orca/apis/discord.html#c.discord_idle_cb)\* | the callback to run when the READY event is triggered |
| Member Parameters | Description |
| :---------------------| :---------------------------------------------------- |
| `struct discord` | the client stucture |
| `discord\_on\_idle()` | the callback to run when the READY event is triggered |

### [discord\_set\_on\_command()](https://cee-studio.github.io/orca/apis/discord.html?highlight=set_on_command#c.discord_set_on_command)
### discord\_set\_on\_command()

`discord_set_on_command(struct discord*, char[], discord_message_cb*)`: runs callback when a command prefix is detected on chat

| Member Parameters | Description |
| :------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |
| [struct discord](https://cee-studio.github.io/orca/apis/discord.html#c.discord) | the client stucture |
| char[] | The chat command expected to trigger a callback response |
| [discord\_on\_message](https://cee-studio.github.io/orca/apis/discord.html#c.discord_message_cb)\* | the message type function callback to run when its corresponding event is triggered |
| Member Parameters | Description |
| :----------------------| :---------------------------------------------------------------------------------- |
| `struct discord` | the client stucture |
| char[] | The chat command expected to trigger a callback response |
| `discord\_on\_message` | the message type function callback to run when its corresponding event is triggered |

### [discord\_run()](https://cee-studio.github.io/orca/apis/discord.html#c.discord_run)
### discord\_run()

`discord_run(struct discord*)`: establishes a connection to Discord, run until error or shutdown

| Member Parameters | Description |
| :------------------------------------------------------------------------------ | :------------------ |
| [struct discord](https://cee-studio.github.io/orca/apis/discord.html#c.discord) | the client stucture |
| Member Parameters | Description |
| :-----------------| :------------------ |
| `struct discord` | the client stucture |

## Clean up the bot

```c
discord_cleanup(client);
```

### [discord\_cleanup()](https://cee-studio.github.io/orca/apis/discord.html?highlight=set_on_command#c.discord_cleanup)
### discord\_cleanup()

`discord_cleanup(struct discord*)`: cleanup client initialized by `discord_init()` or `discord_config_init()`

Expand Down
36 changes: 21 additions & 15 deletions docs/INTERNALS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
# Introduction

If you are interested in contributing with more than just coding, you found the
right place! The ultimate goal is to help you understand how Orca works internally,
and as a result, write your own API endpoint. <!-- This guide will assist you with writing your first endpoint, we will be using the GitHub API but the same techniques should apply to any other API. -->
right place! The ultimate goal is to help you understand how Concord works internally,
and as a result, write your own API endpoint.

Before starting make sure you have followed the [build instructions](../README.md#build-instructions)!

## About Orca
## About Concord

Orca is a collection of REST API wrappers that are written in C. Orca currently
covers the Discord API (and GitHub, Reddit, and Slack to some degree).
Concord is a Discord API wrappers written entirely in C.

# A Tour of Orca
# A Tour of Concord

While Orca is not complex, it is still a decently sized project. Navigating the
While Concord is not complex, it is still a decently sized project. Navigating the
documentation may be confusing to new potential contributors when searching for
certain things. This section aims to assist you with understanding each of the
major folders and files.

## Orca Specs
## Concord Specs

Wrapping an API object in C can quickly get overwhelming and repetitive, considering
one have to address many things modern languages would take for granted, such as the
Expand All @@ -31,7 +30,7 @@ for wrapping and generating API objects.

- `specs/`: This is the folder we write our specs for code-generation, it contains multiple
JSON templates that are parsed by `specs/specs-gen.c`. To generate code from
scratch simply run `make specs_gen`, the code will be placed inside of `specs-code/`.
scratch simply run `make specs_gen`, the code will be placed inside of `src/specs-code/`.

## Examples

Expand All @@ -40,11 +39,16 @@ The `examples/` folder is where we place our up-to-date bot examples.
When adding a new feature it is encouraged that the contributor writes an example bot
to demonstrate said feature, as a sort of makeshift test for other users and developers.

## APIs source-code
## API source-code

`discord-*.c`, `github-*.c`, `reddit-*.c`, and `slack-*.c` are the source
files that handle all the logic behind their individual API wrapper.
The `src/` folder is where we place all of our Discord API wrapping logic.

## Common source-code

The `common/` folder is where we place all of our generic logic, such as handling of the
WebSockets and REST protocols, threadpool management, etc.

<!-- REWRITE FOR DISCORD
# Choosing an Endpoint

Now that the boring reading stuff is out of the way, we can get to the fun
Expand Down Expand Up @@ -142,7 +146,7 @@ that are used internally and by the user.
On a base level, this allow us to generate a structure that holds a ``ja_str`` which
has a **decorator** of an ``ntl``.

``ja_str`` is a string found in the JSON library that Orca uses internally.
``ja_str`` is a string found in the JSON library that Concord uses internally.
It holds a single value, which is a string.

A **decorator** is simply a token that is put after the type. A decorator you may be familiar with is a `*`
Expand Down Expand Up @@ -177,7 +181,7 @@ this format:
https://api.github.com/repos/{owner}/{repo}/topics
```

Anything inside braces are intended to be replaced with a string. If we wanted to get the topics for Orca,
Anything inside braces are intended to be replaced with a string. If we wanted to get the topics for Concord,
we would send a GET request to this URL:

```
Expand Down Expand Up @@ -215,4 +219,6 @@ In situations where you do not know how much information the buffer should have,
much to fit on the stack (unlikely), or because it has dynamic data, you can use a **sized buffer** which must be managed
through the response handler. This will be covered and added to this section at a later date.

If you have any questions, feel free to join our [Discord server](https://discord.gg/nBUqrWf).
-->

If you have any questions, feel free to join our [Discord server](https://discord.gg/Y7Xa6MA82v).
80 changes: 0 additions & 80 deletions docs/SAIPHC.md

This file was deleted.