Skip to content

Commit

Permalink
Merge pull request #101 from LizardByte/nightly
Browse files Browse the repository at this point in the history
v0.1.1
  • Loading branch information
ReenigneArcher authored Aug 20, 2022
2 parents 688ef22 + b091f44 commit 0941b25
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 73 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
time: "00:00"
target-branch: "nightly"
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
4 changes: 2 additions & 2 deletions .github/label-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ invalid:duplicate:
invalid:support:
comment: >
:wave: @{issue-author}, we use the issue tracker exclusively for bug reports.
However, this issue appears to be a support request. Please use
[Discord](https://docs.lizardbyte.dev/about/support.html#discord) for support issues. Thanks.
However, this issue appears to be a support request. Please use our
[Support Center](https://app.lizardbyte.dev/support) for support issues. Thanks.
close: true
lock: true
lock-reason: 'off-topic'
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/ci-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ jobs:
outputs:
dockerfile: ${{ steps.check.outputs.dockerfile }}

lint_dockerfile:
name: Lint Dockerfile
needs: [check_dockerfile]
if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Lint Dockerfile
uses: actions/checkout@v3

- uses: hadolint/[email protected]
with:
dockerfile: ./Dockerfile

check_changelog:
name: Check Changelog
needs: [check_dockerfile]
Expand Down Expand Up @@ -68,6 +81,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Prepare
id: prepare
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/issues-stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/stale@v5
with:
close-issue-message: >
This issue was closed because it has been stalled for 5 days with no activity.
This issue was closed because it has been stalled for 10 days with no activity.
close-pr-message: >
This PR was closed because it has been stalled for 10 days with no activity.
days-before-stale: 90
Expand All @@ -28,12 +28,13 @@ jobs:
exempt-pr-labels: 'dependencies,l10n'
stale-issue-label: 'stale'
stale-issue-message: >
This issue is stale because it has been open for 30 days with no activity.
Comment or remove the stale label, otherwise this will be closed in 5 days.
This issue is stale because it has been open for 90 days with no activity.
Comment or remove the stale label, otherwise this will be closed in 10 days.
stale-pr-label: 'stale'
stale-pr-message: >
This PR is stale because it has been open for 90 days with no activity.
Comment or remove the stale label, otherwise this will be closed in 10 days.
repo-token: ${{ secrets.GH_BOT_TOKEN }}

- name: Invalid Template
uses: actions/stale@v5
Expand All @@ -52,3 +53,4 @@ jobs:
stale-pr-label: 'invalid:template-incomplete'
stale-pr-message: >
Invalid PR template.
repo-token: ${{ secrets.GH_BOT_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
- name: Label Actions
uses: dessant/label-actions@v2
with:
github-token: ${{ github.token }}
github-token: ${{ secrets.GH_BOT_TOKEN }}
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [0.1.1] - 2022-08-20
### Changed
- Enable timeout callback for `/docs` command after 45s
- Incomplete `/docs` commands are deleted 30s after the timeout period
- `/docs` command is reset for each call
- Fix url returned for `/docs` command when `None` was selected as category
- Move constants to `discord_constants.py`
- Move avatar related items to `discord_avatar.py`
### Added
- Add `discord_modals.py`
### Dependencies
- Bump flask from 2.2.1 to 2.2.2
- Bump py-cord from 2.0.0 to 2.0.1


## [0.1.0] - 2022-08-07
### Changed
- Select Menus added to `docs` slash command to give finer control of returned documentation url
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ ENV GRAVATAR_EMAIL=$GRAVATAR_EMAIL
ENV IGDB_CLIENT_ID=$IGDB_CLIENT_ID
ENV IGDB_CLIENT_SECRET=$IGDB_CLIENT_SECRET

RUN mkdir /app
WORKDIR /app/

COPY requirements.txt .
COPY *.py .
RUN pip install --no-cache-dir -r requirements.txt
Expand Down
15 changes: 15 additions & 0 deletions discord_avatar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# standard imports
from io import BytesIO
import os

# lib imports
import requests

# local imports
from discord_helpers import get_bot_avatar

# avatar
avatar = get_bot_avatar(gravatar=os.environ['GRAVATAR_EMAIL'])

avatar_response = requests.get(url=avatar)
avatar_img = BytesIO(avatar_response.content).read()
65 changes: 50 additions & 15 deletions discord_bot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# standard imports
from datetime import datetime
from io import BytesIO
import json
import os
import random
Expand All @@ -13,30 +12,24 @@
import requests

# local imports
from discord_helpers import get_bot_avatar, igdb_authorization, month_dictionary
from discord_views import DocsCommandView, DonateCommandView
from discord_constants import org_name, bot_name, bot_url
from discord_helpers import igdb_authorization, month_dictionary
import keep_alive

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

if True: # hack for flake8
from discord_avatar import avatar, avatar_img
from discord_views import DocsCommandView, DonateCommandView, RefundCommandView

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

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

# avatar
avatar = get_bot_avatar(gravatar=os.environ['GRAVATAR_EMAIL'])

response = requests.get(url=avatar)
avatar_img = BytesIO(response.content).read()

# context reference
# https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context
# https://docs.pycord.dev/en/master/ext/commands/api.html#discord.ext.commands.Context
Expand Down Expand Up @@ -198,13 +191,55 @@ async def docs_command(ctx: discord.ApplicationContext,
user : discord.Commands.Option
Username to mention in response.
"""
embed = discord.Embed(title="Select a project", color=0xDC143C)
embed = discord.Embed(title="Select a project", color=0xF1C232)
embed.set_footer(text=bot_name, icon_url=avatar)

if user:
await ctx.respond(
f'{ctx.author.mention}, {user.mention}',
embed=embed,
ephemeral=False,
view=DocsCommandView(ctx=ctx)
)
else:
await ctx.respond(
f'{ctx.author.mention}',
embed=embed,
ephemeral=False,
view=DocsCommandView(ctx=ctx)
)


@bot.slash_command(name="refund",
description="Refund form for unhappy customers."
)
async def refund_command(ctx: discord.ApplicationContext,
user: Option(discord.Member,
description=user_mention_desc,
required=False)):
"""
The ``refund`` slash command.
Sends a discord embed, with a `Modal`, to the server and channel where the command was issued. This command is
pure satire.
Parameters
----------
ctx : discord.ApplicationContext
Request message context.
user : discord.Commands.Option
Username to mention in response.
"""
embed = discord.Embed(title="Refund request",
description="Original purchase price: $0.00\n\n"
"Select the button below to request a full refund!",
color=0xDC143C)
embed.set_footer(text=bot_name, icon_url=avatar)

if user:
await ctx.respond(f'{ctx.author.mention}, {user.mention}', embed=embed, view=DocsCommandView(ctx=ctx))
await ctx.respond(user.mention, embed=embed, view=RefundCommandView())
else:
await ctx.respond(f'{ctx.author.mention}', embed=embed, view=DocsCommandView(ctx=ctx))
await ctx.respond(embed=embed, view=RefundCommandView())


@tasks.loop(minutes=60.0)
Expand Down
3 changes: 3 additions & 0 deletions discord_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org_name = 'LizardByte'
bot_name = f'{org_name}-Bot'
bot_url = 'https://app.lizardbyte.dev'
21 changes: 21 additions & 0 deletions discord_modals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# lib imports
import discord


class RefundModal(discord.ui.Modal):
"""
Class representing `discord.ui.Modal` for ``refund`` slash command.
"""
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)

self.add_item(discord.ui.InputText(label="Name"))
self.add_item(discord.ui.InputText(label="Email"))
self.add_item(discord.ui.InputText(label="Purchase Date"))

async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(title="Refund request completed",
description="Your refund is being processed!")
embed.add_field(name="Original price", value="$0.00")
embed.add_field(name="Refund amount", value="$0.00")
await interaction.response.send_message(embeds=[embed])
Loading

0 comments on commit 0941b25

Please sign in to comment.