Skip to content
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

3.8.0: Filters, Room settings and more #189

Draft
wants to merge 90 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
2fe3c4d
greatly simplify bridging logic
greeeen-dev Nov 24, 2024
fdd0f1b
use user install if set
greeeen-dev Nov 24, 2024
faf0a71
use gcm mode instead of cbc
greeeen-dev Nov 24, 2024
0105b8c
remove secrets folder
greeeen-dev Nov 24, 2024
423e184
encapsulate tokenstore
greeeen-dev Nov 24, 2024
7655074
make installer use gcm
greeeen-dev Nov 24, 2024
763d2c1
cbc to gcm converter
greeeen-dev Nov 24, 2024
68260e2
version bump
greeeen-dev Nov 24, 2024
11c0fc9
logging
greeeen-dev Nov 24, 2024
821bc0f
finish cbc to gcm
greeeen-dev Nov 24, 2024
fdf1f94
add 3.8.0 support
greeeen-dev Nov 24, 2024
18a4b62
bugfix
greeeen-dev Nov 24, 2024
23f43f1
we don't use these by default
greeeen-dev Nov 24, 2024
4105a0c
update desc
greeeen-dev Nov 24, 2024
ad24df9
add class desc
greeeen-dev Nov 24, 2024
501fefb
filters (wip)
greeeen-dev Nov 24, 2024
9cd0569
simplify some logic
greeeen-dev Nov 24, 2024
96d9580
whoops
greeeen-dev Nov 24, 2024
a7b9bd7
remove unused methods
greeeen-dev Nov 24, 2024
088da64
add comment
greeeen-dev Nov 24, 2024
811d1db
wip filters config
greeeen-dev Nov 25, 2024
7e9493c
remove 3.11 and below
greeeen-dev Nov 25, 2024
bbd519e
application command support and some customizations
greeeen-dev Nov 28, 2024
710ad87
why did i use reference
greeeen-dev Nov 28, 2024
ec06fcc
use @
greeeen-dev Nov 28, 2024
116a196
implement filters management
greeeen-dev Nov 29, 2024
742037e
fix workflows (fuck windows)
greeeen-dev Nov 29, 2024
ce6da84
run discover instead of sync
greeeen-dev Nov 29, 2024
059964a
wip support for global filters
greeeen-dev Nov 29, 2024
65f82cf
use both global and room filters
greeeen-dev Nov 29, 2024
9d8bc1b
Merge branch 'main' into dev
greeeen-dev Nov 29, 2024
c3e6b3c
i hate autocomplete
greeeen-dev Nov 29, 2024
3d88fea
finished filters v1
greeeen-dev Nov 30, 2024
1ea7466
fix config editing
greeeen-dev Nov 30, 2024
5b8b8f2
performance optimizations + agegate update
greeeen-dev Nov 30, 2024
7796449
change limits display
greeeen-dev Nov 30, 2024
842bb1e
add method for nsfw indicator
greeeen-dev Nov 30, 2024
4ee7e76
start from newest thread
greeeen-dev Nov 30, 2024
37a70e0
performance improvements w/ thread starter
greeeen-dev Nov 30, 2024
de270bc
undo optimization
greeeen-dev Nov 30, 2024
64262bb
nvm, i released from the wrong branch
greeeen-dev Nov 30, 2024
575b4ce
copy filters
greeeen-dev Nov 30, 2024
18de9cc
make faster multicore experimental
greeeen-dev Dec 1, 2024
4e01ce9
add warning for unstable branches
greeeen-dev Dec 1, 2024
e6a00cd
optimize aiohttp json
greeeen-dev Dec 4, 2024
343f4b6
experimental aiohttp optimization
greeeen-dev Dec 4, 2024
9175164
undo experimental optimization
greeeen-dev Dec 4, 2024
0ae3577
use zstd instead of lzma for backups
greeeen-dev Dec 6, 2024
bf55403
add better comments
greeeen-dev Dec 6, 2024
65402bf
max is apparently 22
greeeen-dev Dec 6, 2024
bcb849f
min is apparently -7
greeeen-dev Dec 6, 2024
6aaf3ab
encrypted backups (wip)
greeeen-dev Dec 6, 2024
3bc7e2f
add encryption option
greeeen-dev Dec 6, 2024
7a17a53
fix data saving
greeeen-dev Dec 6, 2024
4a2e1cf
fix data loading
greeeen-dev Dec 6, 2024
745eece
clone data dict for saving
greeeen-dev Dec 6, 2024
b7f7974
fix data backup
greeeen-dev Dec 6, 2024
df93ffd
why is this here
greeeen-dev Dec 6, 2024
5783a13
github release workflow
greeeen-dev Dec 11, 2024
0edc359
version bump
greeeen-dev Dec 11, 2024
609bc98
use correct branch
greeeen-dev Dec 11, 2024
eed3cd1
we don't need an environment here
greeeen-dev Dec 11, 2024
44781af
nvm we need our environment here
greeeen-dev Dec 11, 2024
1b6b430
add workflow call
greeeen-dev Dec 11, 2024
b15f5d0
Merge branch 'main' into dev
greeeen-dev Dec 11, 2024
80f77bb
forgot to add this
greeeen-dev Dec 11, 2024
942d876
version bump to beta
greeeen-dev Dec 12, 2024
ba71100
add beta release notes
greeeen-dev Dec 12, 2024
990851d
experimental pylint workflow
greeeen-dev Dec 12, 2024
187009e
Merge branch 'main' into dev
greeeen-dev Dec 19, 2024
12cc5e7
THE NEXTCORD 3 IS REAL
greeeen-dev Dec 25, 2024
cded52e
prepare for alpha release
greeeen-dev Dec 25, 2024
e92e537
wrong version
greeeen-dev Dec 25, 2024
32a13fc
First commit of the year :wheeze:
NullyIsHere Dec 31, 2024
805698e
first commit of 2025
greeeen-dev Dec 31, 2024
407aae7
3rd commit of the year :D
NullyIsHere Dec 31, 2024
c10aefd
-
sam065819 Jan 1, 2025
3d2284e
Add a little message in badge for the Unifier Team.
NullyIsHere Jan 1, 2025
b70ba2c
forgot the license code :skull:
NullyIsHere Jan 1, 2025
80973fe
Merge branch 'dev' into NullyIsHere-patch-1
NullyIsHere Jan 1, 2025
99bd9a4
Readded license text
NullyIsHere Jan 1, 2025
c625aee
Merge pull request #190 from UnifierHQ/NullyIsHere-patch-1
NullyIsHere Jan 2, 2025
506cb80
Fixed grammar mistake on subdomain, gonna change repo and subdomain now.
NullyIsHere Jan 3, 2025
0f098e5
Added aliases support
NullyIsHere Jan 3, 2025
138d792
more secure tokenstore and securestorage system
greeeen-dev Jan 18, 2025
168f44f
alpha 6 changelogs
greeeen-dev Jan 18, 2025
ed47164
correct plugin json
greeeen-dev Jan 18, 2025
ef5c1e6
give wrappers on boot
greeeen-dev Jan 18, 2025
d2464af
cleanup
greeeen-dev Jan 18, 2025
1f51891
version bump
greeeen-dev Jan 18, 2025
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
60 changes: 42 additions & 18 deletions cogs/badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@
"""

import nextcord
from nextcord.ext import commands
from nextcord.ext import commands, tasks
from typing import Optional
from utils import log, langmgr, restrictions_legacy as r_legacy, slash as slash_handler
from enum import Enum
import aiohttp
import asyncio

restrictions_legacy = r_legacy.Restrictions()
language = langmgr.partial()
language.load()
slash = slash_handler.SlashHelper(language)

class UserRole(Enum):
# let values be None until set by langmgr
OWNER = language.get('owner','badge.roles')
ADMIN = language.get('admin','badge.roles')
MODERATOR = language.get('moderator','badge.roles')
TRUSTED = language.get('trusted','badge.roles')
BANNED = language.get('banned','badge.roles')
USER = language.get('user','badge.roles')
OWNER = language.get('owner', 'badge.roles')
ADMIN = language.get('admin', 'badge.roles')
MODERATOR = language.get('moderator', 'badge.roles')
TRUSTED = language.get('trusted', 'badge.roles')
BANNED = language.get('banned', 'badge.roles')
USER = language.get('user', 'badge.roles')

class Badge(commands.Cog, name=':medal: Badge'):
"""Badge contains commands that show you your role in Unifier."""
Expand All @@ -46,7 +47,7 @@ def __init__(self, bot):
language = self.bot.langmgr
self.embed_colors = {
UserRole.OWNER: (
self.bot.colors.greens_hair if self.bot.user.id==1187093090415149056 else self.bot.colors.unifier
self.bot.colors.greens_hair if self.bot.user.id == 1187093090415149056 else self.bot.colors.unifier
),
UserRole.ADMIN: nextcord.Color.green(),
UserRole.MODERATOR: nextcord.Color.purple(),
Expand All @@ -55,6 +56,18 @@ def __init__(self, bot):
UserRole.USER: nextcord.Color.blurple()
}
restrictions_legacy.attach_bot(self.bot)
self.unifier_team_data = {}
self.check_unifier_team.start()

@tasks.loop(minutes=30)
async def check_unifier_team(self):
url = "https://colab.unifierhq.org/data.json"
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
if response.status == 200:
self.unifier_team_data = await response.json()
else:
self.logger.warning(f"Failed to fetch Unifier team data: {response.status}")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could just do this by having a json file on the repo (or another) tbh

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is https://github.com/UnifierHQ/colaborators , but a GET requests is faster and more lightweight.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that explains the cname, but consider renaming that to "collaborators" since that's the correct spelling

same goes for the subdomain


@nextcord.slash_command(
description=language.desc('badge.badge'),
Expand All @@ -72,48 +85,57 @@ async def badge(
user_role = self.get_user_role(user.id)
embed = nextcord.Embed(
description=selector.fget("body", values={
'mention':f"<@{user.id}>",'role': user_role.value
'mention': f"<@{user.id}>", 'role': user_role.value
}),
color=self.embed_colors[user_role]
)
embed.set_author(
name=f'@{user.name}',
icon_url=user.avatar.url if user.avatar else None
)
if user_role==UserRole.BANNED:
if user_role == UserRole.BANNED:
embed.set_footer(text=selector.get("easter_egg"))


if str(user.id) in self.unifier_team_data:
team_member = self.unifier_team_data[str(user.id)]
embed.add_field(
name="Unifier Team",
value=f"{team_member['icon']} - **{team_member['displayname']}** is a **{team_member['role']}** in the Unifier team.",
inline=False
)

await ctx.send(embed=embed)

@commands.command(hidden=True,aliases=['trust'],description=language.desc('badge.verify'))
@commands.command(hidden=True, aliases=['trust'], description=language.desc('badge.verify'))
@restrictions_legacy.admin()
async def verify(self, ctx, user: nextcord.User):
selector = language.get_selector(ctx)

if user.id in self.bot.trusted_group:
return await ctx.send(f'{self.bot.ui_emojis.error} '+selector.fget("failed", values={'user': user.name}))
return await ctx.send(f'{self.bot.ui_emojis.error} ' + selector.fget("failed", values={'user': user.name}))

self.bot.trusted_group.append(user.id)

self.bot.db['trusted'] = self.bot.trusted_group
await self.bot.loop.run_in_executor(None, lambda: self.bot.db.save_data())

await ctx.send(f'{self.bot.ui_emojis.success} '+selector.fget("success", values={'user': user.name}))
await ctx.send(f'{self.bot.ui_emojis.success} ' + selector.fget("success", values={'user': user.name}))

@commands.command(hidden=True, aliases=['untrust'], description=language.desc('badge.unverify'))
@restrictions_legacy.admin()
async def unverify(self, ctx, user: nextcord.User):
selector = language.get_selector(ctx)

if not user.id in self.bot.trusted_group:
return await ctx.send(f'{self.bot.ui_emojis.error} '+selector.fget("failed", values={'user': user.name}))
return await ctx.send(f'{self.bot.ui_emojis.error} ' + selector.fget("failed", values={'user': user.name}))

self.bot.trusted_group.remove(user.id)

self.bot.db['trusted'] = self.bot.trusted_group
await self.bot.loop.run_in_executor(None, lambda: self.bot.db.save_data())

await ctx.send(f'{self.bot.ui_emojis.success} '+selector.fget("success", values={'user': user.name}))
await ctx.send(f'{self.bot.ui_emojis.success} ' + selector.fget("success", values={'user': user.name}))

def get_user_role(self, user_id):
if user_id == self.bot.owner or user_id in self.bot.other_owners:
Expand All @@ -132,6 +154,9 @@ def get_user_role(self, user_id):
async def cog_command_error(self, ctx, error):
await self.bot.exhandler.handle(ctx, error)

def setup(bot):
bot.add_cog(Badge(bot))

# Happy new 2025, leaving this as an easteregg, with love, ItsAsheer, green., summer., Lezetho, Arhan, Saphire, and arandomguy

# note from green to itsasheer:
Expand All @@ -141,5 +166,4 @@ async def cog_command_error(self, ctx, error):
# (jokes aside happy new year)

# ItsAsheer --> green. : Its bc new update to badge.py soon :eyes:, and bc its not a critical feature (imagine i broke bridge.py. We could create an easter egg file where we leave comments :)
def setup(bot):
bot.add_cog(Badge(bot))

Loading