main commit. bot added, admin is functional
This commit is contained in:
0
bot/management/commands/__init__.py
Normal file
0
bot/management/commands/__init__.py
Normal file
28
bot/management/commands/run_bot.py
Normal file
28
bot/management/commands/run_bot.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
import django
|
||||
from django.core.management.base import BaseCommand
|
||||
from telegram.ext import Application, CommandHandler
|
||||
from bot.handlers import start, list_users, list_hotels # Импорт обработчиков
|
||||
|
||||
# Настройка Django окружения
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'touchh.settings')
|
||||
django.setup()
|
||||
|
||||
def main():
|
||||
# Создаём приложение Telegram
|
||||
application = Application.builder().token("8125171867:AAGxDcSpQxJy3_pmq3TDBWtqaAVCj7b-F5k").build()
|
||||
|
||||
# Регистрируем обработчики команд
|
||||
application.add_handler(CommandHandler("start", start))
|
||||
application.add_handler(CommandHandler("users", list_users))
|
||||
application.add_handler(CommandHandler("hotels", list_hotels))
|
||||
|
||||
# Запускаем бота
|
||||
application.run_polling()
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Запуск Telegram бота"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.stdout.write("Запуск Telegram бота...")
|
||||
main()
|
||||
Reference in New Issue
Block a user