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 message.out
and len(message.message) > 2 and len(message.message) > 2
and message.message.startswith(prefix * 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 # Allow escaping commands using .'s
if not watcher: if not watcher:

View File

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

View File

@ -187,12 +187,11 @@ class HelpMod(loader.Module):
name = getattr(module, "name", "ERROR") name = getattr(module, "name", "ERROR")
_name = ( _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) reply = self.strings("single_mod_header").format(_name)
if module.__doc__: if module.__doc__: