Traceback (most recent call last):
File "bot.py", line 66, in <module>
executor.start_polling(dp, on_startup=main)
File "/usr/local/lib/python3.8/dist-packages/aiogram/utils/executor.py", line 45, in start_polling
executor.start_polling(
File "/usr/local/lib/python3.8/dist-packages/aiogram/utils/executor.py", line 320, in start_polling
loop.run_until_complete(self._startup_polling())
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/local/lib/python3.8/dist-packages/aiogram/utils/executor.py", line 377, in _startup_polling
await callback(self.dispatcher)
File "bot.py", line 60, in main
await init_models()
File "bot.py", line 40, in init_models
async with engine.begin() as conn:
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/ext/asyncio/base.py", line 60, in __aenter__
return await self.start(is_ctxmanager=True)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/ext/asyncio/engine.py", line 609, in start
await self.conn.start(is_ctxmanager=is_ctxmanager)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/ext/asyncio/engine.py", line 154, in start
await (greenlet_spawn(self.sync_engine.connect))
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/util/_concurrency_py3k.py", line 134, in greenlet_spawn
result = context.throw(*sys.exc_info())
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/future/engine.py", line 406, in connect
return super(Engine, self).connect()
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 3204, in connect
return self._connection_cls(self, close_with_result=close_with_result)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 96, in __init__
else engine.raw_connection()
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 3283, in raw_connection
return self._wrap_pool_connect(self.pool.connect, _connection)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 3250, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 310, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 868, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 476, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/impl.py", line 146, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 256, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 371, in __init__
self.__connect()
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 666, in __connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 661, in __connect
self.dbapi_connection = connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/create.py", line 590, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/default.py", line 597, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 758, in connect
await_only(self.asyncpg.connect(*arg, **kw)),
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/util/_concurrency_py3k.py", line 76, in await_only
return current.driver.switch(awaitable)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/util/_concurrency_py3k.py", line 129, in greenlet_spawn
value = await result
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 2085, in connect
return await connect_utils._connect(
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connect_utils.py", line 895, in _connect
raise last_error
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connect_utils.py", line 881, in _connect
return await _connect_addr(
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connect_utils.py", line 781, in _connect_addr
return await __connect_addr(params, timeout, True, *args)
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connect_utils.py", line 825, in __connect_addr
tr, pr = await compat.wait_for(connector, timeout=timeout)
File "/usr/local/lib/python3.8/dist-packages/asyncpg/compat.py", line 66, in wait_for
return await asyncio.wait_for(fut, timeout)
File "/usr/lib/python3.8/asyncio/tasks.py", line 494, in wait_for
return fut.result()
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connect_utils.py", line 691, in _create_ssl_connection
tr, pr = await loop.create_connection(
File "/usr/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
raise exceptions[0]
File "/usr/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
sock = await self._connect_sock(
File "/usr/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect
return await fut
File "/usr/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 5432)
from pathlib import Path
from environs import Env
env = Env()
env.read_env()
class BotData:
bot_token: str = env.str('BOT_TOKEN')
admins: list = env.list("ADMINS")
REF_PERCENTAGE = 0.10
class PaymentApi:
QIWI_TOKEN: str = env.str("QIWI_TOKEN")
OBMENKA_KEY: str = env.str("OBMENKA_KEY")
OBMENKA_ID: str = env.str("OBMENKA_ID")
class DatabaseData:
username: str = env.str("DB_USERNAME")
password: str = env.str("DB_PASSWORD")
host: str = env.str("DB_HOST")
port: int = env.int("DB_PORT")
database: str = env.str("DB_NAME")
class ItemsCost:
COST: int = 5
class I18N:
I18N_DOMAIN = 'messages'
BASE_DIR = Path(__file__).parent.parent
LOCALES_DIR = BASE_DIR / 'locales'
class FSMPartnerbaze1(StatesGroup):
name = State()# Начало ввода почты
# @dp.message_handler(content_types=['text'], text='Марафон', state=None)
async def cm_start(message: types.Message):
await FSMPartnerbaze1.name.set()
await message.answer('Пожалуйста, укажите Вашу почту. Она нужна для корректной работы с Вами!')
print("FSM запущена")
# Ловим ответ и пишем в словарь
# @dp.message_handler(state=FSMPartnerbaze1.name) #временно для понимания
async def get_email(message: types.Message, state: FSMContext):
async with state.proxy() as data:
data['name'] = message.text
email = message.text
await state.update_data(
{'email': email}
)
regex = re.compile(r'([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')
if re.fullmatch(regex, email):
print("Valid email")
await sqlite_db.sql_add_command(state)
await state.finish()
юзер оставляет почту.
надо чтобы потмо на почту ушла серия писем.
я вижу это через crm битрикс.
в битрикс надо создать лида где в полях будет емейл юзернейм никнейм
и все. пошла рассылка автоматом.
это уже в битриксе настраивается.