An open API service indexing awesome lists of open source software.

https://github.com/cnily03/ctf-bot

A discord bot for CTF crafting based on Pycord.
https://github.com/cnily03/ctf-bot

bot capture-the-flag ctf ctf-bot ctf-helper ctf-helper-bot ctf-tools discord discord-bot discordbot helper python

Last synced: about 2 months ago
JSON representation

A discord bot for CTF crafting based on Pycord.

Awesome Lists containing this project

README

          

# CTF Helper

A discord bot for CTF crafting based on [Pycord](https://pycord.dev/github).

## Application

Invite CTF Helper to your server: https://discord.cnily.me/invite/bot/ctf-bot

If you want to create your own bot, clone this repository to your computer.

```bash
git clone https://github.com/Cnily03/ctf-bot.git
```

Install requirements.

```bash
pip install -r requirements.txt
```

or if you use Poetry to manage your project, install as following.

```bash
poetry install
```

Make file `token` at root directory, which contains Token of your discord bot .

Then start the program.

```bash
python ctf-bot
```

## Configure

Edit `config.yml` at the root directory.

## Development

### Extensions

#### Class `BotController`

`BotController` is a packed abstract class of `discord.Bot`, which can help control the bot more easily.

##### Prototype of `BotController`

```python
class BotController:
def __init__(self, bot: discord.Bot):
self.bot = bot
def use(self, plugin: AppPlugin):
plugin.apphandler(self.bot)
```

#### Class `AppPlugin`

`AppPlugin` is a abstract class for developers to create various plugins with colorful functions.

The implementation of API to connect with `bot` is method `apphandler` with a param `bot` in type `discord.Bot`.

##### Prototype of `AppPlugin`

```python
class AppPlugin:
def apphandler(self, bot: discord.Bot): pass
```

#### Example

```python
class CustomPlugin(AppPlugin):
# do something here
def apphandler(self, bot: discord.Bot):
#do something here
bot = discord.Bot()
app = BotController(bot)
app.use(CustomPlugin())
```

Many functions in this project is implemented in this way.

### Register commands

All the commands python file is in `commands` directory.

Remember to modify `register_args` in `__main__.py` after adding or removing a command.