示例#1
0
async def maybe_migrate_config_identifier() -> None:
    old_config: Config = Config.get_conf(
        None,
        cog_name="Status",
        identifier="Vexed-status"  # type:ignore
    )
    new_config: Config = Config.get_conf(None,
                                         cog_name="Status",
                                         identifier=418078199982063626)
    new_config.register_global(migrated_identifier=False)

    if await new_config.migrated_identifier() is True:
        return

    await new_config.version.set(await old_config.version())
    await new_config.feed_store.set(await old_config.feed_store())
    await new_config.old_ids.set(await old_config.old_ids())

    old_channel_data = await old_config.all_channels()
    async for channel, data in AsyncIter(old_channel_data.items(), steps=25):
        await new_config.channel_from_id(channel).feeds.set(data.get("feeds"))

    old_guild_data = await old_config.all_guilds()
    async for guild, data in AsyncIter(old_guild_data.items(), steps=25):
        await new_config.guild_from_id(guild).service_restrictions.set(
            data.get("service_restrictions"))

    await new_config.migrated_identifier.set(True)
    await old_config.clear_all()
示例#2
0
class ConfigHolderClass(object):
    AccountManager = Config.get_conf(
        None, identifier=1273062035, force_registration=True, cog_name="AccountManager"
    )
    GamingProfile = Config.get_conf(
        None, identifier=9420012589, force_registration=True, cog_name="GamingProfile"
    )
    PCSpecs = Config.get_conf(
        None, identifier=8205491788, force_registration=True, cog_name="PCSpecs"
    )
    PublisherManager = Config.get_conf(
        None, identifier=2064553666, force_registration=True, cog_name="PublisherManager"
    )
    PlayerStatus = Config.get_conf(
        None, identifier=3584065639, force_registration=True, cog_name="PlayerStatus"
    )
    LogoData = Config.get_conf(
        None, identifier=7056820599, force_registration=True, cog_name="LogoData"
    )
    DynamicChannels = Config.get_conf(
        None, identifier=3172784244, force_registration=True, cog_name="DynamicChannels"
    )
    CustomChannels = Config.get_conf(
        None, identifier=7861412794, force_registration=True, cog_name="CustomChannels"
    )
    RandomQuotes = Config.get_conf(
        None, identifier=8475527184, force_registration=True, cog_name="RandomQuotes"
    )
示例#3
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=572944636209922059,
         force_registration=True,
     )
示例#4
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(self, 176070082584248320, force_registration=True)
     self.config.register_guild(ping_single_users=False)
     # {CHANNEL_ID: {FEED_NAME: {...}}}
     self.config.init_custom(FEED, 2)
     self.config.register_custom(FEED, user_mentions=[], role_mentions=[])
示例#5
0
    def get_config_object(self, bot, cogname, attr, _id):
        try:
            config = getattr(bot.get_cog(cogname), attr)
        except (TypeError, AttributeError):
            config = Config.get_conf(None, _id, cog_name=cogname)

        return config
示例#6
0
    def __init__(self, bot: Red) -> None:
        self.bot = bot

        self.config: Config = Config.get_conf(self,
                                              418078199982063626,
                                              force_registration=True)
        self.config.register_global(version=0)
        self.config.register_guild(
            time_utc_s=None,
            message_w_year=None,
            message_wo_year=None,
            channel_id=None,
            role_id=None,
            setup_state=
            0,  # 0 is not setup, 5 is everything setup. this is so it can be steadily
            # incremented with individual setup commands or with the interactive setup, then
            # easily checked
        )
        self.config.register_member(birthday={"year": 1, "month": 1, "day": 1})

        self.loop_meta = VexLoop("Birthday loop", 60 * 60)
        self.loop = self.bot.loop.create_task(self.birthday_loop())
        self.role_manager = self.bot.loop.create_task(
            self.birthday_role_manager())
        self.coro_queue = asyncio.Queue()

        self.ready = asyncio.Event()
示例#7
0
 def __init__(self, bot, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.bot: Red = bot
     self.config = Config.get_conf(self, identifier=78631113035100160)
     self.config.register_guild(
         channel=None, warn_message="Warning: detected invite url in status:"
     )
示例#8
0
 def __init__(self, bot):
     self.bot = bot
     self.config = Config.get_conf(self, identifier=78631113035100160, force_registration=True)
     self.config.register_global(handled_variation=False, handled_full_str_emoji=False)
     self.config.register_role(
         exclusive_to={},
         requires_any=[],
         requires_all=[],
         add_with=[],
         sticky=False,
         self_removable=False,
         self_role=False,
         protected=False,
         cost=0,
         subscription=0,
         subscribed_users={},
         dm_msg=None,
     )  # subscribed_users maps str(user.id)-> end time in unix timestamp
     self.config.register_member(roles=[], forbidden=[])
     self.config.init_custom("REACTROLE", 2)
     self.config.register_custom(
         "REACTROLE", roleid=None, channelid=None, guildid=None
     )  # ID : Message.id, str(React)
     self.config.register_guild(notify_channel=None, s_roles=[], free_roles=[], join_roles=[])
     self._ready = asyncio.Event()
     self._start_task: Optional[asyncio.Task] = None
     self.loop = asyncio.get_event_loop()
     self._sub_task = self.loop.create_task(self.sub_checker())
     # remove selfrole commands since we are going to override them
     self.bot.remove_command("selfrole")
     super().__init__()
示例#9
0
    def __init__(self, bot):
        self.bot = bot
        self.config = Config.get_conf(
            self,
            identifier=1001,
            force_registration=True,
        )
        self.url = "https://wiki.multitheftauto.com/wiki/"

        with open(data_manager.bundled_data_path(self) / "list.json", "r") as f:
            self.list = json.load(f)

        with open(data_manager.bundled_data_path(self) / "channels.json", "r") as f:
            self.channels = json.load(f)

        self.junk = [
            "[[{{{image}}}|link=]]"
        ]

        self.types = [
            "Server-only function",
            "Serverside event",
            "Client-only function",
            "Clientside event",
            "Shared function",
            "Useful Function"
        ]
示例#10
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self._session: aiohttp.ClientSession
     self.config = Config.get_conf(self,
                                   176070082584248320,
                                   force_registration=True)
     self.config.register_guild(
         blocklist_mode=False,
         file_extensions=[".txt", ".log"],
         listen_to_bots=False,
         listen_to_self=False,
     )
     # state:
     #  - `True` - allowed
     #  - `False` - blocked
     #  - `None` - not set (the default)
     self.config.register_channel(state=None)
     # gists:
     #  list of IDs of all uploaded gists for the files uploaded by user
     #  the only purpose of this are data deletion requests
     self.config.register_user(gists=[])
     # message_cache:
     #  {message_id: (user_id, gist_id, bot_message_id)}
     self._message_cache: MutableMapping[int,
                                         Tuple[int, str,
                                               int]] = cachetools.Cache(
                                                   maxsize=10_000)
     self._guild_cache: Dict[int, GuildData] = {}
示例#11
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=8237578807127857,
         force_registration=True,
     )
示例#12
0
    def __init__(self, bot):
        super().__init__()
        self.bot = bot
        self.config = Config.get_conf(self,
                                      identifier=78631113035100160,
                                      force_registration=True)
        self.config.register_guild(
            boxes=[],
            add_reactions=False,
            reactions=["\N{THUMBS UP SIGN}", "\N{THUMBS DOWN SIGN}"],
            forms={},
            approval_queues={},
            log_channel=None,
        )

        self.config.register_global(
            boxes=[],
            add_reactions=False,
            reactions=["\N{THUMBS UP SIGN}", "\N{THUMBS DOWN SIGN}"],
            forms={},
            approval_queues={},
        )

        self.config.init_custom("SUGGESTION", 1)
        self.config.register_custom("SUGGESTION", data={})
        self.config.register_member(blocked=False)
        self.config.register_user(blocked=False)
        self.antispam = {}
 def __init__(self, bot):
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier={{cookiecutter.config_id}},
         force_registration=True,
     )
示例#14
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=82345678897346,
         force_registration=True,
     )
示例#15
0
    def __init__(self, bot: Red) -> None:
        self.bot = bot
        self.config = Config.get_conf(
            self,
            identifier=567234895692346562369,
            force_registration=True,
        )
        default_guild = {"tags": {}}
        self.config.register_guild(**default_guild)

        blocks = stable_blocks + [
            block.MathBlock(),
            block.RandomBlock(),
            block.RangeBlock(),
            block.AnyBlock(),
            block.IfBlock(),
            block.AllBlock(),
            block.BreakBlock(),
            block.StrfBlock(),
            block.StopBlock(),
            block.AssignmentBlock(),
            block.FiftyFiftyBlock(),
            block.ShortCutRedirectBlock("args"),
            block.LooseVariableGetterBlock(),
            block.SubstringBlock(),
        ]
        self.engine = Interpreter(blocks)
        self.role_converter = commands.RoleConverter()
        self.channel_converter = commands.TextChannelConverter()
        self.member_converter = commands.MemberConverter()
        self.emoji_converter = commands.EmojiConverter()

        self.guild_tag_cache = defaultdict(dict)
        self.task = asyncio.create_task(self.cache_tags())
示例#16
0
    def __init__(self, bot: Red) -> None:
        self.bot = bot
        self.config = Config.get_conf(
            self,
            identifier=567234895692346562369,
            force_registration=True,
        )
        default_guild = {"tags": {}}
        default_global = {
            "tags": {},
            "blocks": {},
            "async_enabled": False,
            "dot_parameter": False
        }
        self.config.register_guild(**default_guild)
        self.config.register_global(**default_global)

        self.guild_tag_cache = defaultdict(dict)
        self.global_tag_cache = {}
        self.initialize_task = None
        self.dot_parameter: bool = None
        self.async_enabled: bool = None
        self.initialize_task = self.create_task(self.initialize())

        self.session = aiohttp.ClientSession()
        self.docs: list = []
        if bot._cli_flags.logging_level == logging.DEBUG:
            logging.getLogger("TagScriptEngine").setLevel(logging.DEBUG)

        bot.add_dev_env_value("tags", lambda ctx: self)
        super().__init__()
示例#17
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     cog = self.bot.get_cog("CustomCommands")
     if cog:
         raise RuntimeError(
             "This cog conflicts with CustomCommands and cannot be loaded with both at the same time."
         )
     self.config = Config.get_conf(
         self,
         identifier=567234895692346562369,
         force_registration=True,
     )
     default_guild = {"tags": {}}
     self.config.register_guild(**default_guild)
     blocks = stable_blocks + [
         block.MathBlock(),
         block.RandomBlock(),
         block.RangeBlock(),
         block.AnyBlock(),
         block.IfBlock(),
         block.AllBlock(),
         block.BreakBlock(),
         block.StrfBlock(),
         block.StopBlock(),
         block.AssignmentBlock(),
         block.FiftyFiftyBlock(),
         block.ShortCutRedirectBlock("message"),
         block.LooseVariableGetterBlock(),
         block.SubstringBlock(),
     ]
     self.engine = Interpreter(blocks)
示例#18
0
    def __init__(self, bot: Red) -> None:
        self.bot = bot

        self.config: Config = Config.get_conf(self,
                                              418078199982063626,
                                              force_registration=True)
        self.config.register_guild(timechannels={})
示例#19
0
 def __init__(self, bot):
     self.bot = bot
     self.config = Config.get_conf(self, identifier=0x3D86BBD3E2B744AE8AA8B5D986EB4DD8)
     default_member = {"role": None}
     default_guild = {"blacklist": [], "role_persistence": True}
     self.config.register_member(**default_member)
     self.config.register_guild(**default_guild)
示例#20
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=3782421,
         force_registration=True,
     )
示例#21
0
    def get_config_object(self, bot, cogname, attr, _id):
        try:
            config = getattr(bot.get_cog(cogname), attr)
        except (TypeError, AttributeError):
            config = Config.get_conf(None, _id, cog_name=cogname)

        return config
示例#22
0
    def __init__(self, bot: Red) -> None:
        self.bot = bot
        self.application_id = None
        self.eval_command = None
        self.http = SlashHTTP(self)
        self.config = Config.get_conf(
            self,
            identifier=70342502093747959723475890,
            force_registration=True,
        )
        default_guild = {"tags": {}}
        default_global = {"application_id": None, "eval_command": None}
        self.config.register_guild(**default_guild)
        self.config.register_global(**default_global)

        self.command_cache = {}
        self.button_cache = {}
        self.guild_tag_cache: Dict[int, Dict[int,
                                             SlashTag]] = defaultdict(dict)
        self.global_tag_cache = {}

        self.load_task = self.create_task(self.initialize_task())
        bot.add_dev_env_value("st", lambda ctx: self)

        super().__init__()
示例#23
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=283457823853246562378,
         force_registration=True,
     )
示例#24
0
 def __init__(self, bot):
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=123456789,
         force_registration=True,
     )
示例#25
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=23457892378904578923089489,
         force_registration=True,
     )
示例#26
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=623469945234523465,
         force_registration=True,
     )
示例#27
0
 def __init__(self, bot):
     self.bot = bot
     self.config = Config.get_conf(
         self, identifier=78631113035100160, force_registration=True
     )
     self.config.register_global(
         handled_variation=False, handled_full_str_emoji=False
     )
     self.config.register_role(
         exclusive_to=[],
         requires_any=[],
         requires_all=[],
         sticky=False,
         self_removable=False,
         self_role=False,
         protected=False,
         cost=0,
     )
     self.config.register_member(roles=[], forbidden=[])
     self.config.init_custom("REACTROLE", 2)
     self.config.register_custom(
         "REACTROLE", roleid=None, channelid=None, guildid=None
     )  # ID : Message.id, str(React)
     self.config.register_guild(notify_channel=None)
     self._ready = asyncio.Event()
     self._start_task: Optional[asyncio.Task] = None
     super().__init__()
    def __init__(self, bot: Red) -> None:
        self.bot = bot

        crtools_cog = self.bot.get_cog("ClashRoyaleTools")
        self.tags = getattr(crtools_cog, "tags", None)
        self.constants = Constants()

        default_global = {
            "clans": dict(),
            "keep_memberlog": False,
            "dispatch_event": True,
        }
        self.config = Config.get_conf(
            self,
            identifier=2286464642345664457,
            force_registration=True,
        )
        self.config.register_global(**default_global)

        try:
            self.claninfo_path = str(bundled_data_path(self) / "clans.json")
            with open(self.claninfo_path) as file:
                self.static_clandata = dict(json.load(file))
        except:
            self.static_clandata = {}

        self.claninfo_lock = asyncio.Lock()

        self.refresh_task = self.get_clandata.start()
        self.token_task = self.bot.loop.create_task(self.crtoken())
        self.clash = None
        self.last_updated = None
        self.last_updated_preety = None
        self.last_error_time = None
        self.loop_count = 0
示例#29
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=567234895692346562369,
         force_registration=True,
     )
     default_guild = {"tags": {}}
     self.config.register_guild(**default_guild)
     blocks = [
         block.MathBlock(),
         block.RandomBlock(),
         block.RangeBlock(),
         block.AnyBlock(),
         block.IfBlock(),
         block.AllBlock(),
         block.BreakBlock(),
         block.StrfBlock(),
         block.StopBlock(),
         block.AssignmentBlock(),
         block.FiftyFiftyBlock(),
         block.ShortCutRedirectBlock("message"),
         block.LooseVariableGetterBlock(),
         block.SubstringBlock(),
     ]
     self.engine = Interpreter(blocks)
示例#30
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=52834582367672349,
         force_registration=True,
     )
示例#31
0
 def __init__(self, bot):
     super().__init__()
     self.bot = bot
     self.config = Config.get_conf(self,
                                   identifier=78631113035100160,
                                   force_registration=True)
     self.config.register_guild(active=False, action=0)
     self.config.register_channel(exclude=False)
示例#32
0
 def __init__(self, bot):
     self.bot = bot
     self.config = Config.get_conf(self, identifier=78631113035100160, force_registration=True)
     self.config.register_member(roles=[])
     self.config.register_role(sticky=False)
示例#33
0
 def __init__(self, bot):
     self.bot = bot
     self.config = Config.get_conf(self, identifier=326328326783286, force_registration=True)
     self.config.register_global(suggestions=[], suggestion_channel=472408084686438422)
     self.bot.add_listener(self.message_sent, "on_message")