removed files
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -1,6 +0,0 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BotConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'bot'
|
||||
39
bot/bot.py
39
bot/bot.py
@@ -1,39 +0,0 @@
|
||||
from telegram import Update
|
||||
from telegram.ext import Updater, CommandHandler, CallbackContext
|
||||
from users.models import User, UserConfirmation
|
||||
import uuid
|
||||
|
||||
def start(update: Update, context: CallbackContext):
|
||||
user_id = update.message.from_user.id
|
||||
chat_id = update.message.chat_id
|
||||
|
||||
user, created = User.objects.get_or_create(telegram_id=user_id, defaults={'chat_id': chat_id})
|
||||
if not user.confirmed:
|
||||
confirmation_code = str(uuid.uuid4())
|
||||
UserConfirmation.objects.create(user=user, confirmation_code=confirmation_code)
|
||||
update.message.reply_text(f"Ваш код подтверждения: {confirmation_code}")
|
||||
else:
|
||||
update.message.reply_text("Вы уже зарегистрированы!")
|
||||
|
||||
def confirm(update: Update, context: CallbackContext):
|
||||
user_id = update.message.from_user.id
|
||||
code = ' '.join(context.args)
|
||||
|
||||
try:
|
||||
confirmation = UserConfirmation.objects.get(user__telegram_id=user_id, confirmation_code=code)
|
||||
confirmation.user.confirmed = True
|
||||
confirmation.user.save()
|
||||
confirmation.delete()
|
||||
update.message.reply_text("Регистрация подтверждена!")
|
||||
except UserConfirmation.DoesNotExist:
|
||||
update.message.reply_text("Неверный код подтверждения!")
|
||||
|
||||
def main():
|
||||
updater = Updater("YOUR_TELEGRAM_BOT_TOKEN")
|
||||
dispatcher = updater.dispatcher
|
||||
|
||||
dispatcher.add_handler(CommandHandler("start", start))
|
||||
dispatcher.add_handler(CommandHandler("confirm", confirm))
|
||||
|
||||
updater.start_polling()
|
||||
updater.idle()
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user