Skip to content

[MAJOR] - Zorak V2.0 - Alpha #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 38 commits into
base: Development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2c30533
- saving work for now
Xarlos89 Apr 1, 2024
7b31066
Applied guild settings to Logging files
Xarlos89 Apr 4, 2024
c030957
Oopsie in guild_settings.py
Xarlos89 Apr 5, 2024
dfb3642
Set up Automoderation to be guild-specific, not only in moderation, b…
Xarlos89 Apr 5, 2024
efe67e7
checking for a staff role is unnecessary when we check for ban_member…
Xarlos89 Apr 5, 2024
97ac632
checking for a staff role is unnecessary when we check for manage_mes…
Xarlos89 Apr 5, 2024
e40acd0
checking for a staff role is unnecessary when we check for kick_membe…
Xarlos89 Apr 5, 2024
a3835dd
checking for a staff role is unnecessary when we check for moderate_m…
Xarlos89 Apr 5, 2024
4677e42
checking for a staff role is unnecessary when we check for moderate_m…
Xarlos89 Apr 5, 2024
01262b3
Dont know how I feel about this. Might be better to send all logs dir…
Xarlos89 Apr 5, 2024
d84be89
Added server settings to make this a multi-guild thing
Xarlos89 Apr 5, 2024
f575b62
Added server settings to make this a multi-guild thing
Xarlos89 Apr 5, 2024
7504e18
Added settings to verification, however only for the button message s…
Xarlos89 Apr 5, 2024
be0916e
Added settings to points cog
Xarlos89 Apr 5, 2024
aa29be9
fix small bug in moderation_invites.py with the message types being p…
Xarlos89 Apr 5, 2024
b0ceb34
Added guild settings to tickets
Xarlos89 Apr 5, 2024
0ea3067
Little oopsie passing the guild ID
Xarlos89 Apr 5, 2024
a3f981d
Bug with bot messages being passed
Xarlos89 Apr 5, 2024
0763918
Name change logging fix
Xarlos89 Apr 5, 2024
c2dd439
Issue with bot user triggering invite spam
Xarlos89 Apr 5, 2024
a6b40bb
Forgot the welcome message.
Xarlos89 Apr 5, 2024
b64fcb5
Turn DB back on
Xarlos89 Apr 5, 2024
3dbc6ad
Start working in mongo.py
Xarlos89 Apr 5, 2024
aca5c4b
[MAJOR] - Update to mongo.py, added GuildSettings collection
Xarlos89 Apr 6, 2024
87150a8
[MAJOR] - Update command to update settings. Doesn't feel like final …
Xarlos89 Apr 6, 2024
6949232
minor fix in update_settings.py
Xarlos89 Apr 6, 2024
f0aba97
housecleaning mongo.py
Xarlos89 Apr 6, 2024
9990efe
Update global usage of Settings Toml to Database
Xarlos89 Apr 6, 2024
2e1ca16
.gitignore update
Xarlos89 Apr 6, 2024
6c4aec6
Moving this out of the way
Xarlos89 Apr 6, 2024
172f8f8
This too
Xarlos89 Apr 6, 2024
32f39b2
- Allows us to update MongoDB Guild settings for the current guild. W…
Xarlos89 Apr 7, 2024
47d4a55
- Need to encode things as a Long. not a String
Xarlos89 Apr 7, 2024
3c2b6e3
- Entrypoint for Zorak setup
Xarlos89 Apr 7, 2024
24b669c
Start removal of reaction_roles.toml
Xarlos89 Apr 9, 2024
36dd7c3
Add ReactionRoles handler to mongo.py
Xarlos89 Apr 9, 2024
991339d
Remove toml links in settings
Xarlos89 Apr 9, 2024
b629d50
START working on command
Xarlos89 Apr 9, 2024
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,6 @@ data/
# ignore db data
db/*
/deploy
.env
.env
/Pipfile
/Pipfile.lock
169 changes: 0 additions & 169 deletions Resources/ServerConfig/Zorak-Dev/reaction_roles.toml

This file was deleted.

73 changes: 73 additions & 0 deletions Resources/ServerConfig/dev/FAKE_DB_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"1031644670436061324": {
"info": {
"id": 1031644670436061324,
"name": "Practical Python",
"website": "https://practical-python-org.github.io/Home/",
"email": "[email protected]",
"review": "https://disboard.org/review/create/900302240559018015",
"invite": "https://discord.gg/vgZmgNwuHw",
"logo": "https://raw.githubusercontent.com/Xarlos89/PracticalPython/main/logo.png"
},
"channels": {
"verification": {
"verification_channel": 1055126587512721439
},
"quarantine": {
"quarantine_channel": 1055126882691076177
},
"support": {
"server_support": 1068103243734994964
},
"general": {
"role_channel": 1062268986726813758,
"rules_channel": 1062269049121275914,
"general_channel": 1031644670436061327,
"resources_channel": 1062300735338983485,
"python_help_1": 1062302503351365632,
"python_help_2": 12345,
"challenges_channel": 1045104938071633994,
"news_channel": 1071095960538718261,
"suggestions_channel": 117939062999902620
},
"logging": {
"chat_log": 1043607758685089932,
"join_log": 1043967844934762556,
"mod_log": 1055124663526752297,
"server_change_log": 1062269270047862884,
"user_log": 1044331443884654692,
"verification_log": 1043621605940674580,
"zorak_log": 1062754277543645324
}
},
"roles": {
"admin": {
"owner": 1054762426614157354,
"admin": 1134861924882989097,
"staff": 1031903615310385232,
"staff_networking": 1134861783358775367,
"bot": 1054763353538576437
},
"reaction": {
"beginner": 1064259543250522112,
"intermediate": 1064259555497877534,
"professional": 1064259557049761863,
"north_america": 1064259558819770379,
"europe": 1064259561302794361,
"asia": 1064259687924637768,
"africa": 1064259690948722708,
"south_america": 1064259693545013288,
"oceana": 1064259760674840666,
"open_to_work": 1114611004182102218,
"employer": 1114611092677722113
},
"punishment": {
"naughty": 1062270109839790110
},
"verified": {
"verified": 1173219859878924298
}
}
}
}

File renamed without changes.
Empty file added src/__init__.py
Empty file.
Empty file added src/zorak/_ARCHIVE/__init__.py
Empty file.
32 changes: 19 additions & 13 deletions src/zorak/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
- [email protected]
"""
import logging
from datetime import datetime
import os

import discord
from discord.ext import commands

from zorak.utilities.core.args_utils import parse_args
from zorak.utilities.core.logging_utils import setup_logger
from zorak.utilities.core.logging_options import setup_logger
from zorak.utilities.core.mongo import initialise_bot_db
from zorak.utilities.core.server_settings import Settings
from zorak.utilities.core.settings import Settings

logger = logging.getLogger(__name__)

COGS_ROOT_PATH = os.path.join(os.path.dirname(__file__), "cogs")
logger.debug(f"COG_PATH: {COGS_ROOT_PATH}")
logger = logging.getLogger(__name__)

server_settings_path = None

Expand All @@ -28,7 +27,9 @@ def load_cogs(bot):
Loads the directories under the /cogs/ folder,
then digs through those directories and loads the cogs.
"""
COGS_ROOT_PATH = os.path.join(os.path.dirname(__file__), "cogs")
logger.info("Loading Cogs...")
logger.info(f"Loading from {COGS_ROOT_PATH}")
failed_to_load = []
for directory in os.listdir(COGS_ROOT_PATH):
if directory.startswith("_"):
Expand Down Expand Up @@ -60,29 +61,34 @@ def init_bot(token, bot):
try:
load_cogs(bot)
bot.run(token)

except TypeError as e:
print(e)



def main():
args = parse_args()

bot = commands.Bot(command_prefix="/", intents=discord.Intents.all())
bot.remove_command("help")


# Set up global logging across the bot.
setup_logger(
level=args.log_level if args.log_level else int(os.getenv("LOGGING_LEVEL", 20)),
stream_logs=args.console_log if args.console_log != None else bool(os.getenv("STREAM_LOGS", False)),
)

bot = commands.Bot(command_prefix="/", intents=discord.Intents.all())
bot.remove_command("help")

if not args.drop_db:
logger.info("Initialising Database...")
initialise_bot_db(bot)

server_settings_path = args.server_settings_path if args.server_settings_path else os.environ.get("SERVER_SETTINGS")
if server_settings_path:
logger.info(f"Loading server settings from {server_settings_path}")
bot.server_settings = Settings(server_settings_path) # type: ignore
settings_path = args.server_settings_path if args.server_settings_path else os.environ.get(
"SERVER_SETTINGS")

if settings_path:
logger.info(f"Loading all server settings from {settings_path}")
bot.settings = Settings(settings_path, bot.guilds) # type: ignore

if args.discord_token:
init_bot(args.discord_token, bot)
Expand Down
20 changes: 13 additions & 7 deletions src/zorak/cogs/admin/admin_automod_spam_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ async def on_message(self, message):
if isinstance(message.channel, discord.DMChannel):
return

settings = self.bot.db_client.get_guild_settings(message.guild)

# new speaker. Welcome to auto mod.
if message.author.id not in self.records:
self.records[message.author.id] = {
if message.guild.id not in self.records:
self.records[message.guild.id] = {}

guild_record = self.records[message.guild.id]

if message.author.id not in guild_record:
guild_record[message.author.id] = {
"last_message": message.content
, "occurrence": 1
, "1st": {"message_id": message.id, "channel_id": message.channel.id}
Expand All @@ -52,7 +59,7 @@ async def on_message(self, message):
# Old speaker. We are watching you...
else:
# Check if the last message is the same as the new one.
the_archive = self.records[message.author.id]
the_archive = guild_record[message.author.id]

if the_archive["last_message"] == message.content:
# If so, increase the occurance by 1
Expand Down Expand Up @@ -93,10 +100,9 @@ async def on_message(self, message):
# timeout right away
await message.author.timeout(until=datetime.utcnow() + timedelta(seconds=30))

naughty = message.author.guild.get_role(self.bot.server_settings.user_roles["bad"]["naughty"])
verified = message.author.guild.get_role(self.bot.server_settings.verified_role['verified'])
quarantine = await self.bot.fetch_channel(
self.bot.server_settings.channels["moderation"]["quarantine_channel"])
naughty = message.author.guild.get_role(settings["naughty_role"])
verified = message.author.guild.get_role(settings["verified_role"])
quarantine = await self.bot.fetch_channel(settings["quarantine_channel"])

# assign Naughty roll
member = message.author
Expand Down
5 changes: 3 additions & 2 deletions src/zorak/cogs/admin/admin_ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def __init__(self, bot):

@commands.slash_command(description="Ban a user.")
@commands.has_permissions(ban_members=True)
@commands.has_role("Staff")
async def ban_member(self, ctx, target: discord.Member, reason):
"""
Take in a user mention, and a string reason.
Expand All @@ -42,7 +41,9 @@ async def ban_member(self, ctx, target: discord.Member, reason):
await target.ban(reason=f"{ctx.author.name} - {reason}")
logger.info("{%s} banned {%s}. Reason: {%s}", ctx.author.name, target.name, reason)
# Then we publicly announce what happened.
await ctx.respond(embed=embed_cant_do_that(f"**{ctx.author.name}** banned **{target.name}**" f"\n**Reason:** {reason}"))
await ctx.respond(
embed=embed_cant_do_that(f"**{ctx.author.name}** banned **{target.name}**" f"\n"
f"**Reason:** {reason}"))

else:
await ctx.respond(embed=embed_cant_do_that("You can't ban an Admin."), ephemeral=True)
Expand Down
Loading