From e43744586180357b9d50b1ff2687832c325cf7e8 Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Thu, 14 Mar 2024 12:53:32 +0500 Subject: [PATCH] stage changes --- .envrc | 1 + Cargo.lock | 2 +- Cargo.toml | 2 +- LICENSE | 22 +++++++++++++++++ README.md | 16 +++---------- flake.lock | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 55 ++++++++++++++++++++++++++++++++++++++++++ info.md | 16 +++++++++++++ 8 files changed, 169 insertions(+), 15 deletions(-) create mode 100644 .envrc create mode 100644 LICENSE create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 info.md diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/Cargo.lock b/Cargo.lock index e6666f2..4864cce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1002,7 +1002,7 @@ dependencies = [ ] [[package]] -name = "oscuro" +name = "oscuro-discord-bot" version = "0.1.0" dependencies = [ "anyhow", diff --git a/Cargo.toml b/Cargo.toml index ebdf06d..a9db53a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "oscuro" +name = "oscuro-discord-bot" version = "0.1.0" edition = "2021" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fe24b2e --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2023-2024 George Kusayko [L-Nafaryus] + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 086084e..fab900d 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,6 @@ -# Serenity Hello World Bot with Shuttle +# Oscuro - Discord Bot -In this example we will deploy a Serenity bot with Shuttle that responds to the `!hello` command with `world!`. To run this bot we need a valid Discord Token. To get started log in to the [Discord developer portal](https://discord.com/developers/applications). +# License -1. Click the New Application button, name your application and click Create. -2. Navigate to the Bot tab in the lefthand menu, and add a new bot. -3. On the bot page click the Reset Token button to reveal your token. Put this token in your `Secrets.toml`. It's very important that you don't reveal your token to anyone, as it can be abused. Create a `.gitignore` file to omit your `Secrets.toml` from version control. -4. For the sake of this example, you also need to scroll down on the bot page to the Message Content Intent section and enable that option. -To add the bot to a server we need to create an invite link. - -1. On your bot's application page, open the OAuth2 page via the lefthand panel. -2. Go to the URL Generator via the lefthand panel, and select the `bot` scope as well as the `Send Messages` permission in the Bot Permissions section. -3. Copy the URL, open it in your browser and select a Discord server you wish to invite the bot to. - -For more information please refer to the [Discord docs](https://discord.com/developers/docs/getting-started) as well as the [Serenity repo](https://github.com/serenity-rs/serenity) for more examples. +**oscuro** is licensed under the [MIT License](LICENSE). diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9ff60ae --- /dev/null +++ b/flake.lock @@ -0,0 +1,70 @@ +{ + "nodes": { + "crane": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703439018, + "narHash": "sha256-VT+06ft/x3eMZ1MJxWzQP3zXFGcrxGo5VR2rB7t88hs=", + "owner": "ipetkov", + "repo": "crane", + "rev": "afdcd41180e3dfe4dac46b5ee396e3b12ccc967a", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": [] + }, + "locked": { + "lastModified": 1703485398, + "narHash": "sha256-eJkxehEmQjSLD/UwPCXlHxH6g41R66fY7Hw9AOSsQA8=", + "owner": "nix-community", + "repo": "fenix", + "rev": "57a533b99ebe646449b71718e43ca29b550bd254", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1703134684, + "narHash": "sha256-SQmng1EnBFLzS7WSRyPM9HgmZP2kLJcPAz+Ug/nug6o=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d6863cbcbbb80e71cecfc03356db1cda38919523", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..904809f --- /dev/null +++ b/flake.nix @@ -0,0 +1,55 @@ +{ + description = "Basic rust template"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; }; + fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; inputs.rust-analyzer-src.follows = ""; }; + }; + + outputs = inputs @ { self, nixpkgs, crane, fenix, ... }: + let + forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ]; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in + { + packages = forAllSystems (system: { + oscuro = + let + pkgs = nixpkgsFor.${system}; + cranelib = crane.lib.${system}; + in + cranelib.buildPackage { + src = cranelib.cleanCargoSource (cranelib.path ./.); + strictDeps = true; + + buildInputs = [ ]; + }; + + default = self.packages.${system}.oscuro; + }); + + checks = forAllSystems (system: { + inherit (self.packages.${system}.oscuro); + + oscuro-fmt = let cranelib = crane.lib.${system}; in + cranelib.cargoFmt { + src = cranelib.cleanCargoSource (cranelib.path ./.); + }; + }); + + apps = forAllSystems (system: { + default = { + type = "app"; + program = "${self.packages.${system}.oscuro}/bin/oscuro"; + }; + }); + + devShells = forAllSystems (system: { + default = let pkgs = nixpkgsFor.${system}; in pkgs.mkShell { + nativeBuildInputs = [ fenix.packages.${system}.complete.toolchain pkgs.cargo-shuttle ]; + }; + }); + }; + +} diff --git a/info.md b/info.md new file mode 100644 index 0000000..086084e --- /dev/null +++ b/info.md @@ -0,0 +1,16 @@ +# Serenity Hello World Bot with Shuttle + +In this example we will deploy a Serenity bot with Shuttle that responds to the `!hello` command with `world!`. To run this bot we need a valid Discord Token. To get started log in to the [Discord developer portal](https://discord.com/developers/applications). + +1. Click the New Application button, name your application and click Create. +2. Navigate to the Bot tab in the lefthand menu, and add a new bot. +3. On the bot page click the Reset Token button to reveal your token. Put this token in your `Secrets.toml`. It's very important that you don't reveal your token to anyone, as it can be abused. Create a `.gitignore` file to omit your `Secrets.toml` from version control. +4. For the sake of this example, you also need to scroll down on the bot page to the Message Content Intent section and enable that option. + +To add the bot to a server we need to create an invite link. + +1. On your bot's application page, open the OAuth2 page via the lefthand panel. +2. Go to the URL Generator via the lefthand panel, and select the `bot` scope as well as the `Send Messages` permission in the Bot Permissions section. +3. Copy the URL, open it in your browser and select a Discord server you wish to invite the bot to. + +For more information please refer to the [Discord docs](https://discord.com/developers/docs/getting-started) as well as the [Serenity repo](https://github.com/serenity-rs/serenity) for more examples.