Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/custom-changelogger
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivansh-007 committed Nov 3, 2021
2 parents 384ea89 + 9b5dac9 commit b164477
Show file tree
Hide file tree
Showing 28 changed files with 3,281 additions and 490 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2

updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
time: "07:00"
open-pull-requests-limit: 10
commit-message:
prefix: "chore(deps): "
50 changes: 50 additions & 0 deletions .github/workflows/update_requirements_dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Update `requirements.txt`

on:
pull_request:

permissions:
pull-requests: write
issues: write
repository-projects: write

jobs:
regenerate-requirements:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
# Checks out the repository in the current folder.
- name: Checkout repository
uses: actions/checkout@v2

# Set up the right version of Python
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

# Install the required dependencies for using the feature, we aren't using cache here
# as the number is relatively small and having cache would be complete redundancy.
- name: Install dependencies using pip
run: |
pip install tomli
# Run the script for regenerating requirements.txt so that the dependancies
# updated by dependabot are reflected in `requirements.txt`
- name: Regenerate `requirements.txt` if opened PR is made by dependabot
run: |
python -m scripts.export_requirements
- name: Commit Changes
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit --amend --no-edit
git push --force origin ${GITHUB_REF##*/}
- name: Add a label
run: 'gh pr edit "$PR_URL" --add-label "a: dependencies,skip changelog"'
env:
PR_URL: ${{github.event.pull_request.html_url}}
5 changes: 4 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added Dispatcher system, although it is not hooked into important features like thread creation yet. (#71)

### Changed

- Embedified the meta commands so they have a nicer UI (#78)


## [0.2.0] - 2021-09-29

### Added
Expand Down
19 changes: 12 additions & 7 deletions modmail/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from discord.ext import commands

from modmail.config import CONFIG
from modmail.dispatcher import Dispatcher
from modmail.log import ModmailLogger
from modmail.utils.extensions import EXTENSIONS, NO_UNLOAD, walk_extensions
from modmail.utils.plugins import PLUGINS, walk_plugins
Expand All @@ -35,11 +36,13 @@ class ModmailBot(commands.Bot):
"""

logger: ModmailLogger = logging.getLogger(__name__)
dispatcher: Dispatcher

def __init__(self, **kwargs):
self.config = CONFIG
self.start_time: t.Optional[arrow.Arrow] = None # arrow.utcnow()
self.http_session: t.Optional[ClientSession] = None
self.dispatcher = Dispatcher()

status = discord.Status.online
activity = Activity(type=discord.ActivityType.listening, name="users dming me!")
Expand All @@ -49,14 +52,16 @@ def __init__(self, **kwargs):
# allow only user mentions by default.
# ! NOTE: This may change in the future to allow roles as well
allowed_mentions = AllowedMentions(everyone=False, users=True, roles=False, replied_user=True)
# override passed kwargs if they are None
kwargs["case_insensitive"] = kwargs.get("case_insensitive", True)
# do not let the description be overridden.
kwargs["description"] = "Modmail bot by discord-modmail."
kwargs["status"] = kwargs.get("status", status)
kwargs["activity"] = kwargs.get("activity", activity)
kwargs["allowed_mentions"] = kwargs.get("allowed_mentions", allowed_mentions)
kwargs["command_prefix"] = kwargs.get("command_prefix", prefix)
kwargs["intents"] = kwargs.get("intents", REQUIRED_INTENTS)
super().__init__(
case_insensitive=True,
description="Modmail bot by discord-modmail.",
status=status,
activity=activity,
allowed_mentions=allowed_mentions,
command_prefix=prefix,
intents=REQUIRED_INTENTS,
**kwargs,
)

Expand Down
Loading

0 comments on commit b164477

Please sign in to comment.