Skip to content

Commit

Permalink
Pwnybot Forum Rewrite (#30)
Browse files Browse the repository at this point in the history
* remove most things
probably too aggressive, but we can add stuff back
also, discord-py-slash-commands seems to have moved to discord-py-interactions
added generic bot

* create basic extension

* add back util

* add back template

* rename command decorators

* remove dm config since all commands will be restricted to guild anyways

* added ctf cog
allow other parameters to be passed via command decorator
make custom decorator inherit stuff

* added docstrings to command decorators

* generalize sanitize_name and sanitize class and function names
unable to sanitize option names since calls require exact param name

* enable base type checking

* add placeholders for ctf and chal commands

* update some things

* ctf create now creates a forum
oops that's a lot of changes

* add tags

* pinned general post

* placeholder for adding custom category

* implement add_category

* add category auto complete for chal create

* change tags to only be categories and unsolved and no combinations

* improve autocomplete with filtering

* prevent adding duplicate tags

* implement chal create

* add some spacing

* move general name to config

* implement chal solve

* remove testing cog

* move challenge categories to config file

* set permissions to ctf role only for ctf forums

* remove underscore for consistent naming

* implement addrole

* formatting

* add ctf optin
since it needs different permissions, I decided to put it under different a command

* fix class name

* implement optout

* some formatting details

* update readme permissions

* update readme environment variables

* remove workspace file

* change for else to any
#30 (comment)

* added docstring about autocomplete
addresses #30 (comment)

* add checkmark to channel name after solving
add check if a challenge has already been marked as solved
addresses #30 (comment)

* /chal solve sends a message in general
addresses #30 (comment)

* alias admin check at top of file
addresses #30 (comment)

* make unsolved check lowercase

* change for else to any pattern
addresses #30 (comment)

* add newline
addresses #30 (comment)

* remove networking
addresses #30 (comment)

* break conditional into separate statements
addresses #30 (comment)

* change max_length in sanitize_name to keyword argument
addresses #30 (comment)

* add error message if /ctfs optout called with no ctf role

* change permissions error message

* error if already have ctf role

* add general message

* solve message in general includes flag

* add unsolved variants of categories (combination tags)

---------

Co-authored-by: jupiter <[email protected]>
  • Loading branch information
reteps and user32121 committed Mar 10, 2024
1 parent f991894 commit f2e4352
Show file tree
Hide file tree
Showing 40 changed files with 288 additions and 3,217 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
debug*
*.sw*
__pycache__/
.vscode/
27 changes: 1 addition & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,10 @@
FROM python:3.9
FROM python:3.10

# Change into the source directory
WORKDIR /bot

COPY . .

RUN apt-get update

RUN apt-get install -y gfortran libopenblas-dev liblapack-dev

RUN pip install -r requirements.txt

# DiscordChatExporter and Dependencies

# https://github.com/dotnet/dotnet-docker/blob/main/documentation/scenarios/installing-dotnet.md

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
curl \
ca-certificates \
\
# .NET dependencies
libc6 \
libgcc1 \
libgssapi-krb5-2 \
libicu67 \
libssl1.1 \
libstdc++6 \
zlib1g \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -Channel 6.0 -Runtime dotnet -InstallDir /usr/share/dotnet \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet

CMD [ "python", "./main.py" ]
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@ The official sigpwny discord bot.

Check the 'bot' scope, and after doing so, the list of bot-specific permissions should pop up. You will need:

+ Manage Roles
+ Manage Channels
+ Read Messages/View Channels
+ Send Messages
+ Read Message History
+ Add Reactions

Additionally, go to the 'Bot' tab and enable the 'Message Content Intent'.
+ Manage Roles
+ Manage Threads

In the future, more permission may be needed, so ask the current maintainer.

Expand All @@ -25,15 +20,13 @@ Then, copy the link and invite the bot to your server.

```
DISCORD_TOKEN=XXXXXX
CTFD_TOKEN=XXXXXX
GUILD_IDS=GUILD1
GUILD_IDS=GUILD1_ID
CTF_CATEGORY_CHANNELS=CHANNEL1_ID
CTF_ROLES=ROLE1_ID
UIUC_ROLES=ROLE2_ID
```

Fill in the DISCORD_TOKEN with the token from the 'Bot' tab of the discord developer portal. Then, fill in the GUILD_IDS with a comma seperated list of each guild IDs you want the server running on. If you just have one, do `GUILD_IDS=xxxxxx`.

Note that the bot is still partially functional without `CTFD_TOKEN` being defined.

Using a role with perms higher than the level you need, make sure that `lib/config.py` has an accurate admin role ID. Some commands may not work if this is set incorrectly.
Fill in the `DISCORD_TOKEN` with the token from the 'Bot' tab of the discord developer portal. Then, fill in the `GUILD_IDS` with a comma seperated list of each guild IDs you want the server running on. If you just have one, do `GUILD_IDS=XXXXXX`. Same goes for `CTF_CATEGORY` (category channels), `CTF_ROLES` (roles that can access CTF channels), and `UIUC_ROLES` (roles that can gain CTF roles).


3. Startup docker with this command
Expand Down
49 changes: 0 additions & 49 deletions cogs/binary/binary.py

This file was deleted.

57 changes: 0 additions & 57 deletions cogs/breakout/breakout.py

This file was deleted.

Loading

0 comments on commit f2e4352

Please sign in to comment.