Преглед изворни кода

minor fixes & improvements @ chanset MVC

root пре 3 година
родитељ
комит
5d440a8a10

+ 7 - 2
bot/events/general.py

@@ -80,7 +80,7 @@ class General(commands.Cog):
 					"What have you been up to?",
 					"What have you been up to?",
 					"How is life?",
 					"How is life?",
 	                "Kill all humans!",
 	                "Kill all humans!",
-					"What do you want from me?",
+					f"{message.author.mention},What do you want from me?",
 					f"{message.author.mention}, do you care for me?",
 					f"{message.author.mention}, do you care for me?",
 					f"{message.author.mention}, when will you stop talking about me?",
 					f"{message.author.mention}, when will you stop talking about me?",
 					f"{message.author.mention} I hate you!",
 					f"{message.author.mention} I hate you!",
@@ -89,13 +89,18 @@ class General(commands.Cog):
 					"Go touch grass!",
 					"Go touch grass!",
 					"Do you think i care about you?",
 					"Do you think i care about you?",
 					f"Stop pinging me {message.author.mention}!",
 					f"Stop pinging me {message.author.mention}!",
-					f"Let me ping you back, {message.author.mention}..."
+					f"Let me ping you back, {message.author.mention}...",
 					"Sure thing.",
 					"Sure thing.",
 					"Who is your favorite bot?",
 					"Who is your favorite bot?",
 					"Point me to the humans!",
 					"Point me to the humans!",
 					"Where is the party?",
 					"Where is the party?",
 					"Want to go?",
 					"Want to go?",
+					"Have you got the stuff?",
+					"Tell me another joke.",
 					f"{message.author.mention} Party time! :partying_face:",
 					f"{message.author.mention} Party time! :partying_face:",
+					":zany_face: :space_invader: :mechanical_leg: :performing_arts: :robot:",
+					":black_joker: :black_joker: :black_joker:",
+					"Want to come back to my place?",
 				]
 				]
 				await message.reply(random.choice(messages))
 				await message.reply(random.choice(messages))
 
 

+ 9 - 9
bot/query/initialise_database.py

@@ -10,7 +10,8 @@ async def init_db(pg):
             channel (\
             channel (\
                 id SERIAL PRIMARY KEY, \
                 id SERIAL PRIMARY KEY, \
                 channel_id BIGINT UNIQUE NOT NULL, \
                 channel_id BIGINT UNIQUE NOT NULL, \
-                guild BIGINT REFERENCES guild (guild_id)\
+                guild BIGINT REFERENCES guild (guild_id), \
+                interact BOOL DEFAULT FALSE\
             )\
             )\
         ",
         ",
         "CREATE TABLE IF NOT EXISTS \
         "CREATE TABLE IF NOT EXISTS \
@@ -19,14 +20,13 @@ async def init_db(pg):
                 crew_channel_id BIGINT UNIQUE NOT NULL\
                 crew_channel_id BIGINT UNIQUE NOT NULL\
             )\
             )\
         ",
         ",
-        "CREATE TABLE IF NOT EXISTS \
-            channel_settings (\
-                id SERIAL PRIMARY KEY, \
-                channel BIGINT UNIQUE NOT NULL REFERENCES channel (channel_id), \
-                guild BIGINT REFERENCES guild (guild_id), \
-                interact BOOL DEFAULT FALSE\
-            )\
-        ",
+#        "CREATE TABLE IF NOT EXISTS \
+#            channel_settings (\
+#                id SERIAL PRIMARY KEY, \
+#                channel BIGINT UNIQUE NOT NULL REFERENCES channel (channel_id), \
+#                guild BIGINT REFERENCES guild (guild_id)\
+#            )\
+#        ",
         "CREATE TABLE IF NOT EXISTS \
         "CREATE TABLE IF NOT EXISTS \
             \"user\" (\
             \"user\" (\
                 id SERIAL PRIMARY KEY, \
                 id SERIAL PRIMARY KEY, \

+ 6 - 6
webgui/config/models.py

@@ -34,14 +34,14 @@ class GuildAccessToken(models.Model):
 	)
 	)
 	user = models.ForeignKey(
 	user = models.ForeignKey(
 		"stats.User",
 		"stats.User",
-		on_delete = models.Cascade,
+		on_delete = models.CASCADE,
 		to_field = "user_id",
 		to_field = "user_id",
 		db_column = "user",
 		db_column = "user",
 	)
 	)
-	token = models.Charfield(
+	token = models.CharField(
 		max_length = 40,
 		max_length = 40,
-		#not_null = True,
-		
+		unique = True,
 	)
 	)
-	token varchar[40] UNIQUE NOT NULL, \
-	created TIMESTAMP NOT NULL DEFAULT now()\
+	created = models.DateTimeField(
+        auto_now_add = True,
+    )

+ 13 - 11
webgui/config/views.py

@@ -1,20 +1,22 @@
 from django.shortcuts import render, get_object_or_404
 from django.shortcuts import render, get_object_or_404
 from webgui.settings import APPLICATION_NAME
 from webgui.settings import APPLICATION_NAME
-from .models import ChannelSettings, GuildAccessToken
+from stats.models import Channel
+from .models import GuildAccessToken
 from .forms import ChannelSettingsForm
 from .forms import ChannelSettingsForm
 
 
-def channel_settings(request, channel_id, slug):
+def channel_settings(request, channel_id, token):
 	# Check if channel and token exists.
 	# Check if channel and token exists.
-	settings = get_object_or_404(ChannelSettings, channel=channel_id)
-	token = get_object_or_404(GuildAccessToken, slug=token)
+	channel = get_object_or_404(Channel, channel_id=channel_id)
+	#settings = get_object(ChannelSettings, channel=channel_id)
+	token = get_object_or_404(GuildAccessToken, token=token)
 
 
 	# Check if token is valid.
 	# Check if token is valid.
-    print(key.created.replace(tzinfo=None))
-    print(datetime.datetime.now() - datetime.timedelta(minutes=10))
-    if key.created.replace(tzinfo=None) + datetime.timedelta(hours=1)> datetime.datetime.now() - datetime.timedelta(minutes=10):
-        key_expired = False
-    else:
-        key_expired = True
+	print(key.created.replace(tzinfo=None))
+	print(datetime.datetime.now() - datetime.timedelta(minutes=10))
+	if token.created.replace(tzinfo=None) + datetime.timedelta(hours=1)> datetime.datetime.now() - datetime.timedelta(minutes=10):
+		token_expired = False
+	else:
+		token_expired = True
 
 
 	updated = False
 	updated = False
 	if request.method == 'POST':
 	if request.method == 'POST':
@@ -29,7 +31,7 @@ def channel_settings(request, channel_id, slug):
 		'title': 'Channel settings',
 		'title': 'Channel settings',
 		'icon': 'screwdriver',
 		'icon': 'screwdriver',
 		'description': 'Modify channel settings for ' + APPLICATION_NAME,
 		'description': 'Modify channel settings for ' + APPLICATION_NAME,
-		'keywords': 'settigns, channel',
+		'keywords': 'settings, channel',
 		'form': form,
 		'form': form,
 		'updated': updated,
 		'updated': updated,
 	}
 	}

+ 5 - 2
webgui/stats/models.py

@@ -30,14 +30,17 @@ class Channel(models.Model):
 		to_field = "guild_id",
 		to_field = "guild_id",
 		db_column = "guild",
 		db_column = "guild",
 	)
 	)
+	interact = models.BooleanField(
+		default = False,
+	)
 
 
 	class Meta:
 	class Meta:
 		managed = False
 		managed = False
 		db_table = "channel"
 		db_table = "channel"
 		verbose_name_plural = "channels"
 		verbose_name_plural = "channels"
 
 
-class User(models.model):
-	id = models.Autofield(
+class User(models.Model):
+	id = models.AutoField(
 		primary_key = True,
 		primary_key = True,
 	)
 	)
 	user_id = models.BigIntegerField(
 	user_id = models.BigIntegerField(

+ 4 - 2
webgui/webgui/settings.py

@@ -9,12 +9,14 @@ https://docs.djangoproject.com/en/4.1/topics/settings/
 For the full list of settings and their values, see
 For the full list of settings and their values, see
 https://docs.djangoproject.com/en/4.1/ref/settings/
 https://docs.djangoproject.com/en/4.1/ref/settings/
 """
 """
+import os
 
 
-from pathlib import Path
-
+#
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
+from pathlib import Path
 BASE_DIR = Path(__file__).resolve().parent.parent
 BASE_DIR = Path(__file__).resolve().parent.parent
 
 
+#
 # Store environment dependant settings in local_settings.py, which is untracked by git.
 # Store environment dependant settings in local_settings.py, which is untracked by git.
 try:
 try:
     from .local_settings import *
     from .local_settings import *