Skip to content

Commit

Permalink
Merge branch 'main' into tests/test-error-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
onerandomusername authored Apr 21, 2022
2 parents abce8a6 + 0c4e1c2 commit 09472f3
Show file tree
Hide file tree
Showing 15 changed files with 1,818 additions and 2 deletions.
9 changes: 8 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
### Breaking
- Bot now requires a `RELAY_CHANNEL_ID` configuration variable. (#53)
- This is where tickets with users will be relayed.
- At a later point in time, this will be additionally included in a configuration command.

### Added
- Threads system (#53)
- Messages can now be relayed between a user and a server.
- NOTE: There is not a database yet, so none of these messages are stored.
- Added Dispatcher system, although it is not hooked into important features like thread creation yet. (#71)
- Officially support python 3.10 (#119)
- Officially support windows and macos (#121)
Expand Down
5 changes: 4 additions & 1 deletion modmail/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from modmail.log import ModmailLogger
from modmail.utils.extensions import EXTENSIONS, NO_UNLOAD, walk_extensions
from modmail.utils.plugins import PLUGINS, walk_plugins
from modmail.utils.threads import Ticket


REQUIRED_INTENTS = Intents(
Expand All @@ -38,9 +39,11 @@ class ModmailBot(commands.Bot):
logger: ModmailLogger = logging.getLogger(__name__)
dispatcher: Dispatcher

_tickets: t.Dict[int, Ticket] = dict()

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

Expand Down
22 changes: 22 additions & 0 deletions modmail/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import types
import typing
from collections import defaultdict
from typing import Optional

import attr
import desert
Expand Down Expand Up @@ -383,6 +384,26 @@ class EmojiConfig:
)


@attr.mutable(slots=True)
class ThreadConfig:
"""Thread configuration."""

thread_mention_role_id: Optional[int] = attr.ib(
default=0,
metadata={
METADATA_TABLE: ConfigMetadata(
description="Role to mention on ticket creation.",
)
},
converter=int,
)
relay_channel_id: Optional[int] = attr.ib(
default=0,
metadata={METADATA_TABLE: ConfigMetadata(description="Channel to use for creating tickets.")},
converter=int,
)


@attr.s(auto_attribs=True, slots=True)
class BaseConfig:
"""
Expand All @@ -406,6 +427,7 @@ class BaseConfig:
},
)
emojis: EmojiConfig = EmojiConfig()
threads: ThreadConfig = ThreadConfig()


# build configuration
Expand Down
4 changes: 4 additions & 0 deletions modmail/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ production = true
[emojis]
failure = ":x:"
success = ":thumbsup:"

[threads]
relay_channel_id = 0
thread_mention_role_id = 0
3 changes: 3 additions & 0 deletions modmail/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ dev:
emojis:
failure: ':x:'
success: ':thumbsup:'
threads:
relay_channel_id: 0
thread_mention_role_id: 0
Loading

0 comments on commit 09472f3

Please sign in to comment.