aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bot.py (renamed from bot/bot.py)14
-rw-r--r--bot/__init__.py13
-rw-r--r--bot/admin.py5
-rw-r--r--bot/apps.py6
-rw-r--r--bot/migrations/0001_initial.py44
-rw-r--r--bot/migrations/__init__.py0
-rw-r--r--bot/models.py9
-rw-r--r--bot/tests.py3
-rw-r--r--bot/urls.py7
-rw-r--r--bot/views.py5
-rw-r--r--checkin/settings.py2
-rw-r--r--checkin/urls.py3
12 files changed, 97 insertions, 14 deletions
diff --git a/bot/bot.py b/bot.py
index 2710184..c2e102d 100644
--- a/bot/bot.py
+++ b/bot.py
@@ -5,6 +5,20 @@
5import logging 5import logging
6import io 6import io
7import telegram.constants 7import telegram.constants
8from telegram import __version__ as TG_VER
9
10try:
11 from telegram import __version_info__
12except ImportError:
13 __version_info__ = (0, 0, 0, 0, 0) # type: ignore[assignment]
14
15if __version_info__ < (20, 0, 0, "alpha", 1):
16 raise RuntimeError(
17 f"This example is not compatible with your current PTB version {TG_VER}. To view the "
18 f"{TG_VER} version of this example, "
19 f"visit https://docs.python-telegram-bot.org/en/v{TG_VER}/examples.html"
20 )
21
8from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, ReplyKeyboardMarkup, KeyboardButton 22from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, ReplyKeyboardMarkup, KeyboardButton
9from telegram.ext import Application, CallbackQueryHandler, CommandHandler, ContextTypes, MessageHandler, filters, ConversationHandler, CallbackContext 23from telegram.ext import Application, CallbackQueryHandler, CommandHandler, ContextTypes, MessageHandler, filters, ConversationHandler, CallbackContext
10from ..config import BOT_TOKEN 24from ..config import BOT_TOKEN
diff --git a/bot/__init__.py b/bot/__init__.py
index 5e3c341..e69de29 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -1,13 +0,0 @@
1from telegram import __version__ as TG_VER
2
3try:
4 from telegram import __version_info__
5except ImportError:
6 __version_info__ = (0, 0, 0, 0, 0) # type: ignore[assignment]
7
8if __version_info__ < (20, 0, 0, "alpha", 1):
9 raise RuntimeError(
10 f"This example is not compatible with your current PTB version {TG_VER}. To view the "
11 f"{TG_VER} version of this example, "
12 f"visit https://docs.python-telegram-bot.org/en/v{TG_VER}/examples.html"
13 )
diff --git a/bot/admin.py b/bot/admin.py
new file mode 100644
index 0000000..f91be8f
--- /dev/null
+++ b/bot/admin.py
@@ -0,0 +1,5 @@
1from django.contrib import admin
2from django.contrib.auth.admin import UserAdmin
3from .models import User
4
5admin.site.register(User, UserAdmin)
diff --git a/bot/apps.py b/bot/apps.py
new file mode 100644
index 0000000..1cd7ff2
--- /dev/null
+++ b/bot/apps.py
@@ -0,0 +1,6 @@
1from django.apps import AppConfig
2
3
4class BotConfig(AppConfig):
5 default_auto_field = 'django.db.models.BigAutoField'
6 name = 'bot'
diff --git a/bot/migrations/0001_initial.py b/bot/migrations/0001_initial.py
new file mode 100644
index 0000000..6b4f210
--- /dev/null
+++ b/bot/migrations/0001_initial.py
@@ -0,0 +1,44 @@
1# Generated by Django 4.1.7 on 2023-02-22 00:44
2
3import django.contrib.auth.models
4from django.db import migrations, models
5import django.utils.timezone
6
7
8class Migration(migrations.Migration):
9
10 initial = True
11
12 dependencies = [
13 ('auth', '0012_alter_user_first_name_max_length'),
14 ]
15
16 operations = [
17 migrations.CreateModel(
18 name='User',
19 fields=[
20 ('password', models.CharField(max_length=128, verbose_name='password')),
21 ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
22 ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
23 ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
24 ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
25 ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
26 ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
27 ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
28 ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
29 ('name', models.CharField(blank=True, max_length=50)),
30 ('telegram_id', models.PositiveBigIntegerField(primary_key=True, serialize=False, unique=True)),
31 ('username', models.CharField(max_length=32)),
32 ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
33 ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
34 ],
35 options={
36 'verbose_name': 'user',
37 'verbose_name_plural': 'users',
38 'abstract': False,
39 },
40 managers=[
41 ('objects', django.contrib.auth.models.UserManager()),
42 ],
43 ),
44 ]
diff --git a/bot/migrations/__init__.py b/bot/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/bot/migrations/__init__.py
diff --git a/bot/models.py b/bot/models.py
new file mode 100644
index 0000000..c6df3e7
--- /dev/null
+++ b/bot/models.py
@@ -0,0 +1,9 @@
1from django.contrib.auth.models import AbstractUser
2from django.db import models
3
4
5class User(AbstractUser):
6 name = models.CharField(max_length=50, blank=True)
7 telegram_id = models.PositiveBigIntegerField(unique=True, primary_key=True)
8 username = models.CharField(max_length=32, blank=False)
9 USERNAME_FIELD = 'telegram_id'
diff --git a/bot/tests.py b/bot/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/bot/tests.py
@@ -0,0 +1,3 @@
1from django.test import TestCase
2
3# Create your tests here.
diff --git a/bot/urls.py b/bot/urls.py
new file mode 100644
index 0000000..88a9cac
--- /dev/null
+++ b/bot/urls.py
@@ -0,0 +1,7 @@
1from django.urls import path
2
3from . import views
4
5urlpatterns = [
6 path('', views.index, name='index'),
7]
diff --git a/bot/views.py b/bot/views.py
new file mode 100644
index 0000000..963b6f7
--- /dev/null
+++ b/bot/views.py
@@ -0,0 +1,5 @@
1from django.http import HttpResponse
2
3
4def index(request):
5 return HttpResponse("Hello, world. You're at the polls index.")
diff --git a/checkin/settings.py b/checkin/settings.py
index 6fa12a2..8d74770 100644
--- a/checkin/settings.py
+++ b/checkin/settings.py
@@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
31# Application definition 31# Application definition
32 32
33INSTALLED_APPS = [ 33INSTALLED_APPS = [
34 'bot.apps.BotConfig',
34 'django.contrib.admin', 35 'django.contrib.admin',
35 'django.contrib.auth', 36 'django.contrib.auth',
36 'django.contrib.contenttypes', 37 'django.contrib.contenttypes',
@@ -99,6 +100,7 @@ AUTH_PASSWORD_VALIDATORS = [
99 }, 100 },
100] 101]
101 102
103AUTH_USER_MODEL = 'bot.User'
102 104
103# Internationalization 105# Internationalization
104# https://docs.djangoproject.com/en/4.1/topics/i18n/ 106# https://docs.djangoproject.com/en/4.1/topics/i18n/
diff --git a/checkin/urls.py b/checkin/urls.py
index a173748..4f9cbe8 100644
--- a/checkin/urls.py
+++ b/checkin/urls.py
@@ -14,8 +14,9 @@ Including another URLconf
14 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 14 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15""" 15"""
16from django.contrib import admin 16from django.contrib import admin
17from django.urls import path 17from django.urls import path, include
18 18
19urlpatterns = [ 19urlpatterns = [
20 path('bot/', include('bot.urls')),
20 path('admin/', admin.site.urls), 21 path('admin/', admin.site.urls),
21] 22]
Powered by cgit v1.2.3 (git 2.41.0)