diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..23fb746 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +venv +scratch +.vscode +.github diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..0694639 --- /dev/null +++ b/.env.sample @@ -0,0 +1 @@ +DISCORD_TOKEN="token" diff --git a/.github/ISSUE_TEMPLATE/01-bot-feature-suggestion.md b/.github/ISSUE_TEMPLATE/01-bot-feature-suggestion.md index df5426a..46e4dc8 100644 --- a/.github/ISSUE_TEMPLATE/01-bot-feature-suggestion.md +++ b/.github/ISSUE_TEMPLATE/01-bot-feature-suggestion.md @@ -7,7 +7,7 @@ assignees: "" --- **Describe your suggested improvement** -Describe what feature you'd like to see for the Discord Bot... +Describe what feature you'd like to see for the Discord bot... **Describe the benefit** Describe how this will benefit users of the server (utility, memes, etc)... diff --git a/.github/workflows/build.yml b/.github/workflows/deploy.yml similarity index 95% rename from .github/workflows/build.yml rename to .github/workflows/deploy.yml index d60a944..121de00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/deploy.yml @@ -8,7 +8,6 @@ jobs: deploy: if: (github.ref == 'refs/heads/main') && (github.repository == 'ClimateTown/discord-bot') runs-on: ubuntu-latest - needs: build permissions: id-token: write # to verify the deployment originates from an appropriate source steps: diff --git a/.gitignore b/.gitignore index aefc5e1..1a2f58d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ venv .vscode __pycache__ .pytest_cache +.env +scratch diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..882da92 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.10 +LABEL org.opencontainers.image.title="Climate Town Discord Bot" +LABEL org.opencontainers.image.description="Discord Bot used within the Climate Town Discord server." +LABEL org.opencontainers.image.source="https://github.com/ClimateTown/discord-bot" + +WORKDIR /code + +COPY requirements.txt requirements.txt + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . diff --git a/README.md b/README.md index a0e0250..5ed945c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- +

@@ -11,11 +11,11 @@ --- -This is the code that runs our custom `` bot in the Climate Town Discord server! +This is the code that runs our friendly custom bot (their name is Spud) in the Climate Town Discord server! ## Contributing -Contributions welcome! Suggest features for the bot by [posting an issue](https://github.com/ClimateTown/discord-bot/issues), or by messaging in `🔨server-suggestion-box`. +Contributions welcome! Suggest features for the bot by [posting an issue](https://github.com/ClimateTown/discord-bot/issues/new/choose), or by messaging in `🔨server-suggestion-box`. Note that bot feature suggestions are approved/dis-approved at the discretion of the moderators (aka. Comptrollers) of the server\*. diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..9a2961b --- /dev/null +++ b/bot.py @@ -0,0 +1,27 @@ +import discord +import os +from dotenv import load_dotenv + +load_dotenv() + +intents = discord.Intents.default() +intents.message_content = True + +client = discord.Client(intents=intents) + + +@client.event +async def on_ready(): + print(f"We have logged in as {client.user}") + + +@client.event +async def on_message(message): + if message.author == client.user: + return + + if message.content.startswith("$hello"): + await message.channel.send("Hello!") + + +client.run(os.getenv("DISCORD_TOKEN")) diff --git a/requirements.in b/requirements.in index 844f49a..0b95797 100644 --- a/requirements.in +++ b/requirements.in @@ -1 +1,5 @@ discord.py +pip-tools +pre-commit +pytest +python-dotenv diff --git a/requirements.txt b/requirements.txt index c6d48ea..9489d51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,19 +12,71 @@ async-timeout==4.0.2 # via aiohttp attrs==22.2.0 # via aiohttp +build==1.0.3 + # via pip-tools +cfgv==3.4.0 + # via pre-commit charset-normalizer==2.1.1 # via aiohttp +click==8.1.7 + # via pip-tools discord-py==2.3.2 # via -r requirements.in +distlib==0.3.8 + # via virtualenv +exceptiongroup==1.2.0 + # via pytest +filelock==3.13.1 + # via virtualenv frozenlist==1.3.3 # via # aiohttp # aiosignal +identify==2.5.33 + # via pre-commit idna==3.4 # via yarl +iniconfig==2.0.0 + # via pytest multidict==6.0.4 # via # aiohttp # yarl +nodeenv==1.8.0 + # via pre-commit +packaging==23.2 + # via + # build + # pytest +pip-tools==7.3.0 + # via -r requirements.in +platformdirs==4.1.0 + # via virtualenv +pluggy==1.3.0 + # via pytest +pre-commit==3.6.0 + # via -r requirements.in +pyproject-hooks==1.0.0 + # via build +pytest==7.4.4 + # via -r requirements.in +python-dotenv==1.0.0 + # via -r requirements.in +pyyaml==6.0.1 + # via pre-commit +tomli==2.0.1 + # via + # build + # pip-tools + # pyproject-hooks + # pytest +virtualenv==20.25.0 + # via pre-commit +wheel==0.42.0 + # via pip-tools yarl==1.9.2 # via aiohttp + +# The following packages are considered to be unsafe in a requirements file: +# pip +# setuptools diff --git a/spud.png b/spud.png new file mode 100644 index 0000000..851966c Binary files /dev/null and b/spud.png differ