Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions koala/cogs/react_for_role/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Own modules
import koalabot
from koala.colours import KOALA_GREEN
from koala.utils import wait_for_message
from koala.utils import wait_for_message, is_int
from koala.db import insert_extension
from .db import ReactForRoleDBManager
from .log import logger
Expand Down Expand Up @@ -783,7 +783,12 @@ async def get_rfr_message_from_prompts(self, ctx: commands.Context) -> Tuple[dis
if not channel:
raise commands.CommandError("Invalid channel given.")
msg_id_raw = await self.prompt_for_input(ctx, "react for role message ID")
msg_id = None if (msg_id_raw == "") else int(msg_id_raw)
if (msg_id_raw == ""):
msg_id = None
elif not is_int(msg_id_raw):
msg_id = None
else:
msg_id = int(msg_id_raw)
if not msg_id:
raise commands.CommandError("Invalid Message ID given.")
msg = await channel.fetch_message(msg_id)
Expand Down
5 changes: 4 additions & 1 deletion koala/cogs/verification/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ async def verify(self, ctx, email):
session.add(NonVerifiedEmails(u_id=ctx.author.id, email=email, token=verification_code))
session.commit()

self.send_email(email, verification_code)
try:
self.send_email(email, verification_code)
except smtplib.SMTPRecipentsRefused:
raise Exception("KoalaBot was unable to send an email to the given address.")
await ctx.send("Please verify yourself using the command you have been emailed")

@commands.check(koalabot.is_dm_channel)
Expand Down
44 changes: 22 additions & 22 deletions koala/env.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import os
from dotenv import load_dotenv
load_dotenv()
BOT_TOKEN = os.environ['DISCORD_TOKEN']
BOT_OWNER_ENV = os.environ.get('BOT_OWNER')
BOT_OWNER_STR = BOT_OWNER_ENV.split(',')
BOT_OWNER = [int(item) for item in BOT_OWNER_STR]
API_PORT = os.environ.get("API_PORT", 8080)
DB_KEY = os.environ.get('SQLITE_KEY', "2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99")
ENCRYPTED_DB = (not os.name == 'nt') and eval(os.environ.get('ENCRYPTED', "True"))
CONFIG_PATH = os.environ.get("CONFIG_PATH")
if not CONFIG_PATH:
CONFIG_PATH = "/config"
if os.name == 'nt':
CONFIG_PATH = '.'+CONFIG_PATH
LOGGING_FILE = eval(os.environ.get("LOGGING_FILE", "True"))
import os
from dotenv import load_dotenv

load_dotenv()

BOT_TOKEN = os.environ['DISCORD_TOKEN']
BOT_OWNER_ENV = os.environ.get('BOT_OWNER')
BOT_OWNER_STR = BOT_OWNER_ENV.split(',')
BOT_OWNER = [int(item) for item in BOT_OWNER_STR]

API_PORT = os.environ.get("API_PORT", 8080)

DB_KEY = os.environ.get('SQLITE_KEY', "2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99")
ENCRYPTED_DB = (not os.name == 'nt') and eval(os.environ.get('ENCRYPTED', "True"))

CONFIG_PATH = os.environ.get("CONFIG_PATH")
if not CONFIG_PATH:
CONFIG_PATH = "/config"
if os.name == 'nt':
CONFIG_PATH = '.'+CONFIG_PATH

LOGGING_FILE = eval(os.environ.get("LOGGING_FILE", "True"))
4 changes: 4 additions & 0 deletions tests/test_koalabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def test_not_admin_is_admin(test_ctx):
assert not koalabot.is_admin(test_ctx)
koalabot.is_dpytest = True

@pytest.mark.asyncio
async def test_command_not_found():
with pytest.raises(discord.ext.commands.errors.CommandNotFound):
await dpytest.message(koalabot.COMMAND_PREFIX + 'fakecommand')

@mock.patch("koalabot.COGS_PACKAGE", "tests.tests_utils.fake_load_all_cogs")
@mock.patch("koalabot.ENABLED_COGS", ['greetings_cog'])
Expand Down