from discord.utils import find from discord.errors import Forbidden, NotFound from datetime import datetime import re FIELDS = [ "trades", "favorite games", "favorite items", "inactivity notice", "description" ] FIELDS_STR = ", ".join(FIELDS) game_id_regex = re.compile(r"https://www.roblox.com/games/(\d+)/?") catalog_id_regex = re.compile(r"https://www.roblox.com/catalog/(\d+)/?") parse_message = Bloxlink.get_module("commands", attrs="parse_message") get_game, get_catalog_item, get_user = Bloxlink.get_module( "roblox", attrs=["get_game", "get_catalog_item", "get_user"]) get_inactive_role, handle_inactive_role, get_profile = Bloxlink.get_module( "roblox", name_override="RobloxProfile", attrs=["get_inactive_role", "handle_inactive_role", "get_profile"]) post_event = Bloxlink.get_module("utils", attrs=["post_event"]) @Bloxlink.command class ProfileCommand(Bloxlink.Module): """view someone's personal profile""" def __init__(self): self.arguments = [{ "prompt": "Please specify the user to retrieve the profile of.",
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from resources.constants import NICKNAME_TEMPLATES, DEFAULTS, UNVERIFIED_TEMPLATES, BROWN_COLOR # pylint: disable=import-error from resources.exceptions import Message # pylint: disable=import-error from discord.errors import NotFound, HTTPException, Forbidden post_event = Bloxlink.get_module("utils", attrs=["post_event"]) set_guild_value = Bloxlink.get_module("cache", attrs=["set_guild_value"]) @Bloxlink.command class JoinDMCommand(Bloxlink.Module): """greets people who join the server. by default, this is ENABLED for verified members.""" def __init__(self): self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Administration" self.arguments = [{ "prompt": "Would you like to alter/disable the DM messages for **verified** or **unverified** users?", "type": "choice", "choices": ("verified", "unverified"), "name": "subcommand" }] self.hidden = True async def __main__(self, CommandArgs): subcommand = CommandArgs.parsed_args["subcommand"] if subcommand == "verified": await self.verified(CommandArgs) elif subcommand == "unverified": await self.unverified(CommandArgs)
import math from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error, no-name-in-module from resources.constants import SHARD_RANGE, CLUSTER_ID, STARTED, IS_DOCKER, RELEASE # pylint: disable=import-error, no-name-in-module from discord import Embed from time import time from psutil import Process from os import getpid broadcast = Bloxlink.get_module("ipc", attrs="broadcast") @Bloxlink.command class StatsCommand(Bloxlink.Module): """view the current stats of Bloxlink""" def __init__(self): self.aliases = ["statistics", "nerdinfo"] self.dm_allowed = True self.slash_enabled = True if len(SHARD_RANGE) > 1: self.shard_range = f"{SHARD_RANGE[0]}-{SHARD_RANGE[len(SHARD_RANGE)-1]}" else: self.shard_range = SHARD_RANGE[0] async def __main__(self, CommandArgs): response = CommandArgs.response clusters = 0 total_mem = 0 process = Process(getpid())
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from resources.exceptions import Message, Error, CancelledPrompt, PermissionError # pylint: disable=import-error from resources.constants import ARROW, OPTIONS, DEFAULTS, NICKNAME_TEMPLATES, ORANGE_COLOR, GOLD_COLOR, BROWN_COLOR, TRELLO # pylint: disable=import-error from discord import Embed, Object from os import environ as env from discord.errors import Forbidden from aiotrello.exceptions import TrelloUnauthorized, TrelloNotFound, TrelloBadRequest get_prefix, post_event = Bloxlink.get_module( "utils", attrs=["get_prefix", "post_event"]) get_options = Bloxlink.get_module("trello", attrs=["get_options"]) parse_message = Bloxlink.get_module("commands", attrs=["parse_message"]) clear_guild_data, set_guild_value = Bloxlink.get_module( "cache", attrs=["clear_guild_data", "set_guild_value"]) get_features = Bloxlink.get_module("premium", attrs=["get_features"]) RESET_CHOICES = ("everything", "binds") options_keys = [o for o, o_d in OPTIONS.items() if not o_d[3]] premium_option_keys = [o for o, o_d in OPTIONS.items() if o_d[3]] options_combined = options_keys + premium_option_keys options_strings = ", ".join([o for o, o_d in OPTIONS.items() if not o_d[3]]) premium_options_strings = ", ".join( [o for o, o_d in OPTIONS.items() if o_d[3]]) @Bloxlink.command class SettingsCommand(Bloxlink.Module): """change, view, or reset your Bloxlink settings""" def __init__(self): permission = Bloxlink.Permissions().build("BLOXLINK_MANAGER")
def __init__(self): self.aliases = ["newbind"] self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Binds" self.slash_enabled = True
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from discord import Embed from resources.exceptions import Error, Message # pylint: disable=import-error from resources.constants import ARROW, BLURPLE_COLOR # pylint: disable=import-error from aiotrello.exceptions import TrelloException import asyncio get_binds, get_group, count_binds = Bloxlink.get_module( "roblox", attrs=["get_binds", "get_group", "count_binds"]) post_event = Bloxlink.get_module("utils", attrs=["post_event"]) clear_guild_data = Bloxlink.get_module("cache", attrs=["clear_guild_data"]) BIND_TYPES = ("asset", "badge", "gamepass") async def delete_bind_from_cards(type="group", bind_id=None, trello_binds_list=None, bind_data_trello=None, rank=None, high=None, low=None): if not (trello_binds_list and bind_data_trello): return if type == "group": if rank in ("main", "everything"): cards = bind_data_trello.get("trello", {}).get("cards", []) for rank_id, rank_data in bind_data_trello.get("binds", {}).items():
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from discord import File from io import BytesIO fetch = Bloxlink.get_module("utils", attrs=["fetch"]) @Bloxlink.command class HelpCommand(Bloxlink.Module): """view information about Bloxlink""" def __init__(self): self.dm_allowed = True self.slash_enabled = True self.images = None self.urls = [ "https://i.imgur.com/zQwITet.png", "https://i.imgur.com/yv6jfNC.png", "https://i.imgur.com/pwMB8wZ.png" ] async def __setup__(self): self.images = [] for url in self.urls: image_data, image_response = await fetch(url=url, bytes=True, raise_on_failure=False) if image_response.status == 200: self.images.append(image_data)
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from discord import Embed from resources.exceptions import Message, UserNotVerified, Error, BloxlinkBypass, Blacklisted, PermissionError # pylint: disable=import-error from resources.constants import GREEN_COLOR, VERIFY_URL # pylint: disable=import-error format_update_embed, guild_obligations = Bloxlink.get_module( "roblox", attrs=["format_update_embed", "guild_obligations"]) get_options = Bloxlink.get_module("trello", attrs="get_options") post_event = Bloxlink.get_module("utils", attrs=["post_event"]) class GetRoleCommand(Bloxlink.Module): """get your server roles""" def __init__(self): self.category = "Account" self.cooldown = 5 self.aliases = ["getroles", "get-roles", "get-role"] self.slash_enabled = True self.slash_ack = True @Bloxlink.flags async def __main__(self, CommandArgs): trello_board = CommandArgs.trello_board guild_data = CommandArgs.guild_data guild = CommandArgs.guild author = CommandArgs.author response = CommandArgs.response prefix = CommandArgs.prefix trello_options = {}
def __init__(self): self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Administration" self.aliases = ["ignore", "ignore-channel"]
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from resources.exceptions import Error, RobloxNotFound # pylint: disable=import-error from discord import Embed from discord.errors import NotFound get_user = Bloxlink.get_module("roblox", attrs=["get_user"]) @Bloxlink.command class ReverseSearchCommand(Bloxlink.Module): """find Discord IDs in your server that are linked to a certain Roblox ID""" def __init__(self): self.examples = ["1", "569422833", "blox_link"] self.arguments = [{ "prompt": "Please specify either a username or Roblox ID. If the person's name is all numbers, " "then attach a ``--username`` flag to this command. Example: ``!getinfo 1234 --username`` will " "search for a user with a Roblox username of '1234' instead of a Roblox ID.", "name": "target" }] self.category = "Administration" self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") @Bloxlink.flags async def __main__(self, CommandArgs): guild = CommandArgs.message.guild target = CommandArgs.parsed_args["target"] flags = CommandArgs.flags response = CommandArgs.response
def __init__(self): self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.aliases = ["verificationchannel", "verification-channel"] self.category = "Administration" self.slash_enabled = True
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error, no-name-in-module from resources.exceptions import Message, Error, PermissionError, CancelledPrompt # pylint: disable=import-error, no-name-in-module from resources.constants import LIMITS, ARROW, DEFAULTS, ORANGE_COLOR, OWNER, PROMPT # pylint: disable=import-error, no-name-in-module from discord import Embed from discord.errors import Forbidden from time import time from asyncio import TimeoutError import datetime import json count_binds = Bloxlink.get_module("roblox", attrs=["count_binds"]) get_board, get_options = Bloxlink.get_module("trello", attrs=["get_board", "get_options"]) get_prefix = Bloxlink.get_module("utils", attrs=["get_prefix"]) cache_pop = Bloxlink.get_module("cache", attrs=["pop"]) INT_REACTIONS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣"] @Bloxlink.command class DataCommand(Bloxlink.Module): """backup or restore your stored Server Data""" async def _backup(self, guild, backup_name): guild_data = await self.r.table("guilds").get(str(guild.id)).run() or {} if guild_data: return { "data": guild_data, "timestamp": time(), "guildId": str(guild.id), "backupName": backup_name
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from discord import Embed from resources.exceptions import Message, RobloxNotFound # pylint: disable=import-error from resources.constants import ARROW # pylint: disable=import-error import asyncio get_binds, get_group, count_binds = Bloxlink.get_module( "roblox", attrs=["get_binds", "get_group", "count_binds"]) @Bloxlink.command class ViewBindsCommand(Bloxlink.Module): """view your server bound roles""" def __init__(self): self.category = "Binds" self.aliases = ["binds"] self.slash_enabled = True async def __main__(self, CommandArgs): guild = CommandArgs.guild guild_data = CommandArgs.guild_data trello_board = CommandArgs.trello_board prefix = CommandArgs.prefix role_binds, group_ids, _ = await get_binds(guild_data=guild_data, trello_board=trello_board) if count_binds(guild_data, role_binds=role_binds, group_ids=group_ids) == 0: raise Message(
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from resources.constants import DEFAULTS, BROWN_COLOR # pylint: disable=import-error post_event = Bloxlink.get_module("utils", attrs=["post_event"]) @Bloxlink.command class DynamicRolesCommand(Bloxlink.Module): """automatically create missing group roles. by default, this is ENABLED.""" def __init__(self): self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Administration" self.hidden = True async def __main__(self, CommandArgs): response = CommandArgs.response author = CommandArgs.message.author guild = CommandArgs.message.guild guild_data = CommandArgs.guild_data toggle = not guild_data.get("dynamicRoles", DEFAULTS.get("dynamicRoles")) guild_data["dynamicRoles"] = toggle await self.r.table("guilds").insert(guild_data, conflict="update").run() if toggle:
class VerifyCommand(Bloxlink.Module): """link your Roblox account to your Discord account and get your server roles""" def __init__(self): self.examples = ["add", "unlink", "view", "blox_link"] self.category = "Account" self.cooldown = 5 self.aliases = ["getrole", "getroles"] self.dm_allowed = True @staticmethod async def validate_username(message, content): try: roblox_id, username = await get_roblox_id(content) except RobloxNotFound: return None, "There was no Roblox account found with that username. Please try again." return username @Bloxlink.flags async def __main__(self, CommandArgs): trello_board = CommandArgs.trello_board guild_data = CommandArgs.guild_data guild = CommandArgs.message.guild author = CommandArgs.message.author response = CommandArgs.response prefix = CommandArgs.prefix if not guild: return await self.add(CommandArgs) if CommandArgs.flags.get("add") or CommandArgs.flags.get( "verify") or CommandArgs.flags.get("force"): await CommandArgs.response.error( f"``{CommandArgs.prefix}verify --force`` is deprecated and will be removed in a future version of Bloxlink. " f"Please use ``{prefix}verify add`` instead.") return await self.add(CommandArgs) if CommandArgs.real_command_name in ("getrole", "getroles"): CommandArgs.string_args = [] trello_options = {} if trello_board: trello_options, _ = await get_options(trello_board) guild_data.update(trello_options) try: old_nickname = author.display_name added, removed, nickname, errors, roblox_user = await guild_obligations( CommandArgs.message.author, guild=guild, guild_data=guild_data, roles=True, nickname=True, trello_board=CommandArgs.trello_board, given_trello_options=True, cache=False, response=response, dm=False, exceptions=("BloxlinkBypass", "Blacklisted", "UserNotVerified", "PermissionError")) except BloxlinkBypass: raise Message( "Since you have the ``Bloxlink Bypass`` role, I was unable to update your roles/nickname.", type="info") except Blacklisted as b: if str(b): raise Error( f"{author.mention} has an active restriction for: ``{b}``") else: raise Error( f"{author.mention} has an active restriction from Bloxlink." ) except UserNotVerified: await self.add(CommandArgs) except PermissionError as e: raise Error(e) else: welcome_message, embed = await format_update_embed( roblox_user, author, added=added, removed=removed, errors=errors, nickname=nickname if old_nickname != author.display_name else None, prefix=prefix, guild_data=guild_data) if embed: await post_event( guild, guild_data, "verification", f"{author.mention} ({author.id}) has **verified** as ``{roblox_user.username}``.", GREEN_COLOR) else: embed = Embed( description= "This user is all up-to-date; no changes were made.") await response.send(content=welcome_message, embed=embed) @Bloxlink.subcommand() async def add(self, CommandArgs): """link a new account to Bloxlink""" author = CommandArgs.message.author if CommandArgs.message.guild: guild_data = CommandArgs.guild_data if not guild_data.get("hasBot"): guild_data["hasBot"] = True await self.r.table("guilds").insert(guild_data, conflict="update").run() response_text = f"{author.mention}, to verify with Bloxlink, please visit our website at " \ f"<{VERIFY_URL}>. It won't take long!\nStuck? See this video: <https://www.youtube.com/watch?v=hq496NmQ9GU>" else: response_text = "To verify with Bloxlink, please visit our website at " \ f"<{VERIFY_URL}>. It won't take long!\nStuck? See this video: <https://www.youtube.com/watch?v=hq496NmQ9GU>" await CommandArgs.response.send(response_text) @Bloxlink.subcommand( permissions=Bloxlink.Permissions().build("BLOXLINK_MANAGER")) async def customize(self, CommandArgs): """customize the behavior of !verify""" # TODO: able to set: "forced groups" prefix = CommandArgs.prefix response = CommandArgs.response author = CommandArgs.message.author guild = CommandArgs.message.guild guild_data = CommandArgs.guild_data if not guild: return await response.send( "This sub-command can only be used in a server!") choice = (await CommandArgs.prompt([{ "prompt": "Which option would you like to change?\nOptions: ``(welcomeMessage)``", "name": "choice", "type": "choice", "choices": ("welcomeMessage", ) }]))["choice"] trello_board = CommandArgs.trello_board card = None if trello_board: options_trello_data, trello_binds_list = await get_options( trello_board, return_cards=True) options_trello_find = options_trello_data.get(choice) if options_trello_find: card = options_trello_find[1] if choice == "welcomeMessage": welcome_message = (await CommandArgs.prompt([{ "prompt": f"What would you like your welcome message to be? This will be shown in ``{prefix}verify`` messages.\nYou may " f"use these templates: ```{NICKNAME_TEMPLATES}```", "name": "welcome_message", "formatting": False, "max": 1500 }], last=True) )["welcome_message"] if trello_board and trello_binds_list: try: if card: if card.name == choice: await card.edit(name="welcomeMessage", desc=welcome_message) else: trello_settings_list = await trello_board.get_list(lambda L: L.name == "Bloxlink Settings") \ or await trello_board.create_list(name="Bloxlink Settings") await trello_settings_list.create_card( name="welcomeMessage", desc=welcome_message) await trello_binds_list.sync( card_limit=TRELLO["CARD_LIMIT"]) except TrelloUnauthorized: await response.error( "In order for me to edit your Trello settings, please add ``@bloxlink`` to your " "Trello board.") except (TrelloNotFound, TrelloBadRequest): pass await self.r.table("guilds").insert( { "id": str(guild.id), "welcomeMessage": welcome_message }, conflict="update").run() await post_event( guild, guild_data, "configuration", f"{author.mention} ({author.id}) has **changed** the ``{choice}``.", BROWN_COLOR) raise Message(f"Successfully saved your new ``{choice}``!", type="success") @staticmethod @Bloxlink.subcommand() async def view(CommandArgs): """view your linked account(s)""" author = CommandArgs.message.author response = CommandArgs.response try: primary_account, accounts = await get_user("username", author=author, everything=False, basic_details=True) except UserNotVerified: raise Message("You have no accounts linked to Bloxlink!", type="silly") else: accounts = list(accounts) parsed_accounts = await parse_accounts(accounts, reverse_search=True) parsed_accounts_str = [] primary_account_str = "No primary account set" for roblox_username, roblox_data in parsed_accounts.items(): if roblox_data[1]: username_str = [] for discord_account in roblox_data[1]: username_str.append( f"{discord_account} ({discord_account.id})") username_str = ", ".join(username_str) if primary_account and roblox_username == primary_account.username: primary_account_str = f"**{roblox_username}** {ARROW} {username_str}" else: parsed_accounts_str.append( f"**{roblox_username}** {ARROW} {username_str}") else: parsed_accounts_str.append(f"**{roblox_username}**") parsed_accounts_str = "\n".join(parsed_accounts_str) embed = Embed(title="Linked Roblox Accounts") embed.add_field(name="Primary Account", value=primary_account_str) embed.add_field(name="Secondary Accounts", value=parsed_accounts_str or "No secondary account saved") embed.set_author(name=author, icon_url=author.avatar_url) await response.send(embed=embed, dm=True, strict_post=True) @staticmethod @Bloxlink.subcommand() async def unlink(CommandArgs): """unlink an account from Bloxlink""" if CommandArgs.message.guild: await CommandArgs.response.reply( f"to manage your accounts, please visit our website: <{ACCOUNT_SETTINGS_URL}>" ) else: await CommandArgs.response.send( f"To manage your accounts, please visit our website: <{ACCOUNT_SETTINGS_URL}>" )
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error, no-name-in-module, no-name-in-module from resources.exceptions import Error, RobloxNotFound, RobloxAPIError, Message # pylint: disable=import-error, no-name-in-module, no-name-in-module from discord.errors import NotFound get_user, get_binds = Bloxlink.get_module("roblox", attrs=["get_user", "get_binds"]) parse_message = Bloxlink.get_module("commands", attrs=["parse_message"]) @Bloxlink.command class RobloxSearchCommand(Bloxlink.Module): """retrieve the Roblox information of a user""" def __init__(self): self.aliases = ["rs", "search", "roblox-search"] self.arguments = [ { "prompt": "Please specify either a username or Roblox ID. If the person's name is all numbers, " "then attach a `--username` flag to this command. Example: `!getinfo 1234 --username` will " "search for a user with a Roblox username of '1234' instead of a Roblox ID.", "slash_desc": "Please enter a Roblox username or Roblox ID.", "type": "string", "name": "roblox_name" } ] self.examples = [ "roblox", "569422833", "569422833 --username" ] self.cooldown = 5 self.dm_allowed = True
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from resources.exceptions import Message, Error # pylint: disable=import-error import time import math from discord import Embed, Object transfer_premium, get_features = Bloxlink.get_module( "premium", attrs=["transfer_premium", "get_features"]) cache_pop = Bloxlink.get_module("cache", attrs="pop") @Bloxlink.command class TransferCommand(Bloxlink.Module): """transfer your Bloxlink premium""" def __init__(self): self.examples = ["@justin", "disable"] self.arguments = [{ "prompt": "Please specify the user to transfer premium to.", "name": "user", "type": "user", }] self.category = "Premium" self.free_to_use = True @Bloxlink.flags async def __main__(self, CommandArgs): author = CommandArgs.message.author guild = CommandArgs.message.guild transfer_to = CommandArgs.parsed_args.get("user") response = CommandArgs.response prefix = CommandArgs.prefix
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from resources.modules.commands import commands # pylint: disable=import-error from resources.exceptions import CancelCommand, Error # pylint: disable=import-error from resources.constants import ARROW, OWNER, HELP_DESCRIPTION # pylint: disable=import-error from discord import Embed get_enabled_addons = Bloxlink.get_module("addonsm", attrs=["get_enabled_addons"]) @Bloxlink.command class HelpCommand(Bloxlink.Module): """view the command list, or get help on a certain command""" def __init__(self): self.aliases = ["cmds", "commands"] self.arguments = [ { "prompt": "Please specify the command name", "optional": True, "name": "command_name" } ] self.dm_allowed = True self.slash_enabled = True self.slash_ack = False async def __main__(self, CommandArgs): command_name = CommandArgs.parsed_args.get("command_name") prefix = CommandArgs.prefix response = CommandArgs.response guild = CommandArgs.guild
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error, no-name-in-module from resources.exceptions import Error, UserNotVerified, Message # pylint: disable=import-error, no-name-in-module get_user, get_binds = Bloxlink.get_module("roblox", attrs=["get_user", "get_binds"]) @Bloxlink.extension class GetInfoExtension(Bloxlink.Module): """update a user's roles and nickname""" def __init__(self): self.type = 2 self.name = "Get Roblox Info" self.slash_defer = True self.slash_ephemeral = True self.premium_bypass_channel_perms = True async def __main__(self, ExtensionArgs): user = ExtensionArgs.resolved guild = ExtensionArgs.guild guild_data = ExtensionArgs.guild_data response = ExtensionArgs.response prefix = ExtensionArgs.prefix if user.bot: raise Error("Bots cannot have Roblox accounts!", hidden=True) if guild: role_binds, group_ids, _ = await get_binds(guild_data=guild_data) else:
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from resources.exceptions import PermissionError, Error, RobloxNotFound, Message # pylint: disable=import-error from resources.constants import BROWN_COLOR # pylint: disable=import-error from discord import Embed, Object import re post_event = Bloxlink.get_module("utils", attrs=["post_event"]) get_group = Bloxlink.get_module("roblox", attrs=["get_group"]) get_features = Bloxlink.get_module("premium", attrs=["get_features"]) roblox_group_regex = re.compile(r"roblox.com/groups/(\d+)/") @Bloxlink.command class GroupLockCommand(Bloxlink.Module): """lock your server to group members""" @staticmethod async def validate_group(message, content): regex_search = roblox_group_regex.search(content) if regex_search: group_id = regex_search.group(1) else: group_id = content try: group = await get_group(group_id) except RobloxNotFound: return None, "No group was found with this ID. Please try again." return group
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error, no-name-in-module from resources.exceptions import Error, Message, UserNotVerified, BloxlinkBypass, Blacklisted # pylint: disable=import-error, no-name-in-module from resources.constants import DEFAULTS, GREEN_COLOR, VERIFY_URL, SELF_HOST # pylint: disable=import-error, no-name-in-module from discord.errors import Forbidden, NotFound, HTTPException from discord.utils import find get_options, get_board = Bloxlink.get_module( "trello", attrs=["get_options", "get_board"]) get_user, verify_as, parse_accounts, update_member, get_nickname, verify_member, count_binds, get_binds = Bloxlink.get_module( "roblox", attrs=[ "get_user", "verify_as", "parse_accounts", "update_member", "get_nickname", "verify_member", "count_binds", "get_binds" ]) post_event = Bloxlink.get_module("utils", attrs=["post_event"]) has_magic_role = Bloxlink.get_module("extras", attrs=["has_magic_role"]) class SwitchUserCommand(Bloxlink.Module): """change your linked Roblox account in a server""" def __init__(self): self.category = "Account" self.aliases = ["switch-user"] self.slash_enabled = True @staticmethod async def validate_server(message, content, prompt, guild): content = content.lower() if content in ("skip", "next"): return message.guild
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from resources.exceptions import Error, UserNotVerified, Message, BloxlinkBypass, CancelCommand, PermissionError, Blacklisted # pylint: disable=import-error from config import REACTIONS # pylint: disable=no-name-in-module from resources.constants import RELEASE, GREEN_COLOR # pylint: disable=import-error from discord import Object, Role import math guild_obligations, format_update_embed = Bloxlink.get_module( "roblox", attrs=["guild_obligations", "format_update_embed"]) parse_message = Bloxlink.get_module("commands", attrs=["parse_message"]) get_features = Bloxlink.get_module("premium", attrs="get_features") class UpdateUserCommand(Bloxlink.Module): """force update user(s) with roles and nicknames""" def __init__(self): permissions = Bloxlink.Permissions().build("BLOXLINK_UPDATER") permissions.allow_bypass = True self.permissions = permissions self.aliases = ["update", "updateroles", "update-user"] self.arguments = [{ "prompt": "Please specify user(s) or role(s) to update. For example: `@user1 @user2 @user3` or `@role`", "type": ["user", "role"], "name": "users", "multiple": True, "optional": True, "create_missing_role": False }] self.slash_args = [{
import re import discord from resources.exceptions import CancelledPrompt # pylint: disable=import-error, no-name-in-module from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error, no-name-in-module from resources.exceptions import PermissionError, Error, RobloxNotFound, RobloxAPIError, Message # pylint: disable=import-error, no-name-in-module from resources.constants import NICKNAME_TEMPLATES, ARROW, LIMITS, BLURPLE_COLOR, BROWN_COLOR # pylint: disable=import-error, no-name-in-module bind_num_range = re.compile(r"([0-9]+)\-([0-9]+)") roblox_group_regex = re.compile(r"roblox.com/groups/(\d+)/") get_group, count_binds, get_binds = Bloxlink.get_module( "roblox", attrs=["get_group", "count_binds", "get_binds"]) fetch, post_event = Bloxlink.get_module("utils", attrs=["fetch", "post_event"]) has_premium = Bloxlink.get_module("premium", attrs=["has_premium"]) set_guild_value, get_guild_value = Bloxlink.get_module( "cache", attrs=["set_guild_value", "get_guild_value"]) API_URL = "https://api.roblox.com" FREE_BIND_COUNT, PREM_BIND_COUNT = LIMITS["BINDS"]["FREE"], LIMITS["BINDS"][ "PREMIUM"] @Bloxlink.command class BindCommand(Bloxlink.Module): """bind a discord role to a roblox group, asset, or badge""" def __init__(self): self.aliases = ["newbind"] self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Binds" self.slash_enabled = True
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from resources.exceptions import RobloxNotFound, Error, UserNotVerified, RobloxAPIError # pylint: disable=import-error from resources.constants import LIMITS # pylint: disable=import-error from discord import Embed, Object import re get_group, get_user, parse_accounts = Bloxlink.get_module( "roblox", attrs=["get_group", "get_user", "parse_accounts"]) user_resolver = Bloxlink.get_module("resolver", attrs="user_resolver") set_guild_value = Bloxlink.get_module("cache", attrs=["set_guild_value"]) get_features = Bloxlink.get_module("premium", attrs=["get_features"]) RESTRICTION_NAME_MAP = { "groups": "Groups", "users": "Users", "robloxAccounts": "Roblox Accounts" } @Bloxlink.command class RestrictCommand(Bloxlink.Module): """restrict a Roblox user or group from verifying in your server""" def __init__(self): self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Administration" self.aliases = ["restriction"] self.slash_enabled = True self._roblox_group_regex = re.compile(r"roblox.com/groups/(\d+)/") async def resolve_restriction(self, message, content, prompt):
def __init__(self): self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Administration" self.slash_enabled = True
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error from discord import Embed set_guild_value = Bloxlink.get_module("cache", attrs="set_guild_value") addons, get_enabled_addons = Bloxlink.get_module("addonsm", attrs=["addons", "get_enabled_addons"]) @Bloxlink.command class AddonsCommand(Bloxlink.Module): """enable/disable a server add-on""" def __init__(self): self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Administration" self.aliases = ["addon"] self.hidden = True self.developer = True self.arguments = [ { "prompt": "Would you like to **view** the available add-ons, or **change** (enable/disable) an add-on?", "name": "subcommand", "type": "choice", "choices": ["view", "change", "enable", "disable"] } ] async def __main__(self, CommandArgs): subcommand_choice = CommandArgs.parsed_args["subcommand"]
from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error, no-name-in-module, no-name-in-module from resources.constants import ARROW, BROWN_COLOR, MAGIC_ROLES # pylint: disable=import-error, no-name-in-module, no-name-in-module from resources.exceptions import Error # pylint: disable=import-error, no-name-in-module, no-name-in-module import discord post_event = Bloxlink.get_module("utils", attrs=["post_event"]) set_guild_value = Bloxlink.get_module("cache", attrs=["set_guild_value"]) get_features = Bloxlink.get_module("premium", attrs=["get_features"]) @Bloxlink.command class MagicRolesCommand(Bloxlink.Module): """add/view/remove magic roles""" def __init__(self): self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Premium" self.arguments = [{ "prompt": "Magic Roles allow you to create roles that have special abilities within Bloxlink.\n\n" "Would you like to **add** a new magic role, **view** your existing magic roles, or " "**delete** an existing magic role?", "type": "choice", "components": [discord.ui.Select(max_values=1, options=[ discord.SelectOption(label="Add a new Magic Role"), discord.SelectOption(label="View Magic Roles"), discord.SelectOption(label="Delete a Magic Role"), ])], "choices": ("add a new magic role", "view magic roles", "delete a magic role"), "name": "subcommand" }]
from discord import Embed, Object from resources.exceptions import Message, UserNotVerified, Error, RobloxNotFound, BloxlinkBypass, Blacklisted, PermissionError # pylint: disable=import-error from resources.constants import ( NICKNAME_TEMPLATES, GREEN_COLOR, BROWN_COLOR, ARROW, VERIFY_URL, # pylint: disable=import-error ACCOUNT_SETTINGS_URL, TRELLO) from aiotrello.exceptions import TrelloNotFound, TrelloUnauthorized, TrelloBadRequest verify_as, get_user, get_nickname, get_roblox_id, parse_accounts, unverify_member, format_update_embed, guild_obligations = Bloxlink.get_module( "roblox", attrs=[ "verify_as", "get_user", "get_nickname", "get_roblox_id", "parse_accounts", "unverify_member", "format_update_embed", "guild_obligations" ]) get_options = Bloxlink.get_module("trello", attrs="get_options") post_event = Bloxlink.get_module("utils", attrs=["post_event"]) class VerifyCommand(Bloxlink.Module): """link your Roblox account to your Discord account and get your server roles""" def __init__(self): self.examples = ["add", "unlink", "view", "blox_link"] self.category = "Account" self.cooldown = 5 self.aliases = ["getrole", "getroles"] self.dm_allowed = True
import re import discord from resources.exceptions import CancelledPrompt # pylint: disable=import-error, no-name-in-module from resources.structures.Bloxlink import Bloxlink # pylint: disable=import-error, no-name-in-module from resources.exceptions import PermissionError, Error, RobloxNotFound, RobloxAPIError, Message # pylint: disable=import-error, no-name-in-module from resources.constants import NICKNAME_TEMPLATES, ARROW, LIMITS, BLURPLE_COLOR, BROWN_COLOR # pylint: disable=import-error, no-name-in-module from aiotrello.exceptions import TrelloUnauthorized, TrelloNotFound, TrelloBadRequest bind_num_range = re.compile(r"([0-9]+)\-([0-9]+)") roblox_group_regex = re.compile(r"roblox.com/groups/(\d+)/") get_group, parse_trello_binds, count_binds, get_binds = Bloxlink.get_module( "roblox", attrs=["get_group", "parse_trello_binds", "count_binds", "get_binds"]) fetch, post_event = Bloxlink.get_module("utils", attrs=["fetch", "post_event"]) get_features = Bloxlink.get_module("premium", attrs=["get_features"]) clear_guild_data = Bloxlink.get_module("cache", attrs=["clear_guild_data"]) API_URL = "https://api.roblox.com" FREE_BIND_COUNT, PREM_BIND_COUNT = LIMITS["BINDS"]["FREE"], LIMITS["BINDS"][ "PREMIUM"] @Bloxlink.command class BindCommand(Bloxlink.Module): """bind a discord role to a roblox group, asset, or badge""" def __init__(self): self.aliases = ["newbind"] self.permissions = Bloxlink.Permissions().build("BLOXLINK_MANAGER") self.category = "Binds" self.slash_enabled = True
loop.stop() for task in asyncio.Task.all_tasks(): task.cancel() os._exit(0) #sys.exit(0) async def signals_handler(): loop = asyncio.get_event_loop() for signame in ("SIGINT", "SIGTERM"): loop.add_signal_handler( getattr(signal, signame), lambda: asyncio.ensure_future(handle_signal(signame), loop=loop)) async def main(): #load_sentry() await signals_handler() await register_modules() if __name__ == "__main__": loop.create_task(main()) Bloxlink.run(TOKEN)