- Implemented echo bot and ability to quickly modify bot commands

- reworked config to grab values from .env
- Added a requirements file(with modules needed for bot to function)
- Added a separate bot initialization file for simpler launching
This commit is contained in:
2025-07-24 00:53:13 +03:00
parent fdcad46ace
commit 977d25538d
7 changed files with 61 additions and 10 deletions

BIN
requirements.txt Normal file

Binary file not shown.

View File

@ -1,7 +1,8 @@
from minio import Minio from minio import Minio
from random import randint from random import randint
import DBwork import DBwork
import config from src import config
def _setClient(): def _setClient():
minio_client = Minio( minio_client = Minio(

View File

@ -1,8 +0,0 @@
IS_address = "localhost:9000"
acc_key = "minioadmin"
sec_key = "minioadmin"
db_name = "postgres_db"
postgres_user = "postgres_user"
postgres_password = "postgres_password"
host_name = "localhost"
port = "5430"

View File

@ -1,5 +1,6 @@
import psycopg2 import psycopg2
import config from src import config
def _get_last_id(cursor): def _get_last_id(cursor):
cursor.execute("SELECT MAX(id) FROM usernames") cursor.execute("SELECT MAX(id) FROM usernames")

37
src/Frontend/createbot.py Normal file
View File

@ -0,0 +1,37 @@
from src import config
import asyncio
import logging
from aiogram import Bot, Dispatcher, F, Router
from aiogram.filters import Command
from aiogram.types import Message
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
from aiogram.fsm.storage.memory import MemoryStorage
from apscheduler.schedulers.asyncio import AsyncIOScheduler
start_router = Router()
scheduler = AsyncIOScheduler(timezone = 'Europe/Moscow')
logging.basicConfig(level = logging.INFO, format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
bot = Bot(token = config.TG_TOKEN , default = DefaultBotProperties(parse_mode = ParseMode.HTML))
dp = Dispatcher(storage = MemoryStorage())
@dp.message(Command('start'))
async def cmd_start(message: Message):
await message.answer('Запуск сообщения по команде /start используя фильтр CommandStart()')
@dp.message(F.text)
async def basic_reaction(message: Message):
if message.text != '':
await message.answer(message.text)
async def main():
await dp.start_polling(bot)

5
src/__main__.py Normal file
View File

@ -0,0 +1,5 @@
import asyncio
from Frontend.createbot import main
asyncio.run(main())

15
src/config.py Normal file
View File

@ -0,0 +1,15 @@
from decouple import config
IS_address = config('IS_address')
acc_key = config('acc_key')
sec_key = config('sec_key')
db_name = config('db_name')
postgres_user = config('postgres_user')
postgres_password = config('postgres_password')
host_name = config('host_name')
port = config('port')
TG_TOKEN = config('TG_TOKEN')
# ADMINS = [int(admin_id) for admin_id in config('ADMINS').split(',')]