You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* π¦ Initial rewrite of API to rust
* Some cleanups
* πͺ huge improvements
* Some more updates
* π slight test updates
* Tests pass, clippy is happy
* Minor changes
* Add GitHub action for testing
* Test if workflow works
* Testing further with GH action
* Now?
* Now?
* Only run for changes in api folder(?)
* Make a change in API folder to test gh actions
* Different approach
* Just testing out things
* And now cargo test should run?
* This time?
* This?
* Last test
* I am an idiot
* π¦ Cleaning things up
* π§Ήminor cleanups
* More cleanup
* π§Ή `cargo fmt`
* Update type for top.gg
* Adjust tests to new type
* Testing in prod
* Found it
* π ok actually fixing it
* Updates to GH actions
* 2nd attempt
* New attempt
* Now?
* This should be it
* THIS MUST BE IT AAA
* Cd into directory
* Ok Ig I have to run it before every test
* Hm
* Counter db size (#625)
* added file structure for db
* initial implimentation of updating counter based on len
* counter: cleared old map after updating db
* counter: changed it so that non unique endpoints still count
* counter: changed constant
* addressed clippy warnings
* Fucking all tests but also implement mongo
* Save to mongo on every request instead
* Make clippy happy + inc sleep in tests
* Fix tests + cargo fmt
---------
Co-authored-by: Erik Lippert <elippert1@sheffield.ac.uk>
Co-authored-by: Kile <69253692+Kile@users.noreply.github.com>
* Minor updates
* Add support for Docker
* IPC works now and it was painful
* Pretty massive commit (Add Grafana & prometheus)
* Update README + make sure it runs without Docker
* Forgot to adjust tests
* My bad
* Update README.md
* Avoid started tasks restarting
* Add dashboard json file
* Test pushing to gh Docker registry
* Test compose labels
* Hm
* Wait
* This will probably work but is it what I want?
* Hm will you show up now
* Uh now?
* Ok now?
* Hmmmmmmmm
* Rushed hotfix commit
* Come on
* Hm
* This HAS TO work
* Default is in production
* Hopefully set up grafana better
* Some cleaning up
* Rework of Killua cdn, bug fixes
* Fix numerous bugs
* Seems it has to be built on GH
* Fix actions except hug not working
* Small bugfix
* Update README.md
* Some updates, bug fixes and tests in production
* Two bug fixes
* Fix treasure map not working twice
* π¦ Major restructure (db now async) + fixes
* πSeveral bug fixes
- fixed registering new users failing
- fixed cardinfo not working for spells
- pretty major exploit that `gain` was unrestricted
* π bug fixes
* Improvements
* π¦ Pretty cool tech allowing more user installed cmds
* Bug fixes
* π οΈ bug fixes, additions and cleanupds
* Kinda dumb I did not think of this
* Minor bug fixes
* Minor fixes
* Actually fixing the bug this time
* π¦ Fixes and updates
* π Potentially final fixes for 1.1.0
* π Minor fixes
* Update README.md
* Minor spelling fix, ready to release now π
* Minor fixes and refactors
* Code quality cleanups
---------
Co-authored-by: iBrahizy <98492550+iBrahizy@users.noreply.github.com>
@@ -54,6 +52,9 @@ I started Killua as a way to learn python and different programming concepts. It
54
52
## Algorithms
55
53
Killua contains a number of interesting algorithms which I have explained more and gone into detail in the [algorithms](./algorithms/README.md) folder.
As explained previously, I use Killua as a tool to learn more about python and programming. Here is a list of programming concepts Killua uses and which ones it is planned to use at some point in the future.
@@ -71,13 +72,22 @@ As explained previously, I use Killua as a tool to learn more about python and p
71
72
*[x] caching
72
73
*[x] Website with backend
73
74
*[x] CSS
74
-
*[ ] Threading
75
-
*[ ] Github workflows
75
+
*[x] Threading
76
+
*[x] Github workflows
77
+
*[x] Docker
78
+
*[x] Rust
79
+
*[x] Prometheus
80
+
*[x] Grafana
81
+
*[ ] Dynamically deploying docker containers
82
+
*[ ] Multithreading the bot (related to the above but can be static)
76
83
77
84
## Contributors
78
85
79
86
I would like to give a big thank you to everyone who has helped me on this journey, each in their different way.
80
87
88
+
*[y21](https://github.com/y21)
89
+
> Helped me a lot with the Rust API rewrite, spotting an issue that took me8 months to track down as well as helping my code to be much cleaner.
> Wrote a great library to use Prometheus/Grafana with discord.py which became the template for the current implementation. He also assisted me with questions during this process.
117
+
105
118
*[Vivany](https://vivany.carrd.co/)
106
119
107
120
> Found a lot of hug images and also tracked down most artists of previously used ones to give them credit making Killua a much more considerate bot.
@@ -112,39 +125,126 @@ I would like to give a big thank you to everyone who has helped me on this journ
112
125
113
126
## Running Killua locally
114
127
115
-
First, set up a virtual environment. Do so with `python3 -m venv env; source env/bin/activate`. To leave the virtual environment after you are done, simply run `deactivate`
128
+
Regardless of how you decide to run Killua, you need to edit the `.env` file. This file contains all secrets needed for the bot to run. A few can be left the same as the template for debugging purpose, such as `MODE` which defined if the bot should run in development or production mode. The GF_ variables are the admin login for Grafana which can remain default unless you deploy the bot in production somewhere (which is stealing so please like - don't)
129
+
130
+
This file has a template in the same directory with the same name but with `.template` at the end. You can copy it and edit it to your liking.
131
+
132
+
Depending on if you self host mongodb or not, you may also need a mongodb account. You can to create a mongodb account [here](https://www.mongodb.com), then follow the instructions in [`setup.py`](https://github/Kile/Killua/blob/main/setup.py) and then run `python3 setup.py` or choose the "setup database" option in the menu to get the database set up. As a warning, this script is rarely run so it may not be up to date.
133
+
134
+
<details>
135
+
<summary><b>Why do I use mongoDB instead of SQL?</b></summary>
136
+
The short answer is, it's because what I was introduced to first.
137
+
138
+
But I have come to like it and chosen not to migrate for two reasons:
139
+
140
+
* I am bad at joining tables in SQL. I prefer every piece of data I need returned by just on request
141
+
* Because I am using mongoDB atlas, I don't have to worry about backups or how to migrate my db - it always stays in the same place in the cloud, making server migration insanely easy.
142
+
</details>
143
+
144
+
<details>
145
+
<summary><b>Running from source</b></summary>
146
+
147
+
While running Killua using Docker is more convenient, running from source is more flexible and allows you to make changes to the code and see them in action. To run Killua from source, follow these steps:
148
+
149
+
> WARNING:
150
+
> Not running Killua in Docker will make you unable to use Grafana or Prometheus. The code handles this on its own but if you want to use either of these you must run Killua using docker-compose. You also do not need to run the rust proxy as the IPC connection will be direct.
151
+
152
+
### Bot process
153
+
First, set up a virtual environment. Do so with `python3 -m venv env; source env/bin/activate` (for linux and macOS). To leave the virtual environment after you are done, simply run `deactivate`
116
154
117
155
`requirements.txt` contains the libraries you'll need. To install them use `pip3 install -r requirements.txt`
118
156
119
-
You will need a Mongodb account. Why do I use mongodb and not SQL? In my opinion, mongo is easier to use and you can manually add and remove data.
120
-
121
-
You will have to create a mongodb account [here](https://www.mongodb.com), then follow the instructions in [`setup.py`](https://github/Kile/Killua/blob/main/setup.py) and then run `python3 setup.py` or choose the "setup database" option in the menu to get the database set up
122
-
123
-
You will also need a file named `config.json` having the layout like this:
124
-
125
-
```plaintext
126
-
{
127
-
"token": "token",
128
-
129
-
"mongodb": "your-mongodb-token",
130
-
"pxlapi": "pxlapi-token",
131
-
"patreon": "patreon-api-token",
132
-
"dbl_token": "dbl-token",
133
-
"topgg_token": "topgg-token",
134
-
"password": "vote-pages-password",
135
-
"port": 8000,
136
-
"ipc": "ipc-token"
137
-
}
157
+
Before you run anything, unlike Docker where the env variables are automatically exported, you need to do it manually. For this you can run
158
+
```sh
159
+
export$(cat .env | xargs)
160
+
# or to ignore comments started with #
161
+
export$(grep -v '^#' .env | xargs)
162
+
```
163
+
164
+
You can remove these exports again with
165
+
```sh
166
+
unset$(cat .env | xargs)
167
+
# or to ignore comments started with #
168
+
unset$(grep -v '^#' .env | xargs)
138
169
```
139
170
140
-
You can finally run the bot in development or production environment in a menu by running `./run.sh`
171
+
### Bot
172
+
The bot can be run using
173
+
```sh
174
+
python3 -m killua
175
+
```
176
+
There are a number of command line options, you can see them by running
177
+
```sh
178
+
python3 -m killua --help
179
+
```
180
+
most notabily the `--development` flag which will prevent the bot from caching all it needs on startup and requests local API versions instead of the server. This is useful for development.
181
+
182
+
### API
183
+
To start the API, ideally you should use a different Terminal or screen/tmux session and run `cd api; cargo run`
184
+
</details>
185
+
186
+
<details>
187
+
<summary><b>Running using Docker</b></summary>
188
+
Running from Docker, while taking longer to start up, is much more convenient and allows you to use Grafana and Prometheus. To run Killua using Docker, follow these steps:
189
+
141
190
142
-
**If you add any commands, please make sure to also add tests for it. A document explaining how tests for Killua work can be found**[**here**](https://github.com/Kile/Killua/blob/main/killua/tests/README.md)
191
+
1) Clone the repository (you need the `docker-compose.yml` file)
192
+
2) Edit the `.env` file to your liking
143
193
144
-
If you don't like me using one of your images for the hug command, please contact me on discord `Kile#0606` or on `kile@killua.dev`
194
+
If you want to contribute and test your changes:
195
+
196
+
3) Run `docker compose up --build -d` to build the images and start the containers
197
+
198
+
If you want to run the pre-built images from the registry:
199
+
200
+
3) Run `docker compose up -d` to start the containers (it will pull the images from the GitHub registry)
201
+
202
+
You can access Grafana on port 3000. The configured dashboard should already be added. You can access it after logging in with username `admin` and password `admin` (unless you changed it in the env file). Prometheus can be accessed on port 8000. The API can be accessed on port 6060.
203
+
204
+
Note: if you want to expose Grafana on nginx, you need to add `proxy_set_header Host $http_host;` to the `server` config.
205
+
</details>
206
+
207
+
## Contributing
208
+
Before I start talking about contributing, I want to mention an area of Killua of which traces can be found of but it is not yet complete. This is due to me working on it for a few while and not enjoying it to a point where I decided to postpone development. This is my own testing framework for dpy. This can be found in [`killua/tests`](./killua/tests/). A part of this is also downloading all card data from somewhere so these tests can be run by someone who does not have them in their mongodb database like me. Both of these are incomplete.
209
+
210
+
211
+
### What to work on
212
+
Contributions are MASSIVELY appreciated. A codebase this big can look a bit intimidating so if you would like to contribute but don't know where to start, here are some suggestions:
213
+
***Documentation**: I try to document what I can but ultimately most of this lives in my head so I have never needed to provide detailed documentation. If you see something that is not documented or could be documented better, feel free to make a PR.
214
+
***Multiple languages**: I would love to have Killua be available in multiple languages. You do not need to speak a language other than English to build a framework for it. I can organize translators. I have attempted this previously but got insanely burned out quickly. Discord offers a way to get the language of the user so all needed is to build a smart system to use this data.
215
+
***Testing**: I have a testing framework in place but it is not complete. I would love to have a system where I can run tests on the bot and get a report of what failed and why. This is a big project and probably overengineered but it could be INSANELY useful. It was originally planned to **need** to get done for a non alpha/beta 1.0 version to get published but ultimately I don't have enough time to finish it currently so it has been removed from the roadmap of that release. Especially after the sync -> async change for any DB class, this needs a rewrite/update.
216
+
***Image generation**: I have a few commands that generate images. I rely on pxlapi for quite a few of them which is fine but if you have any other ideas (can be simple copy paste into another image) then feel free to PR them! They are always a lot of fun to use.
217
+
***An RPG system**: I am in the early stages of thinking about an RPG system using hxh's "Nen" system and building out the hunt command for a more interactive fun experience. I will likely work on this myself but I would love some help.
218
+
***Web development**: I have a website but it not very advanced. Frontend is my weak spot. If you would like to help me to build out the website, I am happy to write backend code for it. Please contact me if you are interested in this.
219
+
***Change text commands to generate images**: Commands such as `profile`, `gstats` and `server` all display their stats in text. This is ok for some (`profile` still looks ok) but generally would look much better as a generated image with fancy background etc. This is not a big project so this would be a good starting point for someone who wants to contribute but doesn't know where to start. The rust API could also be used for this in favour of making this more efficient and CPU friendly but it does not have to be.
220
+
221
+
222
+
> [!NOTE]
223
+
> (If the testing system works for the bot) If you add any commands, please make sure to also add tests for it. A document explaining how tests for Killua work can be found [**here**](./killua/tests/README.md).
224
+
> This also applies to the API, if you add any endpoints, please make sure to add tests for them.
225
+
226
+
227
+
## Grafana
228
+
Grafana is pretty cool. The Grafana dashboard was added in version 1.1.0. You can find it in grafana/dashboards/main.json. Here are some screenshots:
If you use Docker to run Killua, this would work without any additional setup. I also welcome contributions to the Grafana dashboard (maybe even add more analytics to the code!). You are also free to use my dashboard for your own bot if you want to, most of the saving data logic can be found in [`killua/cogs/prometheus.py`](./killua/cogs/prometheus.py) and [`killua/metrics/`](./killua/metrics/).
239
+
240
+
241
+
## Thanks for checking this repo out!
242
+
If you don't like me using one of your images for the hug command, please contact me on discord `k1le` or on `kile@killua.dev`
145
243
146
244
If you have any further questions, join my discord server or dm me!
147
245
246
+
If you think I did a good job at this now pretty massive codebase I spent years working on, a star would be much appreciated!!
0 commit comments