Skip to content

Commit

Permalink
Merge pull request #47 from hhollenstain/slash-commands
Browse files Browse the repository at this point in the history
Slash commands
  • Loading branch information
hhollenstain authored Sep 14, 2022
2 parents 93f3ecd + 847224f commit 3b70fb0
Show file tree
Hide file tree
Showing 12 changed files with 822 additions and 509 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM python:3.6-alpine
FROM python:3.10-alpine

RUN apk add gcc g++ musl-dev libffi-dev libxml2-dev libxslt-dev git make postgresql-dev

COPY . /app
WORKDIR /app

RUN apk add gcc musl-dev libffi-dev libxml2-dev libxslt-dev git make postgresql-dev
RUN make live

CMD ["autochannel"]
6 changes: 1 addition & 5 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ name = "pypi"
"pep8" = "*"

[packages]
e1839a8 = {path = ".", editable = true}
tamago = {path = ".",editable = true}
fakah = {path = ".",editable = true}
autochannel = {editable = true, path = "."}
"discord.py" = {git = "https://github.com/Rapptz/discord.py", ref = "master"}

[requires]
python_version = "3.6.8"
python_version = "3.10.0"
878 changes: 595 additions & 283 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion autochannel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
init - version info
"""
VERSION_INFO = (8, 0, 0)
VERSION_INFO = (9, 1, 3)
VERSION = '.'.join(str(c) for c in VERSION_INFO)
23 changes: 20 additions & 3 deletions autochannel/autochannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import aiohttp
import json
from discord.ext.commands import Bot
"""monitor"""

"""data"""
from autochannel.data.database import DB
Expand All @@ -19,7 +18,7 @@ class AutoChannel(discord.ext.commands.Bot):
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args,initial_extensions: list[str], **kwargs):
super().__init__(*args, **kwargs)
db = DB()
self.session = db.session()
Expand All @@ -30,4 +29,22 @@ def __init__(self, *args, **kwargs):
self.env = kwargs.get('env') or 'dev'
self.dbl_token = kwargs.get('dbl_token')
self.stats = None
self.voice_channel_prefix = kwargs.get('voice_channel_prefix')
self.voice_channel_prefix = kwargs.get('voice_channel_prefix')
self.initial_extensions = initial_extensions
self.testing_guild_id = kwargs.get('testing_guild_id') or None

async def setup_hook(self) -> None:
"""_summary_
"""
for extension in self.initial_extensions:
await self.load_extension(extension)

if self.testing_guild_id:
guild = discord.Object(self.testing_guild_id)
# We'll copy in the global commands to test with:
self.tree.copy_global_to(guild=guild)
# followed by syncing to the testing guild.
await self.tree.sync(guild=guild)
log.info(f'Commands successfully updated to GUILD: {guild.id}')
else:
await self.tree.sync()
38 changes: 26 additions & 12 deletions autochannel/autochannel_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"""metrics"""
from prometheus_client import start_http_server
"""AC Imports"""
from autochannel.lib import plugin, utils
from autochannel.lib import utils
from autochannel.autochannel import AutoChannel
from autochannel.data.models import Guild, Category

EXTENSIONS = [
'autochannels',
'ac_dbl',
'help',
'server',
'autochannel.lib.plugins.autochannels',
# 'autochannel.lib.plugins.ac_dbl', broken requires some fixes
'autochannel.lib.plugins.join',
'autochannel.lib.plugins.server',
]

LOG = logging.getLogger(__name__)
Expand All @@ -38,9 +38,15 @@
VOICE_CHANNEL_PREFIX = os.getenv('VOICE_CHANNEL_PREFIX') or '!VC '
AUTO_CHANNEL_PREFIX = os.getenv('AUTO_CHANNEL_PREFIX') or '!AC '
AUTO_CATEGORIES = os.getenv('AUTO_CATEGORIES').lower().split(",") or ['auto-voice']
TESTING_GUILD_ID = os.getenv('TESTING_GUILD_ID')
ENV = os.getenv('ENV') or None

def main():
"""_summary_
"""
asyncio.run(runAC())

async def runAC():
"""Entrypoint if called as an executable."""
args = utils.parse_arguments()
logging.basicConfig(level=logging.INFO)
Expand All @@ -60,15 +66,23 @@ def main():
LOG.info("LONG LIVE AutoChannel bot")
intents = discord.Intents.default()
LOG.info(f'Intents: {intents}')
autochannel = AutoChannel(shard_id=int(SHARD), shard_count=int(SHARD_COUNT),
command_prefix=BOT_PREFIX, app_id=APP_ID, voice_channel_prefix=VOICE_CHANNEL_PREFIX,
auto_channel_prefix=AUTO_CHANNEL_PREFIX, auto_categories=AUTO_CATEGORIES,
env=ENV, dbl_token=DBL_TOKEN, intents=intents)
autochannel = AutoChannel(
shard_id=int(SHARD),
shard_count=int(SHARD_COUNT),
command_prefix=BOT_PREFIX,
app_id=APP_ID,
voice_channel_prefix=VOICE_CHANNEL_PREFIX,
auto_channel_prefix=AUTO_CHANNEL_PREFIX,
auto_categories=AUTO_CATEGORIES,
env=ENV,
dbl_token=DBL_TOKEN,
intents=intents,
initial_extensions=EXTENSIONS,
testing_guild_id=TESTING_GUILD_ID,
)

for extension in EXTENSIONS:
plugin.load('autochannel.lib.plugins.{}'.format(extension), autochannel)
start_http_server(8000)
autochannel.run(TOKEN)
await autochannel.start(TOKEN)



Expand Down
22 changes: 0 additions & 22 deletions autochannel/lib/plugin.py

This file was deleted.

Loading

0 comments on commit 3b70fb0

Please sign in to comment.