Skip to content

Commit 0941b25

Browse files
Merge pull request #101 from LizardByte/nightly
v0.1.1
2 parents 688ef22 + b091f44 commit 0941b25

14 files changed

+232
-73
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
version: 2
77
updates:
8+
- package-ecosystem: "docker"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"
12+
time: "00:00"
13+
target-branch: "nightly"
14+
open-pull-requests-limit: 10
15+
816
- package-ecosystem: "github-actions"
917
directory: "/"
1018
schedule:

.github/label-actions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ invalid:duplicate:
2525
invalid:support:
2626
comment: >
2727
:wave: @{issue-author}, we use the issue tracker exclusively for bug reports.
28-
However, this issue appears to be a support request. Please use
29-
[Discord](https://docs.lizardbyte.dev/about/support.html#discord) for support issues. Thanks.
28+
However, this issue appears to be a support request. Please use our
29+
[Support Center](https://app.lizardbyte.dev/support) for support issues. Thanks.
3030
close: true
3131
lock: true
3232
lock-reason: 'off-topic'

.github/workflows/ci-docker.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ jobs:
3636
outputs:
3737
dockerfile: ${{ steps.check.outputs.dockerfile }}
3838

39+
lint_dockerfile:
40+
name: Lint Dockerfile
41+
needs: [check_dockerfile]
42+
if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }}
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Lint Dockerfile
46+
uses: actions/checkout@v3
47+
48+
- uses: hadolint/[email protected]
49+
with:
50+
dockerfile: ./Dockerfile
51+
3952
check_changelog:
4053
name: Check Changelog
4154
needs: [check_dockerfile]
@@ -68,6 +81,8 @@ jobs:
6881
steps:
6982
- name: Checkout
7083
uses: actions/checkout@v3
84+
with:
85+
submodules: recursive
7186

7287
- name: Prepare
7388
id: prepare

.github/workflows/issues-stale.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions/stale@v5
1919
with:
2020
close-issue-message: >
21-
This issue was closed because it has been stalled for 5 days with no activity.
21+
This issue was closed because it has been stalled for 10 days with no activity.
2222
close-pr-message: >
2323
This PR was closed because it has been stalled for 10 days with no activity.
2424
days-before-stale: 90
@@ -28,12 +28,13 @@ jobs:
2828
exempt-pr-labels: 'dependencies,l10n'
2929
stale-issue-label: 'stale'
3030
stale-issue-message: >
31-
This issue is stale because it has been open for 30 days with no activity.
32-
Comment or remove the stale label, otherwise this will be closed in 5 days.
31+
This issue is stale because it has been open for 90 days with no activity.
32+
Comment or remove the stale label, otherwise this will be closed in 10 days.
3333
stale-pr-label: 'stale'
3434
stale-pr-message: >
3535
This PR is stale because it has been open for 90 days with no activity.
3636
Comment or remove the stale label, otherwise this will be closed in 10 days.
37+
repo-token: ${{ secrets.GH_BOT_TOKEN }}
3738

3839
- name: Invalid Template
3940
uses: actions/stale@v5
@@ -52,3 +53,4 @@ jobs:
5253
stale-pr-label: 'invalid:template-incomplete'
5354
stale-pr-message: >
5455
Invalid PR template.
56+
repo-token: ${{ secrets.GH_BOT_TOKEN }}

.github/workflows/issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
- name: Label Actions
2020
uses: dessant/label-actions@v2
2121
with:
22-
github-token: ${{ github.token }}
22+
github-token: ${{ secrets.GH_BOT_TOKEN }}

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## [0.1.1] - 2022-08-20
4+
### Changed
5+
- Enable timeout callback for `/docs` command after 45s
6+
- Incomplete `/docs` commands are deleted 30s after the timeout period
7+
- `/docs` command is reset for each call
8+
- Fix url returned for `/docs` command when `None` was selected as category
9+
- Move constants to `discord_constants.py`
10+
- Move avatar related items to `discord_avatar.py`
11+
### Added
12+
- Add `discord_modals.py`
13+
### Dependencies
14+
- Bump flask from 2.2.1 to 2.2.2
15+
- Bump py-cord from 2.0.0 to 2.0.1
16+
17+
318
## [0.1.0] - 2022-08-07
419
### Changed
520
- Select Menus added to `docs` slash command to give finer control of returned documentation url

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ ENV GRAVATAR_EMAIL=$GRAVATAR_EMAIL
2222
ENV IGDB_CLIENT_ID=$IGDB_CLIENT_ID
2323
ENV IGDB_CLIENT_SECRET=$IGDB_CLIENT_SECRET
2424

25+
RUN mkdir /app
26+
WORKDIR /app/
27+
2528
COPY requirements.txt .
2629
COPY *.py .
2730
RUN pip install --no-cache-dir -r requirements.txt

discord_avatar.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# standard imports
2+
from io import BytesIO
3+
import os
4+
5+
# lib imports
6+
import requests
7+
8+
# local imports
9+
from discord_helpers import get_bot_avatar
10+
11+
# avatar
12+
avatar = get_bot_avatar(gravatar=os.environ['GRAVATAR_EMAIL'])
13+
14+
avatar_response = requests.get(url=avatar)
15+
avatar_img = BytesIO(avatar_response.content).read()

discord_bot.py

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# standard imports
22
from datetime import datetime
3-
from io import BytesIO
43
import json
54
import os
65
import random
@@ -13,30 +12,24 @@
1312
import requests
1413

1514
# local imports
16-
from discord_helpers import get_bot_avatar, igdb_authorization, month_dictionary
17-
from discord_views import DocsCommandView, DonateCommandView
15+
from discord_constants import org_name, bot_name, bot_url
16+
from discord_helpers import igdb_authorization, month_dictionary
1817
import keep_alive
1918

2019
# development imports
2120
from dotenv import load_dotenv
2221
load_dotenv(override=False) # environment secrets take priority over .env file
2322

23+
if True: # hack for flake8
24+
from discord_avatar import avatar, avatar_img
25+
from discord_views import DocsCommandView, DonateCommandView, RefundCommandView
2426

2527
# constants
2628
bot_token = os.environ['BOT_TOKEN']
2729
bot = discord.Bot(intents=discord.Intents.all(), auto_sync_commands=True)
2830

29-
org_name = 'LizardByte'
30-
bot_name = f'{org_name}-Bot'
31-
bot_url = 'https://app.lizardbyte.dev'
3231
user_mention_desc = 'Select the user to mention'
3332

34-
# avatar
35-
avatar = get_bot_avatar(gravatar=os.environ['GRAVATAR_EMAIL'])
36-
37-
response = requests.get(url=avatar)
38-
avatar_img = BytesIO(response.content).read()
39-
4033
# context reference
4134
# https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context
4235
# https://docs.pycord.dev/en/master/ext/commands/api.html#discord.ext.commands.Context
@@ -198,13 +191,55 @@ async def docs_command(ctx: discord.ApplicationContext,
198191
user : discord.Commands.Option
199192
Username to mention in response.
200193
"""
201-
embed = discord.Embed(title="Select a project", color=0xDC143C)
194+
embed = discord.Embed(title="Select a project", color=0xF1C232)
195+
embed.set_footer(text=bot_name, icon_url=avatar)
196+
197+
if user:
198+
await ctx.respond(
199+
f'{ctx.author.mention}, {user.mention}',
200+
embed=embed,
201+
ephemeral=False,
202+
view=DocsCommandView(ctx=ctx)
203+
)
204+
else:
205+
await ctx.respond(
206+
f'{ctx.author.mention}',
207+
embed=embed,
208+
ephemeral=False,
209+
view=DocsCommandView(ctx=ctx)
210+
)
211+
212+
213+
@bot.slash_command(name="refund",
214+
description="Refund form for unhappy customers."
215+
)
216+
async def refund_command(ctx: discord.ApplicationContext,
217+
user: Option(discord.Member,
218+
description=user_mention_desc,
219+
required=False)):
220+
"""
221+
The ``refund`` slash command.
222+
223+
Sends a discord embed, with a `Modal`, to the server and channel where the command was issued. This command is
224+
pure satire.
225+
226+
Parameters
227+
----------
228+
ctx : discord.ApplicationContext
229+
Request message context.
230+
user : discord.Commands.Option
231+
Username to mention in response.
232+
"""
233+
embed = discord.Embed(title="Refund request",
234+
description="Original purchase price: $0.00\n\n"
235+
"Select the button below to request a full refund!",
236+
color=0xDC143C)
202237
embed.set_footer(text=bot_name, icon_url=avatar)
203238

204239
if user:
205-
await ctx.respond(f'{ctx.author.mention}, {user.mention}', embed=embed, view=DocsCommandView(ctx=ctx))
240+
await ctx.respond(user.mention, embed=embed, view=RefundCommandView())
206241
else:
207-
await ctx.respond(f'{ctx.author.mention}', embed=embed, view=DocsCommandView(ctx=ctx))
242+
await ctx.respond(embed=embed, view=RefundCommandView())
208243

209244

210245
@tasks.loop(minutes=60.0)

discord_constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org_name = 'LizardByte'
2+
bot_name = f'{org_name}-Bot'
3+
bot_url = 'https://app.lizardbyte.dev'

discord_modals.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# lib imports
2+
import discord
3+
4+
5+
class RefundModal(discord.ui.Modal):
6+
"""
7+
Class representing `discord.ui.Modal` for ``refund`` slash command.
8+
"""
9+
def __init__(self, *args, **kwargs) -> None:
10+
super().__init__(*args, **kwargs)
11+
12+
self.add_item(discord.ui.InputText(label="Name"))
13+
self.add_item(discord.ui.InputText(label="Email"))
14+
self.add_item(discord.ui.InputText(label="Purchase Date"))
15+
16+
async def callback(self, interaction: discord.Interaction):
17+
embed = discord.Embed(title="Refund request completed",
18+
description="Your refund is being processed!")
19+
embed.add_field(name="Original price", value="$0.00")
20+
embed.add_field(name="Refund amount", value="$0.00")
21+
await interaction.response.send_message(embeds=[embed])

0 commit comments

Comments
 (0)