Merge pull request #56 from hikariatama/sourcery/v1.3.0

V1.3.0 (Sourcery refactored)
pull/1/head
Dan Gazizullin 2022-08-03 21:49:46 +03:00 committed by GitHub
commit 7627caeb86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 19 deletions

View File

@ -249,7 +249,7 @@ class CommandDispatcher:
message.out
and len(message.message) > 2
and message.message.startswith(prefix * 2)
and not all(s == prefix for s in message.message)
and any(s != prefix for s in message.message)
):
# Allow escaping commands using .'s
if not watcher:

View File

@ -764,7 +764,7 @@ class Modules:
strict=True,
).values():
with contextlib.suppress(AttributeError, ValueError):
existing_watcher = next(
if existing_watcher := next(
(
existing_watcher
for existing_watcher in self.watchers
@ -775,9 +775,7 @@ class Modules:
)
),
None,
)
if existing_watcher:
):
logger.debug(f"Removing watcher for update {existing_watcher}")
self.watchers.remove(existing_watcher)
@ -799,10 +797,7 @@ class Modules:
@property
def get_approved_channel(self):
if not self.__approve:
return None
return self.__approve.pop(0)
return self.__approve.pop(0) if self.__approve else None
async def _approve(
self,
@ -1061,11 +1056,12 @@ class Modules:
ver = tuple(
map(
int,
re.search(r"# ?scope: ?hikka_min ((\d+\.){2}\d+)", code)
.group(1)
.split("."),
re.search(r"# ?scope: ?hikka_min ((\d+\.){2}\d+)", code)[
1
].split("."),
)
)
if version.__version__ < ver:
_raise(
RuntimeError(
@ -1149,8 +1145,9 @@ class Modules:
_raise(ImportError("Invalid library. Class name must end with 'Lib'"))
if (
not any(
line.replace(" ", "") == "#scope:no_stats" for line in code.splitlines()
all(
line.replace(" ", "") != "#scope:no_stats"
for line in code.splitlines()
)
and self._db.get("hikka.main", "stats", True)
and url is not None

View File

@ -187,13 +187,12 @@ class HelpMod(loader.Module):
name = getattr(module, "name", "ERROR")
_name = (
utils.escape_html(name)
if not hasattr(module, "__version__")
else (
f"{utils.escape_html(name)} (v{module.__version__[0]}.{module.__version__[1]}.{module.__version__[2]})"
)
f"{utils.escape_html(name)} (v{module.__version__[0]}.{module.__version__[1]}.{module.__version__[2]})"
if hasattr(module, "__version__")
else utils.escape_html(name)
)
reply = self.strings("single_mod_header").format(_name)
if module.__doc__:
reply += "<i>\n " + utils.escape_html(inspect.getdoc(module)) + "\n</i>"