@@ -23,8 +23,8 @@ from mautrix.bridge.commands import (HelpSection, CommandEvent as BaseCommandEve
|
||||
CommandHandler as BaseCommandHandler,
|
||||
CommandProcessor as BaseCommandProcessor,
|
||||
CommandHandlerFunc, command_handler as base_command_handler)
|
||||
from mautrix.util.format_duration import format_duration
|
||||
|
||||
from ..util import format_duration
|
||||
from .. import user as u, context as c, portal as po
|
||||
|
||||
|
||||
@@ -77,10 +77,11 @@ class CommandHandler(BaseCommandHandler):
|
||||
def __init__(self, handler: Callable[[CommandEvent], Awaitable[EventID]],
|
||||
management_only: bool, name: str, help_text: str, help_args: str,
|
||||
help_section: HelpSection, needs_auth: bool, needs_puppeting: bool,
|
||||
needs_matrix_puppeting: bool, needs_admin: bool) -> None:
|
||||
needs_matrix_puppeting: bool, needs_admin: bool, **kwargs) -> None:
|
||||
super().__init__(handler, management_only, name, help_text, help_args, help_section,
|
||||
needs_auth=needs_auth, needs_puppeting=needs_puppeting,
|
||||
needs_matrix_puppeting=needs_matrix_puppeting, needs_admin=needs_admin)
|
||||
needs_matrix_puppeting=needs_matrix_puppeting, needs_admin=needs_admin,
|
||||
**kwargs)
|
||||
|
||||
async def get_permission_error(self, evt: CommandEvent) -> Optional[str]:
|
||||
if self.needs_puppeting and not evt.sender.puppet_whitelisted:
|
||||
|
||||
@@ -27,11 +27,11 @@ from telethon.tl.types import User
|
||||
|
||||
from mautrix.types import (EventID, UserID, MediaMessageEventContent, ImageInfo, MessageType,
|
||||
TextMessageEventContent)
|
||||
from mautrix.util.format_duration import format_duration as fmt_duration
|
||||
|
||||
from ... import user as u
|
||||
from ...types import TelegramID
|
||||
from ...commands import command_handler, CommandEvent, SECTION_AUTH
|
||||
from ...util import format_duration as fmt_duration
|
||||
|
||||
try:
|
||||
import qrcode
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from .file_transfer import transfer_file_to_matrix, convert_image
|
||||
from .parallel_file_transfer import parallel_transfer_to_telegram
|
||||
from .format_duration import format_duration
|
||||
from .recursive_dict import recursive_del, recursive_set, recursive_get
|
||||
from .color_log import ColorFormatter
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
# mautrix-telegram - A Matrix-Telegram puppeting bridge
|
||||
# Copyright (C) 2019 Tulir Asokan
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
def format_duration(seconds: int) -> str:
|
||||
def pluralize(count: int, singular: str) -> str:
|
||||
return singular if count == 1 else singular + "s"
|
||||
|
||||
def include(count: int, word: str) -> str:
|
||||
return f"{count} {pluralize(count, word)}" if count > 0 else ""
|
||||
|
||||
minutes, seconds = divmod(seconds, 60)
|
||||
hours, minutes = divmod(minutes, 60)
|
||||
days, hours = divmod(hours, 24)
|
||||
parts = [a for a in [
|
||||
include(days, "day"),
|
||||
include(hours, "hour"),
|
||||
include(minutes, "minute"),
|
||||
include(seconds, "second")] if a]
|
||||
if len(parts) > 2:
|
||||
return "{} and {}".format(", ".join(parts[:-1]), parts[-1])
|
||||
return " and ".join(parts)
|
||||
@@ -24,9 +24,9 @@ from aiohttp import web
|
||||
from telethon.errors import *
|
||||
|
||||
from mautrix.bridge import OnlyLoginSelf, InvalidAccessToken
|
||||
from mautrix.util.format_duration import format_duration
|
||||
|
||||
from ...commands.telegram.auth import enter_password
|
||||
from ...util import format_duration
|
||||
from ...puppet import Puppet
|
||||
from ...user import User
|
||||
|
||||
|
||||
@@ -27,4 +27,4 @@ aiosqlite>=0.17,<0.18
|
||||
#/e2be
|
||||
python-olm>=3,<4
|
||||
pycryptodome>=3,<4
|
||||
unpaddedbase64>=1,<2
|
||||
unpaddedbase64>=1,<3
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ python-magic>=0.4,<0.5
|
||||
commonmark>=0.8,<0.10
|
||||
aiohttp>=3,<4
|
||||
yarl>=1,<2
|
||||
mautrix>=0.13rc1,<0.14
|
||||
mautrix>=0.13.1,<0.14
|
||||
telethon>=1.24,<1.25
|
||||
telethon-session-sqlalchemy>=0.2.14,<0.3
|
||||
# Temporarily always depend on aiosqlite to prevent breaking old installs
|
||||
|
||||
Reference in New Issue
Block a user