Skip to content

Commit

Permalink
Merge pull request #126 from ajstewart/release-v1.1.1
Browse files Browse the repository at this point in the history
Release v1.1.1
  • Loading branch information
ajstewart authored May 27, 2023
2 parents 09ee38a + 42377b9 commit 1dd6305
Show file tree
Hide file tree
Showing 24 changed files with 2,893 additions and 2,590 deletions.
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: "README.md"
- id: end-of-file-fixer
- id: debug-statements

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: "v0.0.270"
hooks:
- id: ruff

- repo: https://github.com/python-poetry/poetry
rev: "1.5.0" # add version here
hooks:
- id: poetry-check

- repo: https://github.com/gitleaks/gitleaks
rev: v8.16.3
hooks:
- id: gitleaks
8 changes: 3 additions & 5 deletions alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""alembic env.py."""
from logging.config import fileConfig

from sqlalchemy import engine_from_config
from sqlalchemy import pool
from sqlalchemy import engine_from_config, pool

from alembic import context

Expand Down Expand Up @@ -64,9 +64,7 @@ def run_migrations_online() -> None:
)

with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata
)
context.configure(connection=connection, target_metadata=target_metadata)

with context.begin_transaction():
context.run_migrations()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
"""create guild_schedule_settings table
"""create guild_schedule_settings table.
Revision ID: 9b7158520f28
Revises: c897b93f45ce
Create Date: 2022-08-26 22:35:28.930715
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = '9b7158520f28'
down_revision = 'c897b93f45ce'
revision = "9b7158520f28"
down_revision = "c897b93f45ce"
branch_labels = None
depends_on = None


def upgrade() -> None:
"""Updgrade to 9b7158520f28 revision."""
op.create_table(
'guild_schedule_settings',
sa.Column('guild', sa.Integer, sa.ForeignKey("guilds.id"), nullable=False),
sa.Column('base_open_message', sa.String(length=60), nullable=False),
sa.Column('base_close_message', sa.String(length=60), nullable=False),
sa.Column('warning_time', sa.Integer, nullable=False),
sa.Column('inactive_time', sa.Integer, nullable=False),
sa.Column('delay_time', sa.Integer, nullable=False),
"guild_schedule_settings",
sa.Column("guild", sa.Integer, sa.ForeignKey("guilds.id"), nullable=False),
sa.Column("base_open_message", sa.String(length=60), nullable=False),
sa.Column("base_close_message", sa.String(length=60), nullable=False),
sa.Column("warning_time", sa.Integer, nullable=False),
sa.Column("inactive_time", sa.Integer, nullable=False),
sa.Column("delay_time", sa.Integer, nullable=False),
)


def downgrade() -> None:
op.drop_table('guild_schedule_settings')
"""Downgrade to c897b93f45ce revision."""
op.drop_table("guild_schedule_settings")
80 changes: 41 additions & 39 deletions alembic/versions/c897b93f45ce_initial_tables.py
Original file line number Diff line number Diff line change
@@ -1,66 +1,68 @@
"""Initial tables
"""Initial tables.
Revision ID: c897b93f45ce
Revises:
Create Date: 2022-06-04 20:11:35.416806
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = 'c897b93f45ce'
revision = "c897b93f45ce"
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
"""Upgrade to c897b93f45ce revision."""
op.create_table(
'guilds',
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('tz', sa.String(length=40), nullable=False),
sa.Column('admin_channel', sa.Integer, nullable=False),
sa.Column('meowth_raid_category', sa.Integer, nullable=False),
sa.Column('any_raids_filter', sa.Boolean, nullable=False),
sa.Column('log_channel', sa.Integer, nullable=False),
sa.Column('time_channel', sa.Integer, nullable=False),
sa.Column('join_name_filter', sa.Boolean, nullable=False),
sa.Column('active', sa.Boolean, nullable=False),
sa.Column('prefix', sa.String(length=3), nullable=False)
"guilds",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("tz", sa.String(length=40), nullable=False),
sa.Column("admin_channel", sa.Integer, nullable=False),
sa.Column("meowth_raid_category", sa.Integer, nullable=False),
sa.Column("any_raids_filter", sa.Boolean, nullable=False),
sa.Column("log_channel", sa.Integer, nullable=False),
sa.Column("time_channel", sa.Integer, nullable=False),
sa.Column("join_name_filter", sa.Boolean, nullable=False),
sa.Column("active", sa.Boolean, nullable=False),
sa.Column("prefix", sa.String(length=3), nullable=False),
)

op.create_table(
'schedules',
sa.Column('guild', sa.Integer, sa.ForeignKey("guilds.id"), nullable=False),
sa.Column('channel', sa.Integer, nullable=False),
sa.Column('role', sa.Integer, nullable=False),
sa.Column('channel_name', sa.String(length=40), nullable=False),
sa.Column('role_name', sa.String(length=30), nullable=False),
sa.Column('open', sa.String(length=5), nullable=False),
sa.Column('close', sa.String(length=5), nullable=False),
sa.Column('open_message', sa.String(length=255), nullable=False),
sa.Column('close_message', sa.String(length=255), nullable=False),
sa.Column('warning', sa.Boolean, nullable=False),
sa.Column('dynamic', sa.Boolean, nullable=False),
sa.Column('dynamic_close', sa.String(length=5), nullable=False),
sa.Column('max_num_delays', sa.Integer, nullable=False),
sa.Column('current_delay_num', sa.Integer, nullable=False),
sa.Column('silent', sa.Boolean, nullable=False),
sa.Column('active', sa.Boolean, nullable=False)
"schedules",
sa.Column("guild", sa.Integer, sa.ForeignKey("guilds.id"), nullable=False),
sa.Column("channel", sa.Integer, nullable=False),
sa.Column("role", sa.Integer, nullable=False),
sa.Column("channel_name", sa.String(length=40), nullable=False),
sa.Column("role_name", sa.String(length=30), nullable=False),
sa.Column("open", sa.String(length=5), nullable=False),
sa.Column("close", sa.String(length=5), nullable=False),
sa.Column("open_message", sa.String(length=255), nullable=False),
sa.Column("close_message", sa.String(length=255), nullable=False),
sa.Column("warning", sa.Boolean, nullable=False),
sa.Column("dynamic", sa.Boolean, nullable=False),
sa.Column("dynamic_close", sa.String(length=5), nullable=False),
sa.Column("max_num_delays", sa.Integer, nullable=False),
sa.Column("current_delay_num", sa.Integer, nullable=False),
sa.Column("silent", sa.Boolean, nullable=False),
sa.Column("active", sa.Boolean, nullable=False),
)

op.create_table(
'fc_channels',
sa.Column('guild', sa.Integer, sa.ForeignKey("guilds.id"), nullable=False),
sa.Column('channel', sa.Integer, nullable=False),
sa.Column('channel_name', sa.String(length=40), nullable=False),
sa.Column('secret', sa.Boolean, nullable=False)
"fc_channels",
sa.Column("guild", sa.Integer, sa.ForeignKey("guilds.id"), nullable=False),
sa.Column("channel", sa.Integer, nullable=False),
sa.Column("channel_name", sa.String(length=40), nullable=False),
sa.Column("secret", sa.Boolean, nullable=False),
)


def downgrade():
op.drop_table('fc_channels')
op.drop_table('schedules')
op.drop_table('guilds')
"""Downgrade to c897b93f45ce revision."""
op.drop_table("fc_channels")
op.drop_table("schedules")
op.drop_table("guilds")
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
"""add last message id to close and open
"""add last message id to close and open.
Revision ID: f8574e25d62d
Revises: 9b7158520f28
Create Date: 2022-09-25 16:52:26.857550
"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = 'f8574e25d62d'
down_revision = '9b7158520f28'
revision = "f8574e25d62d"
down_revision = "9b7158520f28"
branch_labels = None
depends_on = None


def upgrade() -> None:
"""Upgrade to f8574e25d62d revision."""
with op.batch_alter_table("schedules") as batch_op:
batch_op.add_column(sa.Column('last_open_message', sa.Integer))
batch_op.add_column(sa.Column('last_close_message', sa.Integer))
batch_op.add_column(sa.Column("last_open_message", sa.Integer))
batch_op.add_column(sa.Column("last_close_message", sa.Integer))


def downgrade() -> None:
"""Downgrade to 9b7158520f28 revision."""
with op.batch_alter_table("schedules") as batch_op:
batch_op.drop_column('last_open_message')
batch_op.drop_column('last_close_message')
batch_op.drop_column("last_open_message")
batch_op.drop_column("last_close_message")
51 changes: 26 additions & 25 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,69 @@
#!/usr/bin/env python
"""Main bot file."""
import os

import discord
import os

from dotenv import load_dotenv
from discord.ext import commands
from dotenv import load_dotenv

from cogs.utils.checks import check_admin
from cogs.utils.utils import get_logger, get_prefix


__version__ = '1.1.0'
DOCS_URL = 'placeholder'
__version__ = "1.1.1"
DOCS_URL = "placeholder"


class MyBot(commands.Bot):
"""Bot class.
"""
"""Bot class."""

def __init__(self, command_prefix, intents, version, test_guild=None):
super().__init__(
command_prefix=command_prefix,
intents=intents
)
"""Initialise the bot."""
super().__init__(command_prefix=command_prefix, intents=intents)
self.initial_extensions = [
'cogs.initial',
'cogs.admin',
'cogs.any_raids_filter',
'cogs.fc_filter',
'cogs.join_name_filter',
'cogs.misc',
'cogs.time_channel',
'cogs.schedules',
"cogs.initial",
"cogs.admin",
"cogs.any_raids_filter",
"cogs.fc_filter",
"cogs.join_name_filter",
"cogs.misc",
"cogs.time_channel",
"cogs.schedules",
]
self.help_command.add_check(check_admin)
self.my_version = version
self.test_guild = test_guild
self.docs = DOCS_URL

async def setup_hook(self):
"""Load the initial extensions."""
for ext in self.initial_extensions:
await self.load_extension(ext)

async def on_ready(self):
logger.info('Bot is ready!')
"""Print a message to the console when the bot is ready."""
logger.info("Bot is ready!")


# LOADS THE .ENV FILE THAT RESIDES ON THE SAME LEVEL AS THE SCRIPT.
load_dotenv()

# GRAB THE API TOKEN FROM THE .ENV FILE.
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
# Set the TEST_GUILD ID
try:
TEST_GUILD = int(os.getenv('TEST_GUILD'))
TEST_GUILD = int(os.getenv("TEST_GUILD"))
if len(str(TEST_GUILD)) < 17:
raise ValueError(f"{TEST_GUILD} is not a valid guild ID!")
except Exception as e:
except Exception:
TEST_GUILD = None

intents = discord.Intents.default()
intents.members = True
intents.message_content = True

logger = get_logger(logfile='snorlax.log')
logger.info('Starting bot...')
logger = get_logger(logfile="snorlax.log")
logger.info("Starting bot...")

bot = MyBot((get_prefix), intents, __version__, test_guild=TEST_GUILD)
bot.run(DISCORD_TOKEN, log_handler=None)
Loading

0 comments on commit 1dd6305

Please sign in to comment.