ram optimization
This commit is contained in:
parent
4a508b1851
commit
eca6e7b268
10 changed files with 23 additions and 22 deletions
|
@ -6,6 +6,7 @@
|
||||||
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/data" />
|
<excludeFolder url="file://$MODULE_DIR$/data" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.mypy_cache" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.10 (tuxbot_bot)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.10 (tuxbot_bot)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
|
|
@ -3,7 +3,7 @@ from typing import Dict
|
||||||
|
|
||||||
|
|
||||||
def sort_by(_events: Counter) -> dict[str, dict]:
|
def sort_by(_events: Counter) -> dict[str, dict]:
|
||||||
majors = [
|
majors = (
|
||||||
"guild",
|
"guild",
|
||||||
"channel",
|
"channel",
|
||||||
"message",
|
"message",
|
||||||
|
@ -12,7 +12,7 @@ def sort_by(_events: Counter) -> dict[str, dict]:
|
||||||
"presence",
|
"presence",
|
||||||
"voice",
|
"voice",
|
||||||
"other",
|
"other",
|
||||||
]
|
)
|
||||||
sorted_events: Dict[str, Dict] = {m: {} for m in majors}
|
sorted_events: Dict[str, Dict] = {m: {} for m in majors}
|
||||||
|
|
||||||
for event, count in _events:
|
for event, count in _events:
|
||||||
|
|
|
@ -146,14 +146,14 @@ async def get_pydig_result(
|
||||||
|
|
||||||
|
|
||||||
def check_ip_version_or_raise(version: str) -> Union[bool, NoReturn]:
|
def check_ip_version_or_raise(version: str) -> Union[bool, NoReturn]:
|
||||||
if version in ["4", "6", "None"]:
|
if version in ("4", "6", "None"):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
raise InvalidIp(_("Invalid ip version"))
|
raise InvalidIp(_("Invalid ip version"))
|
||||||
|
|
||||||
|
|
||||||
def check_query_type_or_raise(query_type: str) -> Union[bool, NoReturn]:
|
def check_query_type_or_raise(query_type: str) -> Union[bool, NoReturn]:
|
||||||
query_types = [
|
query_types = (
|
||||||
"a",
|
"a",
|
||||||
"aaaa",
|
"aaaa",
|
||||||
"cname",
|
"cname",
|
||||||
|
@ -164,7 +164,7 @@ def check_query_type_or_raise(query_type: str) -> Union[bool, NoReturn]:
|
||||||
"txt",
|
"txt",
|
||||||
"ptr",
|
"ptr",
|
||||||
"mx",
|
"mx",
|
||||||
]
|
)
|
||||||
|
|
||||||
if query_type in query_types:
|
if query_type in query_types:
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -151,7 +151,7 @@ class Network(commands.Cog):
|
||||||
"Unable to collect information through CloudFlare",
|
"Unable to collect information through CloudFlare",
|
||||||
ctx,
|
ctx,
|
||||||
self.bot.config,
|
self.bot.config,
|
||||||
).format()
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@command_extra(name="getheaders", aliases=["headers"], deletable=True)
|
@command_extra(name="getheaders", aliases=["headers"], deletable=True)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
emotes = [chr(0x1F1E6 + i) for i in range(26)]
|
emotes = [chr(0x1F1E6 + i) for i in range(26)]
|
||||||
check = [chr(0x2714), chr(0x2716)]
|
check = (chr(0x2714), chr(0x2716))
|
||||||
|
|
||||||
|
|
||||||
def get(count):
|
def get(count):
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from .. import __version__, version_info, VersionInfo, ExitCodes
|
from .. import __version__, version_info, VersionInfo, ExitCodes
|
||||||
from .config import Config, ConfigFile
|
from .config import Config, ConfigFile
|
||||||
|
|
||||||
__all__ = [
|
__all__ = (
|
||||||
"Config",
|
"Config",
|
||||||
"ConfigFile",
|
"ConfigFile",
|
||||||
"__version__",
|
"__version__",
|
||||||
"version_info",
|
"version_info",
|
||||||
"VersionInfo",
|
"VersionInfo",
|
||||||
"ExitCodes",
|
"ExitCodes",
|
||||||
]
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@ import datetime
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from typing import List, Union
|
from typing import List, Union, Tuple
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
|
@ -33,7 +33,7 @@ from . import exceptions
|
||||||
|
|
||||||
log = logging.getLogger("tuxbot")
|
log = logging.getLogger("tuxbot")
|
||||||
|
|
||||||
packages: List[str] = [
|
packages: Tuple = (
|
||||||
"jishaku",
|
"jishaku",
|
||||||
"tuxbot.cogs.Admin",
|
"tuxbot.cogs.Admin",
|
||||||
"tuxbot.cogs.Logs",
|
"tuxbot.cogs.Logs",
|
||||||
|
@ -42,7 +42,7 @@ packages: List[str] = [
|
||||||
"tuxbot.cogs.Polls",
|
"tuxbot.cogs.Polls",
|
||||||
"tuxbot.cogs.Custom",
|
"tuxbot.cogs.Custom",
|
||||||
"tuxbot.cogs.Network",
|
"tuxbot.cogs.Network",
|
||||||
]
|
)
|
||||||
|
|
||||||
|
|
||||||
class Tux(commands.AutoShardedBot):
|
class Tux(commands.AutoShardedBot):
|
||||||
|
@ -81,7 +81,7 @@ class Tux(commands.AutoShardedBot):
|
||||||
else:
|
else:
|
||||||
kwargs["owner_ids"] = self.config.Core.owners_id
|
kwargs["owner_ids"] = self.config.Core.owners_id
|
||||||
|
|
||||||
message_cache_size = 100_000
|
message_cache_size = 10_000
|
||||||
kwargs["max_messages"] = message_cache_size
|
kwargs["max_messages"] = message_cache_size
|
||||||
self.max_messages = message_cache_size
|
self.max_messages = message_cache_size
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ class Tux(commands.AutoShardedBot):
|
||||||
|
|
||||||
if ctx is not None and ctx.valid:
|
if ctx is not None and ctx.valid:
|
||||||
if message.guild and ctx.command in search_for(
|
if message.guild and ctx.command in search_for(
|
||||||
self.config.Servers, message.guild.id, "disabled_command", []
|
self.config.Servers, message.guild.id, "disabled_command", ()
|
||||||
):
|
):
|
||||||
raise exceptions.DisabledCommandByServerOwner
|
raise exceptions.DisabledCommandByServerOwner
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,14 @@ from structured_config import (
|
||||||
ConfigFile,
|
ConfigFile,
|
||||||
)
|
)
|
||||||
|
|
||||||
__all__ = [
|
__all__ = (
|
||||||
"Config",
|
"Config",
|
||||||
"ConfigFile",
|
"ConfigFile",
|
||||||
"search_for",
|
"search_for",
|
||||||
"set_for_key",
|
"set_for_key",
|
||||||
"set_for",
|
"set_for",
|
||||||
"set_if_none",
|
"set_if_none",
|
||||||
]
|
)
|
||||||
|
|
||||||
log = logging.getLogger("tuxbot.core.config")
|
log = logging.getLogger("tuxbot.core.config")
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union, Dict, List, NoReturn, Any
|
from typing import Union, Dict, NoReturn, Any, Tuple
|
||||||
|
|
||||||
from babel.messages.pofile import read_po
|
from babel.messages.pofile import read_po
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ log = logging.getLogger("tuxbot.core.i18n")
|
||||||
|
|
||||||
_translators = []
|
_translators = []
|
||||||
|
|
||||||
available_locales: Dict[str, List[str]] = {
|
available_locales: Dict[str, Tuple] = {
|
||||||
"en-US": ["english", "anglais", "en", "us", "en-us"],
|
"en-US": ("english", "anglais", "en", "us", "en-us"),
|
||||||
"fr-FR": ["français", "francais", "french", "fr", "be", "fr-fr"],
|
"fr-FR": ("français", "francais", "french", "fr", "be", "fr-fr"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from discord.ext.commands import (
|
||||||
|
|
||||||
from tuxbot.core.utils.functions.extra import ContextPlus
|
from tuxbot.core.utils.functions.extra import ContextPlus
|
||||||
|
|
||||||
__all__ = [
|
__all__ = (
|
||||||
"bot_has_permissions",
|
"bot_has_permissions",
|
||||||
"has_permissions",
|
"has_permissions",
|
||||||
"is_owner",
|
"is_owner",
|
||||||
|
@ -18,7 +18,7 @@ __all__ = [
|
||||||
"is_admin",
|
"is_admin",
|
||||||
"check_permissions",
|
"check_permissions",
|
||||||
"guild_owner_or_permissions",
|
"guild_owner_or_permissions",
|
||||||
]
|
)
|
||||||
|
|
||||||
|
|
||||||
def is_mod():
|
def is_mod():
|
||||||
|
|
Loading…
Reference in a new issue