Prepare to bot creation #2
This commit is contained in:
parent
017c278b44
commit
1ff4f8098c
|
@ -7,4 +7,3 @@ env.read_env()
|
|||
BOT_TOKEN = env.str("BOT_TOKEN") # Забираем значение типа str
|
||||
ADMINS = env.list("ADMINS") # Тут у нас будет список из админов
|
||||
IP = env.str("ip") # Тоже str, но для айпи адреса хоста
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from . import help
|
||||
from . import start
|
||||
from . import echo
|
||||
from . import add
|
||||
from . import settings
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
from aiogram import types
|
||||
from aiogram.dispatcher.filters.builtin import Command
|
||||
|
||||
from loader import dp
|
||||
|
||||
|
||||
@dp.message_handler(commands="add")
|
||||
async def bot_add(message: types.Message):
|
||||
await message.answer(f"This is ADD command, {message.from_user.username}!")
|
|
@ -1,21 +1,21 @@
|
|||
from aiogram import types
|
||||
from aiogram.dispatcher import FSMContext
|
||||
|
||||
from loader import dp
|
||||
|
||||
|
||||
# Эхо хендлер, куда летят текстовые сообщения без указанного состояния
|
||||
@dp.message_handler(state=None)
|
||||
async def bot_echo(message: types.Message):
|
||||
await message.answer(f"Эхо без состояния."
|
||||
f"Сообщение:\n"
|
||||
f"{message.text}")
|
||||
|
||||
|
||||
# Эхо хендлер, куда летят ВСЕ сообщения с указанным состоянием
|
||||
@dp.message_handler(state="*", content_types=types.ContentTypes.ANY)
|
||||
async def bot_echo_all(message: types.Message, state: FSMContext):
|
||||
state = await state.get_state()
|
||||
await message.answer(f"Эхо в состоянии <code>{state}</code>.\n"
|
||||
f"\nСодержание сообщения:\n"
|
||||
f"<code>{message}</code>")
|
||||
# from loader import dp
|
||||
#
|
||||
#
|
||||
# # Эхо хендлер, куда летят текстовые сообщения без указанного состояния
|
||||
# @dp.message_handler(state=None)
|
||||
# async def bot_echo(message: types.Message):
|
||||
# await message.answer(f"Эхо без состояния."
|
||||
# f"Сообщение:\n"
|
||||
# f"{message.text}")
|
||||
#
|
||||
#
|
||||
# # Эхо хендлер, куда летят ВСЕ сообщения с указанным состоянием
|
||||
# @dp.message_handler(state="*", content_types=types.ContentTypes.ANY)
|
||||
# async def bot_echo_all(message: types.Message, state: FSMContext):
|
||||
# state = await state.get_state()
|
||||
# await message.answer(f"Эхо в состоянии <code>{state}</code>.\n"
|
||||
# f"\nСодержание сообщения:\n"
|
||||
# f"<code>{message}</code>")
|
||||
|
|
|
@ -6,8 +6,13 @@ from loader import dp
|
|||
|
||||
@dp.message_handler(CommandHelp())
|
||||
async def bot_help(message: types.Message):
|
||||
text = ("Список команд: ",
|
||||
"/start - Начать диалог",
|
||||
"/help - Получить справку")
|
||||
text = ("Available commands: ",
|
||||
"/start - Launch bot.",
|
||||
"/help - Commands list, little help.",
|
||||
"/add - Add expense.",
|
||||
"/edit - Edit expense.",
|
||||
"/list - See my expenses.",
|
||||
"/settings - Configure bot."
|
||||
)
|
||||
|
||||
await message.answer("\n".join(text))
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
from aiogram import types
|
||||
from aiogram.dispatcher.filters.builtin import CommandSettings
|
||||
|
||||
from loader import dp
|
||||
|
||||
|
||||
@dp.message_handler(CommandSettings())
|
||||
async def bot_settings(message: types.Message):
|
||||
await message.answer(f"Settings being here...")
|
|
@ -6,4 +6,4 @@ from loader import dp
|
|||
|
||||
@dp.message_handler(CommandStart())
|
||||
async def bot_start(message: types.Message):
|
||||
await message.answer(f"Привет, {message.from_user.full_name}!")
|
||||
await message.answer(f"Hello, {message.from_user.username}!")
|
||||
|
|
|
@ -4,7 +4,13 @@ from aiogram import types
|
|||
async def set_default_commands(dp):
|
||||
await dp.bot.set_my_commands(
|
||||
[
|
||||
types.BotCommand("start", "Start bot."),
|
||||
types.BotCommand("help", "Help."),
|
||||
types.BotCommand("start", "Launch bot."),
|
||||
types.BotCommand("help", "Commands list, little help."),
|
||||
types.BotCommand("add", "Add expense."),
|
||||
types.BotCommand("edit", "Edit expense."),
|
||||
types.BotCommand("list", "See my expenses."),
|
||||
types.BotCommand("settings", "Configure bot."),
|
||||
# types.BotCommand("settings2", "Configure bot."),
|
||||
# types.BotCommand("settings3", "Configure bot."),
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue