Merge branch 'develop' of ssh://gogs.davte.it:8445/Davte/davtelepot into develop
This commit is contained in:
commit
04699d0dd7
@ -14,7 +14,7 @@ __author__ = "Davide Testa"
|
||||
__email__ = "davide@davte.it"
|
||||
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
|
||||
__license__ = "GNU General Public License v3.0"
|
||||
__version__ = "2.4.20"
|
||||
__version__ = "2.4.23"
|
||||
__maintainer__ = "Davide Testa"
|
||||
__contact__ = "t.me/davte"
|
||||
|
||||
|
@ -18,7 +18,8 @@ from aiohttp import web
|
||||
class TelegramError(Exception):
|
||||
"""Telegram API exceptions class."""
|
||||
|
||||
def __init__(self, error_code=0, description=None):
|
||||
def __init__(self, error_code=0, description=None, ok=False,
|
||||
*args, **kwargs):
|
||||
"""Get an error response and return corresponding Exception."""
|
||||
self._code = error_code
|
||||
if description is None:
|
||||
|
@ -235,6 +235,16 @@ def get_authorization_function(bot):
|
||||
|
||||
def is_authorized(update, user_record=None, authorization_level=2):
|
||||
"""Return True if user role is at least at `authorization_level`."""
|
||||
if user_record is None:
|
||||
if (
|
||||
isinstance(update, dict)
|
||||
and 'from' in update
|
||||
and isinstance(update['from'], dict)
|
||||
and 'id' in update['from']
|
||||
):
|
||||
user_record = bot.db['users'].find_one(
|
||||
telegram_id=update['from']['id']
|
||||
)
|
||||
user_role = bot.Role.get_user_role(user_record=user_record)
|
||||
if user_role.code == 0:
|
||||
return False
|
||||
|
@ -607,6 +607,32 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
|
||||
if 'switch_pm_parameter' in results:
|
||||
switch_pm_parameter = results['switch_pm_parameter']
|
||||
results = results['answer']
|
||||
for result in results:
|
||||
if (
|
||||
isinstance(result, dict)
|
||||
and isinstance(result['title'], dict)
|
||||
):
|
||||
result['title'] = self.get_message(
|
||||
update=update,
|
||||
user_record=user_record,
|
||||
messages=result['title']
|
||||
)
|
||||
if (
|
||||
isinstance(result, dict)
|
||||
and 'input_message_content' in result
|
||||
and isinstance(result['input_message_content'], dict)
|
||||
and 'message_text' in result['input_message_content']
|
||||
and isinstance(
|
||||
result['input_message_content']['message_text'],
|
||||
dict
|
||||
)
|
||||
):
|
||||
result['input_message_content'][
|
||||
'message_text'] = self.get_message(
|
||||
update=update,
|
||||
user_record=user_record,
|
||||
messages=result['input_message_content']['message_text']
|
||||
)
|
||||
try:
|
||||
await self.answer_inline_query(
|
||||
update=update,
|
||||
|
@ -249,8 +249,8 @@ default_admin_messages = {
|
||||
'result': {
|
||||
'en': "Last commit: {last_commit}\n"
|
||||
"davtelepot version: {davtelepot_version}",
|
||||
'it': "Ultimo commit: {last_commit}"
|
||||
"Version di davtelepot: {davtelepot_version}",
|
||||
'it': "Ultimo commit: {last_commit}\n"
|
||||
"Versione di davtelepot: {davtelepot_version}",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user