Import statements refactored
This commit is contained in:
parent
773fe1fdb1
commit
fda4cac348
@ -15,8 +15,8 @@ __version__ = "2.6.19"
|
|||||||
__maintainer__ = "Davide Testa"
|
__maintainer__ = "Davide Testa"
|
||||||
__contact__ = "t.me/davte"
|
__contact__ = "t.me/davte"
|
||||||
|
|
||||||
from . import (administration_tools, authorization, bot, helper, languages,
|
from . import (administration_tools, api, authorization, bot, helper, languages,
|
||||||
suggestions, useful_tools, utilities)
|
messages, suggestions, useful_tools, utilities)
|
||||||
|
|
||||||
__all__ = [administration_tools, authorization, bot, helper, languages,
|
__all__ = [administration_tools, api, authorization, bot, helper, languages,
|
||||||
suggestions, useful_tools, utilities]
|
messages, suggestions, useful_tools, utilities]
|
||||||
|
@ -23,7 +23,7 @@ from typing import Union, List, Tuple
|
|||||||
from sqlalchemy.exc import ResourceClosedError
|
from sqlalchemy.exc import ResourceClosedError
|
||||||
|
|
||||||
# Project modules
|
# Project modules
|
||||||
from . import messages
|
from .messages import default_admin_messages, default_talk_messages
|
||||||
from .bot import Bot
|
from .bot import Bot
|
||||||
from .utilities import (
|
from .utilities import (
|
||||||
async_wrapper, CachedPage, Confirmator, extract, get_cleaned_text,
|
async_wrapper, CachedPage, Confirmator, extract, get_cleaned_text,
|
||||||
@ -362,7 +362,10 @@ async def _talk_button(bot: Bot,
|
|||||||
len(arguments) < 1
|
len(arguments) < 1
|
||||||
or type(arguments[0]) is not int
|
or type(arguments[0]) is not int
|
||||||
):
|
):
|
||||||
result = "Errore!"
|
result = bot.get_message(
|
||||||
|
'talk', 'error', 'text',
|
||||||
|
update=update, user_record=user_record
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
with bot.db as db:
|
with bot.db as db:
|
||||||
other_user_record = db['users'].find_one(
|
other_user_record = db['users'].find_one(
|
||||||
@ -381,7 +384,10 @@ async def _talk_button(bot: Bot,
|
|||||||
len(arguments) < 1
|
len(arguments) < 1
|
||||||
or type(arguments[0]) is not int
|
or type(arguments[0]) is not int
|
||||||
):
|
):
|
||||||
result = "Errore!"
|
result = bot.get_message(
|
||||||
|
'talk', 'error', 'text',
|
||||||
|
update=update, user_record=user_record
|
||||||
|
)
|
||||||
elif not Confirmator.get('stop_bots').confirm(telegram_id):
|
elif not Confirmator.get('stop_bots').confirm(telegram_id):
|
||||||
result = bot.get_message(
|
result = bot.get_message(
|
||||||
'talk', 'end_session',
|
'talk', 'end_session',
|
||||||
@ -1705,7 +1711,7 @@ async def _father_button(bot: Bot, user_record: OrderedDict,
|
|||||||
prefix='father:///',
|
prefix='father:///',
|
||||||
delimiter='|',
|
delimiter='|',
|
||||||
data=['settings', 'edit', 'select',
|
data=['settings', 'edit', 'select',
|
||||||
selected_record['id'], 'edit_descr']
|
selected_record['id'], 'edit_description']
|
||||||
),
|
),
|
||||||
make_button(
|
make_button(
|
||||||
text=bot.get_message(
|
text=bot.get_message(
|
||||||
@ -1731,7 +1737,7 @@ async def _father_button(bot: Bot, user_record: OrderedDict,
|
|||||||
],
|
],
|
||||||
2
|
2
|
||||||
)
|
)
|
||||||
elif len(data) > 3 and data[3] == 'edit_descr':
|
elif len(data) > 3 and data[3] == 'edit_description':
|
||||||
result, text, reply_markup = await edit_bot_father_settings_via_message(
|
result, text, reply_markup = await edit_bot_father_settings_via_message(
|
||||||
bot=bot,
|
bot=bot,
|
||||||
user_record=user_record,
|
user_record=user_record,
|
||||||
@ -1812,10 +1818,10 @@ def init(telegram_bot: Bot,
|
|||||||
)
|
)
|
||||||
asyncio.ensure_future(get_package_updates(telegram_bot))
|
asyncio.ensure_future(get_package_updates(telegram_bot))
|
||||||
if talk_messages is None:
|
if talk_messages is None:
|
||||||
talk_messages = messages.default_talk_messages
|
talk_messages = default_talk_messages
|
||||||
telegram_bot.messages['talk'] = talk_messages
|
telegram_bot.messages['talk'] = talk_messages
|
||||||
if admin_messages is None:
|
if admin_messages is None:
|
||||||
admin_messages = messages.default_admin_messages
|
admin_messages = default_admin_messages
|
||||||
telegram_bot.messages['admin'] = admin_messages
|
telegram_bot.messages['admin'] = admin_messages
|
||||||
db = telegram_bot.db
|
db = telegram_bot.db
|
||||||
if 'bot_father_commands' not in db.tables:
|
if 'bot_father_commands' not in db.tables:
|
||||||
|
@ -10,7 +10,7 @@ import aiohttp
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
# Project modules
|
# Project modules
|
||||||
from . import api
|
from .api import TelegramBot
|
||||||
|
|
||||||
api_url = "https://core.telegram.org/bots/api"
|
api_url = "https://core.telegram.org/bots/api"
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ async def print_api_methods(loop=None,
|
|||||||
"""Get information from Telegram bot API web page."""
|
"""Get information from Telegram bot API web page."""
|
||||||
if loop is None:
|
if loop is None:
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
implemented_methods = dir(api.TelegramBot)
|
implemented_methods = dir(TelegramBot)
|
||||||
async with aiohttp.ClientSession(
|
async with aiohttp.ClientSession(
|
||||||
loop=loop,
|
loop=loop,
|
||||||
timeout=aiohttp.ClientTimeout(
|
timeout=aiohttp.ClientTimeout(
|
||||||
|
@ -3225,9 +3225,14 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
|
|||||||
and 'photos' in user_profile_photos
|
and 'photos' in user_profile_photos
|
||||||
and len(user_profile_photos['photos'])):
|
and len(user_profile_photos['photos'])):
|
||||||
current_photo = user_profile_photos['photos'][0][0]
|
current_photo = user_profile_photos['photos'][0][0]
|
||||||
if (user_picture_record is None
|
if (
|
||||||
or current_photo['file_id']
|
user_picture_record is None
|
||||||
!= user_picture_record['telegram_file_id']):
|
or (
|
||||||
|
isinstance(user_picture_record, dict)
|
||||||
|
and current_photo['file_id']
|
||||||
|
!= user_picture_record['telegram_file_id']
|
||||||
|
)
|
||||||
|
):
|
||||||
db['user_profile_photos'].insert(dict(
|
db['user_profile_photos'].insert(dict(
|
||||||
user_id=user_record['id'],
|
user_id=user_record['id'],
|
||||||
telegram_file_id=current_photo['file_id'],
|
telegram_file_id=current_photo['file_id'],
|
||||||
|
@ -985,6 +985,12 @@ default_talk_messages = {
|
|||||||
'en': 'End session?',
|
'en': 'End session?',
|
||||||
'it': 'Chiudere la sessione?',
|
'it': 'Chiudere la sessione?',
|
||||||
},
|
},
|
||||||
|
'error': {
|
||||||
|
'text': {
|
||||||
|
'en': "❌️ Error!",
|
||||||
|
'it': "❌️ Errore!"
|
||||||
|
},
|
||||||
|
},
|
||||||
'help_text': {
|
'help_text': {
|
||||||
'en': 'Press the button to search for user.',
|
'en': 'Press the button to search for user.',
|
||||||
'it': 'Premi il pulsante per scegliere un utente.',
|
'it': 'Premi il pulsante per scegliere un utente.',
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
aiohttp
|
aiohttp
|
||||||
bs4
|
bs4
|
||||||
dataset
|
dataset
|
||||||
|
beautifulsoup4
|
||||||
|
SQLAlchemy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user